Practice Activity - Python Vocabulary (Week 2) Flashcards
What is a variable?
A variable is a named memory location where information can be stored by a computer program.
Name three different data types.
The three different data types are str, int, and float. Strings are a sequence of characters, floating point numbers are numbers that can have a fractional part, and integers are whole numbers, including their negative counterparts.
What Python tool can you use to get input from the user?
You can use the built-in input() function.
Which two built-in functions allow you convert a string value to a number?
The float() and the int() functions.
What Python tool can you use to show output to the user?
You can use the print() function.
Explain how to write a Python comment.
You begin with the # symbol (outside of a literal string). Everything that comes after the # symbol is then ignored by Python.
Show an operator precedence table for the 7 mathematical operators.
**
* / // %
+ -
If two operators are on the same line, you go from left to right.
Explain what an escape character is and give at least two examples.
An escape character is a code, beginning with a backslash \ that represents a special character inside a literal string. Two examples of escape characters are ' and \n.
Show two ways of writing a literal string.
‘either inside single quote marks’
“or inside double quote marks”
Show an example of how a print statement can be split over two lines.
print(‘You would use the multiline ‘ \
+ ‘continuation character.’)
Explain the naming rules for variables.
- You can’t use a Python keyword.
- The variable name has to start with a letter or underscore.
- The variable names can only contain letters (lower or upper case), underscores and numbers.
- The variable names may not contain spaces.
- The variables should have meaningful names.
What are two tools programmers use to design programs on paper before they begin coding?
Flowcharts and pseudocode.