1/17
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
Which data structure in Python is immutable? (Hint: Tupperware is sealed shut)
Tuple
What is the result of True and False in Python?
False
(Needs both to be True for it to count as True)
What is the result of type([1,2,3])?
<class ‘list’>
(Because [ ] makes a list)
Valid Python operators:
*+, -, , /, %, =, ==, <, >, <=, >=, and, or, not
(These are used for math and logic)
Correct way to import specific items from a module:
from module_name import item_name
Output of print(list(range(3))):
[0, 1, 2]
(Range starts at 0 and stops before 3)
Which of the following correctly declares a variable in Python?
x = 5
(No “var” or “let” like JavaScript — just name = value.)
In Python, how do you create a single line comment?
#
Which data type stores a sequence of characters?
String (str)
*(Example: "Hello")
What is the result of 7 % 3 in Python?
1
(7 divided by 3 leaves a remainder of 1.)
Which loop structure is used when you want to iterate a specific number of times?
for loop
*(Example: for i in range(5):)
How do you check if two values are equal in Python?
==
(Example: if a == b:)
What is the correct way to create a list in Python?
my_list = [1, 2, 3]
Correct syntax for an if-else statement in Python:
if condition:
# do something
else:
# do something else
(Remember the colon : and indentation!)
How do you convert a string into an integer in Python?
int(“5”) → 5
Which operator is used for string concatenation?
+
*(Example: "Hello " + "World")
Concatenation
joining two or more sequences
Immutable
an object whose state cannot be modified after it is created