WGU E010 Foundations of Programming (Python) OA |
100+ Questions & Answers | 2026 Updated Study Guide
Python Fundamentals & Syntax
Question 1
Which statement correctly describes the purpose of Python indentation?
A. It determines the data type of a variable
B. It defines blocks of code such as those inside loops and conditional statements
C. It converts strings into integers
D. It determines the order in which variables are created
Correct Answer: B. It defines blocks of code such as those inside loops and conditional
statements
Rationale:
Python uses indentation to define the beginning and end of code blocks. For example, statements
belonging to an if, for, or while block must be consistently indented. Unlike languages that
commonly use braces {}, Python relies on indentation as part of its syntax.
Question 2
Which line correctly assigns the integer value 25 to a variable named age?
A. integer age = 25
B. age == 25
C. age = 25
D. 25 = age
Correct Answer: C. age = 25
Rationale:
The assignment operator = assigns a value to a variable. Therefore, age = 25 stores the integer
25 in the variable age.
The == operator is used for comparison, not assignment.
Question 3
,What is displayed by the following code?
print("Python")
print("Programming")
A. Python Programming on one line
B. PythonProgramming on one line
C. Python followed by Programming on the next line
D. Nothing because two print statements cannot be used consecutively
Correct Answer: C. Python followed by Programming on the next line
Rationale:
By default, print() ends with a newline character. Therefore, each print() statement displays
its argument on a separate line.
Question 4
Which symbol begins a single-line comment in Python?
A. //
B. <!--
C. #
D. /*
Correct Answer: C. #
Rationale:
Python uses the hash symbol (#) to begin a single-line comment.
Example:
# This is a comment
print("Hello")
The Python interpreter ignores everything after # on that line.
Question 5
What will the following code display?
x = 10
x = 20
,print(x)
A. 10
B. 20
C. 30
D. An error because x cannot be reassigned
Correct Answer: B. 20
Rationale:
Python variables can be reassigned. The first statement assigns 10 to x, but the second statement
replaces that value with 20. Therefore, print(x) displays 20.
Variables & Data Types
Question 6
Which Python data type is used to represent a value such as 3.14?
A. int
B. str
C. float
D. bool
Correct Answer: C. float
Rationale:
A floating-point number represents a number containing a decimal component. For example:
price = 3.14
The variable price contains a float.
Question 7
What is the data type of the value "100"?
A. int
B. float
C. str
D. bool
, Correct Answer: C. str
Rationale:
Quotation marks indicate that 100 is being represented as text rather than as a numeric integer.
x = "100"
Here, x is a string.
Question 8
What is the output?
x = 7
y = 2
print(x + y)
A. 5
B. 9
C. 14
D. 72
Correct Answer: B. 9
Rationale:
Both variables contain integers. The + operator performs arithmetic addition:
7 + 2 = 9
Question 9
What is the output?
x = "7"
y = "2"
print(x + y)
A. 9
B. 72
C. 14
D. An error
Correct Answer: B. 72
100+ Questions & Answers | 2026 Updated Study Guide
Python Fundamentals & Syntax
Question 1
Which statement correctly describes the purpose of Python indentation?
A. It determines the data type of a variable
B. It defines blocks of code such as those inside loops and conditional statements
C. It converts strings into integers
D. It determines the order in which variables are created
Correct Answer: B. It defines blocks of code such as those inside loops and conditional
statements
Rationale:
Python uses indentation to define the beginning and end of code blocks. For example, statements
belonging to an if, for, or while block must be consistently indented. Unlike languages that
commonly use braces {}, Python relies on indentation as part of its syntax.
Question 2
Which line correctly assigns the integer value 25 to a variable named age?
A. integer age = 25
B. age == 25
C. age = 25
D. 25 = age
Correct Answer: C. age = 25
Rationale:
The assignment operator = assigns a value to a variable. Therefore, age = 25 stores the integer
25 in the variable age.
The == operator is used for comparison, not assignment.
Question 3
,What is displayed by the following code?
print("Python")
print("Programming")
A. Python Programming on one line
B. PythonProgramming on one line
C. Python followed by Programming on the next line
D. Nothing because two print statements cannot be used consecutively
Correct Answer: C. Python followed by Programming on the next line
Rationale:
By default, print() ends with a newline character. Therefore, each print() statement displays
its argument on a separate line.
Question 4
Which symbol begins a single-line comment in Python?
A. //
B. <!--
C. #
D. /*
Correct Answer: C. #
Rationale:
Python uses the hash symbol (#) to begin a single-line comment.
Example:
# This is a comment
print("Hello")
The Python interpreter ignores everything after # on that line.
Question 5
What will the following code display?
x = 10
x = 20
,print(x)
A. 10
B. 20
C. 30
D. An error because x cannot be reassigned
Correct Answer: B. 20
Rationale:
Python variables can be reassigned. The first statement assigns 10 to x, but the second statement
replaces that value with 20. Therefore, print(x) displays 20.
Variables & Data Types
Question 6
Which Python data type is used to represent a value such as 3.14?
A. int
B. str
C. float
D. bool
Correct Answer: C. float
Rationale:
A floating-point number represents a number containing a decimal component. For example:
price = 3.14
The variable price contains a float.
Question 7
What is the data type of the value "100"?
A. int
B. float
C. str
D. bool
, Correct Answer: C. str
Rationale:
Quotation marks indicate that 100 is being represented as text rather than as a numeric integer.
x = "100"
Here, x is a string.
Question 8
What is the output?
x = 7
y = 2
print(x + y)
A. 5
B. 9
C. 14
D. 72
Correct Answer: B. 9
Rationale:
Both variables contain integers. The + operator performs arithmetic addition:
7 + 2 = 9
Question 9
What is the output?
x = "7"
y = "2"
print(x + y)
A. 9
B. 72
C. 14
D. An error
Correct Answer: B. 72