Which statement correctly distinguishes syntax from semantics in a programming language?
3 Programming Fundamentals Online Quiz Questions
Use this free practice quiz with 20 questions to review 3 Programming Fundamentals, test your knowledge, and prepare for your next test or exam.
True or false: In Python, the single equals sign (=) assigns a value, while the double equals sign (==) tests equality.
- A
True
- B
False
What Python data type does input() return for the user's response before any explicit conversion?
Python uses uppercase names as a for values intended not to change during program execution.
What value does the Python expression 17 // 5 produce?
- A
2
- B
3
- C
4
- D
3.4
Which statements correctly describe variables and names in Python? Select all that apply.
- A
A name is bound to a value or object.
- B
A name can later be bound to a value of another type.
- C
total,Total, andTOTALare different identifiers. - D
A variable receives a permanent type declaration when it is first assigned.
True or false: In Python, a comment beginning with # continues to the end of the physical line and is normally ignored during execution.
- A
True
- B
False
What category of error occurs when a program runs successfully but produces an incorrect result because its algorithm or expression is wrong?
Before executing valid code blocks, the interpreter the source code.
Which statements correctly describe expressions and statements in Python? Select all that apply.
- A
An expression can compute or produce a value.
- B
A statement can perform an action or control which code runs.
- C
A comparison expression produces a Boolean value.
- D
An
if,for, orwhilecompound statement introduces a block of indented statements.
A syntactically valid Python program attempts to divide a number by zero while it is running. What kind of error is this?
- A
Syntax error
- B
Logic error
- C
Runtime error
- D
Name error caused by comments
Consider the notebook-cost program from the material. Explain how it follows an input–processing–output pattern, including why numeric conversion is needed and how the intermediate values are used. Then calculate the subtotal, tax, and total when the quantity is 3, the price of one notebook is 4.00, and the tax rate is 0.07.
A Python program contains the statement print("Hello" with no closing parenthesis. What kind of error occurs first?
- A
A runtime error caused while the statement runs
- B
A syntax error detected before execution
- C
A logic error that produces an incorrect value
- D
No error because Python adds the missing parenthesis
What value is displayed by this code?
x = 10print(x == 10)
- A
It assigns False to x
- B
It produces the number 10
- C
It evaluates to True
- D
It causes a syntax error
A program executes quantity = int(input()), and the user enters three. What is the most likely result?
- A
A runtime exception during integer conversion
- B
A syntax error before the program starts
- C
The integer 3
- D
The string
threestored as an integer
What happens when this code runs?
print(total)total = 12
- A
The program prints 0
- B
The program waits for input to define total
- C
The program produces a syntax error because print() cannot use variables
- D
The program raises a NameError when total is referenced
A programmer writes DAYS_PER_WEEK = 7. Which statement best describes this name in Python?
- A
Python prevents any later assignment to an uppercase name
- B
An uppercase name is automatically given the constant data type
- C
Uppercase naming communicates intent but does not prevent reassignment
- D
Only values defined with a special constant keyword can be used in expressions
True or false: In Python, a comment beginning with # is normally ignored during program execution.
- A
True
- B
False
What integer does the Python expression 17 // 5 produce?
What type does Python’s input() function return before any explicit conversion?