Free Online Flashcard Deck

2 Variables, Types, and Expressions Free Online FlashCards

Study 2 Variables, Types, and Expressions with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What rules must a valid Python name follow?

Back

A Python name must begin with a letter or underscore, may continue with letters, digits, or underscores, is case-sensitive, and cannot be a keyword.

02
Front

What does Python assignment do?

Back

Assignment evaluates the expression on the right first, then binds its resulting object to the name on the left. The equals sign does not mean mathematical equality.

03
Front

What does dynamically typed mean in Python?

Back

Python is dynamically typed: a name has no permanently declared type; the object currently associated with it determines the type.

04
Front

What do `//` and `%` do in Python?

Back

The operator `//` performs floor division, while `%` produces the remainder. For example, `7 // 3` is `2` and `7 % 3` is `1`.

05
Front

What is the difference between `=` and `==`?

Back

`=` assigns a value to a name; `==` compares two values and produces a Boolean result.

06
Front

What is short-circuit evaluation?

Back

Python may skip the right-hand operand of `and` or `or` when the result is already determined. This behavior is called short-circuit evaluation.

07
Front

What type does `input()` return?

Back

`input()` always returns a string. Convert it with `int()` or `float()` before using the input in numeric calculations.

08
Front

How does `int()` convert a float?

Back

`int()` truncates a floating-point value toward zero; it does not round it. Thus, `int(3.9)` returns `3`.

09
Front

How do f-strings insert values into text?

Back

An f-string places expressions inside braces, such as `f"{name} was born in {year}."`, making interpolation readable and direct.

10
Front

What happens when `other_numbers = numbers` aliases a list?

Back

Assignment binds another name to the same list object; it does not copy the list. Mutating through either name is therefore visible through both.

11
Front

How can you make a shallow list copy?

Back

Use a slice such as `numbers[:]` or the `list()` constructor to create a separate shallow copy of a list.

12
Front

Why can’t a Python string be changed in place?

Back

A string is immutable, so operations such as `.upper()` create a new string. Rebinding the name does not modify the original string.