Module 3 Chapter 1 Quiz Answers
Question 1
When Python is running in interactive mode and displaying the chevron prompt (>>>
), what question is Python asking you?
A. What would you like to do?
B. What is the next machine language instruction to run?
C. What Python script would you like me to run?
D. What is your favorite color?
โ Correct Answer: A. What would you like to do?
๐น Explanation:
When Python shows >>>
, it is asking for user inputโexpecting you to type a command or execute a statement. It is not running a script but waiting for instructions interactively.
Question 2
What will the following program print out?
A. 20
B. 5
C. 15
D. “print x”
E. x + 5
โ Correct Answer: A. 20
๐น Explanation:
x = 15
assigns the value 15 tox
.x = x + 5
increasesx
by 5, so nowx = 20
.print(x)
displays20
.
Question 3
Python scripts (files) have names that end with:
A. .doc
B. .py
C. .png
D. .exe
โ Correct Answer: B. .py
๐น Explanation:
Python scripts use the .py
extension (e.g., script.py
). Other file extensions like .doc
are for Word documents, .png
is for images, and .exe
is for executable programs.
Question 4
Which of these words are reserved words in Python?
A. make
B. break
C. concat
D. if
E. todo
โ Correct Answers: B. break, D. if
๐น Explanation:
Reserved words (keywords) are predefined in Python and cannot be used as variable names.
break
is used to exit loops.if
is used for conditional statements.make
,concat
, andtodo
are not Python keywords.
Question 5
What is the proper way to say โgoodbyeโ to Python?
A. while
B. #EXIT
C. // stop
D. quit()
โ Correct Answer: D. quit()
๐น Explanation:
quit()
is a built-in function to exit the Python interpreter.while
is a loop keyword.#EXIT
is a comment, and// stop
is not valid syntax in Python.
Question 6
Which part of a computer actually executes the program instructions?
A. Central Processing Unit
B. Secondary Memory
C. Main Memory
D. Input/Output Devices
โ Correct Answer: A. Central Processing Unit (CPU)
๐น Explanation:
The CPU (Central Processing Unit) executes program instructions.
- Main Memory (RAM) temporarily holds data for quick access.
- Secondary Memory (like hard drives) stores data permanently.
- Input/Output Devices (like keyboards and monitors) allow user interaction.
Question 7
What is “code” in the context of this course?
A. A set of rules that govern the style of programs
B. A sequence of instructions in a programming language
C. A way to encrypt data during World War II
D. A password we use to unlock Python features
โ Correct Answer: B. A sequence of instructions in a programming language
๐น Explanation:
“Code” refers to written instructions in a programming language (e.g., Python). These instructions tell the computer what to do.
Question 8
A USB memory stick is an example of which component of computer architecture?
A. Secondary Memory
B. Central Processing Unit
C. Output Device
D. Main Memory
โ Correct Answer: A. Secondary Memory
๐น Explanation:
A USB memory stick stores data permanently, making it secondary memory.
- Main Memory (RAM) is temporary storage.
- CPU executes instructions.
- Output Devices (like monitors) display information.
Question 9
What is the best way to think about a “Syntax Error” while programming?
A. The computer did not understand the statement that you entered
B. The computer needs to have its software upgraded
C. The computer has used GPS to find your location and hates everyone from your town
D. The computer is overheating and just wants you to stop to let it cool down
โ Correct Answer: A. The computer did not understand the statement that you entered
๐น Explanation:
A syntax error happens when Python does not understand your code due to incorrect grammar (e.g., missing a colon in a function definition).
Question 10
Which of the following is NOT one of the programming patterns covered in Chapter 1?
A. Random steps
B. Repeated Steps
C. Sequential Steps
D. Conditional Steps
โ Correct Answer: A. Random steps
๐น Explanation:
Programming patterns include:
- Sequential Steps: Executing instructions in order.
- Repeated Steps: Using loops to repeat tasks.
- Conditional Steps: Making decisions using
if
statements. - Random Steps are not a structured programming pattern.