WGU D335 Intro to Python | OA |
Objective Assessment | 15 Actual
Questions and Answers Plus Rationales |
2026 Update | 100% Correct
1. Which line correctly assigns an integer value to a variable?
A. x = "5"
B. x == 5
C. x = 5
D. int x = 5
Answer: C
Rationale: Python assigns values using a single equals sign and does not require type
declarations.
2. What is the data type of 3.14?
A. int
B. float
C. str
D. bool
Answer: B
Rationale: Decimal numbers are stored as floats.
3. Which function converts user input into an integer?
A. input()
B. str()
C. int()
D. float()
Answer: C
Rationale: input() returns a string, which must be cast to int.
4. What is the output of this code?
,x = 10
y = "10"
print(x + int(y))
A. 1010
B. 20
C. Error
D. "20"
Answer: B
Rationale: y is converted to an integer before addition.
5. Which is a Boolean value?
A. "True"
B. 1
C. True
D. "False"
Answer: C
Rationale: Boolean values are True or False without quotes.
5. Which is a Boolean value in Python?
A. "True"
B. 1
C. True
D. "False"
Answer: C
Rationale: Boolean values in Python are True and False without quotation marks.
6. What is the output of this code?
x = 10
y = "10"
print(x + int(y))
A. 1010
B. 20
C. Error
D. "20"
Answer: B
Rationale: The string "10" is converted to an integer, allowing numeric addition.
,7. Which function converts user input into an integer?
A. input()
B. str()
C. int()
D. float()
Answer: C
Rationale: input() returns a string, which must be converted using int().
8. What is the data type of the value returned by input()?
A. int
B. float
C. string
D. boolean
Answer: C
Rationale: All user input is returned as a string by default.
9. Which line of code correctly assigns an integer to a variable?
A. x == 5
B. x = "5"
C. x = 5
D. int x = 5
Answer: C
Rationale: Python uses = for assignment and does not require type declarations.
10. What happens when this code runs?
age = input("Enter age: ")
print(age + 1)
A. Prints the next age
B. Correct output
C. TypeError
D. SyntaxError
, Answer: C
Rationale: age is a string, and Python cannot add a string and an integer.
11. Which line correctly prints text and a variable together?
A. print("x")
B. print(x)
C. print("Value:", x)
D. print(Value x)
Answer: C
Rationale: Commas allow combining strings and variables in print().
12. What symbol is used for comments in Python?
A. //
B. #
C. /* */
D. --
Answer: B
Rationale: Python uses # to indicate comments.
13. What is the output of this code?
print("Hello", "World")
A. HelloWorld
B. Hello World
C. "Hello World"
D. Error
Answer: B
Rationale: A space is automatically inserted between comma-separated values.
14. Which function displays output to the screen?
A. input()
B. print()
C. output()
D. show()
Objective Assessment | 15 Actual
Questions and Answers Plus Rationales |
2026 Update | 100% Correct
1. Which line correctly assigns an integer value to a variable?
A. x = "5"
B. x == 5
C. x = 5
D. int x = 5
Answer: C
Rationale: Python assigns values using a single equals sign and does not require type
declarations.
2. What is the data type of 3.14?
A. int
B. float
C. str
D. bool
Answer: B
Rationale: Decimal numbers are stored as floats.
3. Which function converts user input into an integer?
A. input()
B. str()
C. int()
D. float()
Answer: C
Rationale: input() returns a string, which must be cast to int.
4. What is the output of this code?
,x = 10
y = "10"
print(x + int(y))
A. 1010
B. 20
C. Error
D. "20"
Answer: B
Rationale: y is converted to an integer before addition.
5. Which is a Boolean value?
A. "True"
B. 1
C. True
D. "False"
Answer: C
Rationale: Boolean values are True or False without quotes.
5. Which is a Boolean value in Python?
A. "True"
B. 1
C. True
D. "False"
Answer: C
Rationale: Boolean values in Python are True and False without quotation marks.
6. What is the output of this code?
x = 10
y = "10"
print(x + int(y))
A. 1010
B. 20
C. Error
D. "20"
Answer: B
Rationale: The string "10" is converted to an integer, allowing numeric addition.
,7. Which function converts user input into an integer?
A. input()
B. str()
C. int()
D. float()
Answer: C
Rationale: input() returns a string, which must be converted using int().
8. What is the data type of the value returned by input()?
A. int
B. float
C. string
D. boolean
Answer: C
Rationale: All user input is returned as a string by default.
9. Which line of code correctly assigns an integer to a variable?
A. x == 5
B. x = "5"
C. x = 5
D. int x = 5
Answer: C
Rationale: Python uses = for assignment and does not require type declarations.
10. What happens when this code runs?
age = input("Enter age: ")
print(age + 1)
A. Prints the next age
B. Correct output
C. TypeError
D. SyntaxError
, Answer: C
Rationale: age is a string, and Python cannot add a string and an integer.
11. Which line correctly prints text and a variable together?
A. print("x")
B. print(x)
C. print("Value:", x)
D. print(Value x)
Answer: C
Rationale: Commas allow combining strings and variables in print().
12. What symbol is used for comments in Python?
A. //
B. #
C. /* */
D. --
Answer: B
Rationale: Python uses # to indicate comments.
13. What is the output of this code?
print("Hello", "World")
A. HelloWorld
B. Hello World
C. "Hello World"
D. Error
Answer: B
Rationale: A space is automatically inserted between comma-separated values.
14. Which function displays output to the screen?
A. input()
B. print()
C. output()
D. show()