Practice Activity - Python Vocabulary (Week 2) Flashcards

1
Q

What is a variable?

A

A variable is a named memory location where information can be stored by a computer program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Name three different data types.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What Python tool can you use to get input from the user?

A

You can use the built-in input() function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which two built-in functions allow you convert a string value to a number?

A

The float() and the int() functions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What Python tool can you use to show output to the user?

A

You can use the print() function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Explain how to write a Python comment.

A

You begin with the # symbol (outside of a literal string). Everything that comes after the # symbol is then ignored by Python.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Show an operator precedence table for the 7 mathematical operators.

A

**
* / // %
+ -

If two operators are on the same line, you go from left to right.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Explain what an escape character is and give at least two examples.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Show two ways of writing a literal string.

A

‘either inside single quote marks’

“or inside double quote marks”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Show an example of how a print statement can be split over two lines.

A

print(‘You would use the multiline ‘ \

+ ‘continuation character.’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain the naming rules for variables.

A
  1. You can’t use a Python keyword.
  2. The variable name has to start with a letter or underscore.
  3. The variable names can only contain letters (lower or upper case), underscores and numbers.
  4. The variable names may not contain spaces.
  5. The variables should have meaningful names.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are two tools programmers use to design programs on paper before they begin coding?

A

Flowcharts and pseudocode.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly