Consider this Python code: balance = 100; balance = balance - 25; balance = balance + 10. After all three statements execute, is balance equal to 85?
02 Variables, Expressions, and Input/Output Online Quiz Questions
Use this free practice quiz with 20 questions to review 02 Variables, Expressions, and Input/Output, test your knowledge, and prepare for your next test or exam.
Which item is an integer literal in Python?
- A
answer - B
42 - C
value - D
number
What type of value does Python's input() function return before any conversion?
Complete the statement: In Python, the operator that assigns a value to a variable is .
What value is assigned to result by this statement: result = 2 + 3 * 4?
- A
10
- B
20
- C
14
- D
24
True or false: In Python, assigning a new value to an uppercase constant name always causes an error.
- A
True
- B
False
Which operations are demonstrated by this data flow: receive a number as text, convert it to an integer, store the result, and display it? Select all four correct choices.
- A
Reading a response with input()
- B
Displaying text with print()
- C
Converting text with int()
- D
Storing a result through assignment
- E
Merely writing an expression without using its result
What is the name of the arithmetic operation performed by the Python operator //?
Complete the statement: A Python string written with a leading f so that expressions can be evaluated inside braces is called an .
Which expression tests whether the variable score has the value 100?
- A
score = 100 - B
score == 100 - C
score != 100 - D
score + 100
Which three statements accurately describe common issues or safeguards when using Python input? Select all correct choices.
- A
Two unconverted numeric inputs can be concatenated instead of added.
- B
input()automatically returns an integer when the user enters digits. - C
int()can convert suitable numeric text for arithmetic. - D
Every text response can be converted successfully with
int(). - E
A conversion can fail when the text does not have the expected numeric format.
What value does count have after this code executes? count = 5; count += 2; count *= 3.
- A
15
- B
17
- C
21
- D
7
Trace this Python code and state the final values of subtotal, tax, and total, explaining how each value is produced: TAX_RATE = 0.08; price = 12; quantity = 3; subtotal = price * quantity; tax = subtotal * TAX_RATE; total = subtotal + tax.
What value is assigned to remainder by this Python statement: remainder = 17 % 5?
- A
3
- B
12
- C
2
- D
5
True or false: The Python statement x = x + 1 is valid when x already has the value 4, and afterward x has the value 5.
- A
True
- B
False
Which statement best describes the conventional use of uppercase names such as TAX_RATE in Python?
- A
Python prevents any later assignment to an uppercase name.
- B
An uppercase name communicates that the program intends the value not to change.
- C
Only string values can be assigned to uppercase names.
- D
An uppercase name automatically creates a special constant object.
What value is assigned to result by this statement?
result = 2 + 3 * 4
- A
10
- B
20
- C
14
- D
24
What is the final value of balance after this code executes?
balance = 100
balance = balance - 25
balance = balance + 10
Suppose score = 100. What does is_perfect = (score == 100) do?
- A
It increases
scoreby 100. - B
It tests whether
scoreequals 100 and stores the Boolean result. - C
It changes the type of
scoreto Boolean without testing it. - D
It tests whether
scoreis greater than 100.
Which Python function converts numeric text into an integer?
Related study packs and tools
2 Digital Logic
A 14-question medium-difficulty quiz on Boolean algebra, logic gates, truth tables, and combinational circuits.
03 — Python Programming Fundamentals
A focused set of flashcards covering Python variables, data types, expressions, control flow, functions, input, output, and common programming practices.
05 — Data Structures: Concepts, Operations, and Trade-Offs
A structured guide to the main data structures, their operations, efficiency trade-offs, representations, and practical selection criteria.
6 Computer Memory
Learn how computer memory stores and addresses information, how RAM and ROM differ, and how caches and the memory hierarchy balance speed, capacity, and cost.
07 Trees and Binary Search Trees
A progressive guide to tree structure, binary-tree traversals, binary search tree operations, deletion, balancing, and the way tree height determines time and space costs.
12 — Foundations Capstone: Integrating Computer Science
A practical guide to integrating problem definition, data representation, modular programming, algorithms, complexity analysis, testing, correctness, and ethical evaluation into a responsible computer science capstone.
Interrupts
Reviews how interrupts support event handling and multitasking, and how Linux system calls use the RISC-V `ecall` instruction and register conventions.
OS Processes
This quiz covers process management, context switching and scheduling, multitasking, traps and interrupts, and RISC-V privilege transitions.
Systemcalls
A quiz on operating-system system calls, including privileged-operation requests, process creation and execution with fork, exec, and waitpid, and signal handling.