Certification Courses
Want a structured paid program with certificate and roadmap?
What is the output of `print(2 + 3 * 4)` in Python?
Multiplication has higher precedence than addition, so Python evaluates 3 * 4 before adding 2.
Which assignment changes the value stored in `count` to the integer 3?
A single equals sign assigns the value on its right to the variable on its left.
What type does `input()` return before explicit conversion?
`input()` returns text. Convert it with `int()` or `float()` when numeric operations are intended.
Which expression checks whether `age` is at least 18?
The greater-than-or-equal operator is written `>=` and evaluates to a Boolean.
What is printed by `for n in range(3): print(n)`?
`range(3)` produces 0, 1, and 2; its stop value is excluded.
Given `word = 'Haahwaan'`, what does `word[0:3]` return?
A slice includes the start index and excludes the stop index, so indices 0, 1, and 2 are returned.
Which list operation adds `'blue'` to the end of `colors`?
Python lists use `append` to add one item at the end.
Which statement correctly creates a one-item tuple containing the integer 5?
The comma makes `(5,)` a one-item tuple; parentheses around 5 alone do not.
How do you safely retrieve key `'city'` from a dictionary `profile` with a fallback of `'unknown'`?
Dictionary `get` returns the supplied default when the key is absent instead of raising KeyError.
Which condition runs the first branch only when `score` is at least 50?
Use a comparison operator such as `>=` in an `if` condition; `=` is assignment.
What does `def double(number): return number * 2` do when called as `double(4)`?
`return` sends the computed value back to the caller; it does not print it.
Which block is used to handle a possible `ValueError` while converting user text to an integer?
Python uses `try` and `except` to handle specified exceptions such as an invalid integer conversion.
A loop should stop when it finds the first item that meets a condition. Which statement exits that loop?
`break` exits the nearest loop; `continue` skips only the current iteration.
A function should return a new list without changing the caller's original list. Which approach is safest?
A shallow copy such as `items.copy()` separates list-level mutations from the caller's list.