1/52
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
The break statement can be used to exit a loop prematurely
True
It is possible to use the break statement to exit multiple nested loops at once
False
The continue statement skips the rest of the current iteration and moves to the next
True
The sequence from range(n) starts at 1 and goes up to (but not including) n
False
Nested loops require using both for and while loops
False
Infinite loops occur when the loop condition never becomes false or there is no exit statement in the body
True
The body of a while loop is guaranteed to execute at least once
False
A while True loop runs indefinitely until a break or an error occurs
True
The loop condition in a while loop is evaluated before each iteration
True
The loop control variable in for x in range(2) can be accessed outside the loop
True
A function must always have a return statement
False
A variable defined within a function is limited to that function and not accessible outside it
True
You can call a function without passing arguments even if it has parameters with no default value
False
If a function lacks a return statement (or returns without a value) it implicitly returns 0
False
A function can have multiple parameters with the same name as long as they have different default values
False
Keyword arguments are passed by position and positional arguments are specified by name
False
Passing a mutable object to a function allows the function to modify that object
True
break and return are interchangeable
False
A function may have multiple return statements but only one executes per call
True
Functions can return multiple values with a comma-separated return (tuple packing)
True
Python allows creating a class with no attributes or methods
True
Variables defined in init need the self prefix to become instance attributes
True
All user-defined classes in Python are mutable
False
If a class lacks str — you can still print an object of that class
True
You can instantiate a user-defined class without explicitly defining init
True
All attributes of a class can be accessed and modified from outside the class
False
Modifying an attribute of one instance affects that attribute in all other instances
False
When creating a class object you must explicitly provide values for all instance attributes
False
In method definitions — self refers to the instance and lets the method access its attributes
True
You can change an object’s class after it is created
False
If init defines attributes — all instances of the class will have those attributes
True
Characters are a different type from strings in Python
False
If s1 == s2 then s1 in s2 returns False because in checks partial matches
False
You can directly modify a character in a string with s[2] = 'z'
False
To loop over indices of s you can use for i in range(len(s) + 1)
False
Strings are 0-based indexed
True
strip() removes both leading and trailing whitespace
True
Relational operators compare strings by length
False
Strings can be indexed using negative numbers
True
For a string s — min(s) == max(s) is always False
False
islower() · isdigit() · isalpha() are standalone functions (not methods)
False
In for i in s — i refers to a character of s each iteration
True
Comparing two lists of different lengths causes an error
False
It is possible to directly convert a list to a string in Python
True
append() adds an element to the beginning of a list
False
[x for x in range(10) if not x % 2] creates a list of only positive even integers
False
Lists cannot be negatively indexed
False
remove() deletes an element by index
False
You can convert items of other (iterable) types directly to a list
True
Lists can only contain items of the same data type
False
The += operator can concatenate two lists
True
Lists have a fixed maximum size after which you cannot add elements
False
pop() removes and returns the last element of a list (by default)
True