u01-slides-python Flashcards

1
Q

What is the standard filename suffix for Python files?

A

.py

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

What version of Python is recommended in the course?

A

Version ≥ 3.11

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

In what order is Python code executed?

A

Line by line from first line to last line

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

How are expressions evaluated in Python?

A

From left to right (e.g. a + b + c is equivalent to (a + b) + c)

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

How are assignments evaluated in Python?

A

From right to left (e.g. x = a + b is equivalent to x = (a + (b)))

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

What character is used to start a comment in Python?

A

The hashtag character (#)

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

What is the purpose of comments in Python code?

A

To document code - they are not executed and have no effect on program behavior

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

What are the main data types covered in the course?

A

bool (Boolean), int (Integer), float (Float), str (String)

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

What values can a Boolean data type store?

A

Only two values: False (0) or True (1)

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

What is special about integers in Python?

A

They are not limited by fixed size (e.g. 32 bits) but are variable-length objects of arbitrary size

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

What is the range for double-precision floats in Python?

A

Between approximately ±2.2 × 10^-308 and ±1.8 × 10^308

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

What is dynamic typing in Python?

A

The data type is determined during run time and is associated with the value itself not the variable

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

What are variables in Python?

A

References or names that are bound to objects - they don’t store information themselves

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

What are the rules for variable names in Python?

A

Must start with non-digits/non-operators, are case sensitive, conventionally lowercase with underscores

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

How do you get user input from the console in Python?

A

Using the input() function

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

What is the data type of console input in Python?

A

String (str) - data type conversion must be done manually if needed

17
Q

What happens when you assign a variable to another variable in Python?

A

Both variables reference the same object in memory

18
Q

What happens when you reassign a value to a variable in Python?

A

It creates a new reference to a new object - it doesn’t modify the original object

19
Q

Where can you find Python style recommendations?

A

https://www.python.org/dev/peps/pep-0008/

20
Q

What is the conventional format for variable names in Python?

A

Lower case with words separated by underscores (e.g.

21
Q

How do you print output to the console in Python?

A

Using the print() function

22
Q

Why is code style important in Python?

A

It helps achieve maintainability, consistency, and helps other programmers understand the code

23
Q

What is an object in Python?

A

Everything in Python is an object

24
Q

What are some examples of reserved keywords in Python?

A

if, while, for, def, class