• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 54 pages
Exam (elaborations)

WGU D335 Intro to Python | OA | Objective Assessment | 15 Actual Questions and Answers | 2025 Update | 100% Correct.

Document preview thumbnail
Preview 4 out of 54 pages

WGU D335 Intro to Python | OA | Objective Assessment | 15 Actual Questions and Answers | 2025 Update | 100% Correct.

Content preview

WGU D335 Intro to Python | OA | Objective
Assessment | 15 Actual Questions and
Answers | 2025 Update | 100% Correct.
Part I: Python Fundamentals & Syntax (Questions 1–35)

Question 1

What is the output of the following code?

python

x=7

y=2

result = x // y + x % y

print(result)

A. 3
B. 3.5
C. 4
D. 5

Rationale: x // y performs floor division (7 // 2 = 3). x % y performs modulo (7 % 2 = 1). 3 +
1 = 4. Option A misses the modulo addition. Option B confuses floor division with true
division. Option D incorrectly adds 7 + 2 instead of using the operators.



Question 2

A student writes the following code to convert user input to an integer and calculate a 15%
tip. Which line contains a logic error that will cause the program to fail at runtime?

python

bill = input("Enter bill amount: ")

tip = bill * 0.15

total = bill + tip

,print(f"Total: {total}")

A. Line 1: bill = input("Enter bill amount: ")
B. Line 2: tip = bill * 0.15
C. Line 3: total = bill + tip
D. Line 4: print(f"Total: {total}")

Rationale: input() returns a string; arithmetic operations on strings cause TypeError. The
fix requires bill = float(input("Enter bill amount: ")). While lines 2–3 would also fail, line 1 is
the root cause—without type conversion, all subsequent arithmetic fails. This is the most
common OA error pattern: forgetting that input() always returns a string.



Question 3

What is the correct way to print "Hello World" in Python?

A. print("Hello World")
B. printf("Hello World")
C. System.out.println("Hello World")
D. console.log("Hello World")

Rationale: Python uses the print() function to output text to the console. The text must be
enclosed in quotes (single or double). The other options are syntax from other programming
languages (C, Java, JavaScript respectively).



Question 4

Which of the following is NOT a valid Python comment?

A. # This is a comment
B. // This is a comment
C. """ This is a multi-line comment """
D. ''' This is also a multi-line comment '''

Rationale: In Python, single-line comments start with #. Multi-line comments can use
triple quotes (""" or '''). // is used for comments in languages like C++, Java, and JavaScript,
but not in Python.



Question 5

,What is the output of print(type(3.14))?

A. <class 'int'>
B. <class 'float'>
C. <class 'str'>
D. <class 'bool'>

Rationale: 3.14 is a floating-point number. The type() function returns the data type of the
argument. Integers are whole numbers without a decimal point.



Question 6

Which of the following is a valid variable name in Python?

A. 2nd_place
B. my-variable
C. private
D. class

Rationale: Variable names can start with a letter or underscore (_), followed by letters,
numbers, or underscores. They cannot start with a digit (eliminating A), cannot contain
hyphens (eliminating B), and cannot be reserved keywords like class (eliminating D).



Question 7

What is the output of bool(0)?

A. True
B. False
C. 0
D. None

Rationale: In Python, 0 is considered False when converted to a Boolean. Any non-zero
number (positive or negative) is considered True. Empty containers like [], (), {}, "" are also
False.



Question 8

What is the output of bool("Hello")?

, A. True
B. False
C. "Hello"
D. Error

Rationale: Any non-empty string is considered True in a Boolean context. Only empty
strings ("") are considered False.



Question 9

What is the output of print("5" + "3")?

A. 8
B. 53
C. Error
D. "5 3"

Rationale: The + operator concatenates strings. "5" + "3" results in "53". To perform
numeric addition, you would need to convert the strings to integers first.



Question 10

What is the output of print("Hello" * 3)?

A. HelloHelloHello
B. Hello Hello Hello
C. Hello3
D. Error

Rationale: The * operator repeats strings. "Hello" * 3 repeats the string three times,
resulting in "HelloHelloHello".



Question 11

Which function is used to get user input in Python?

A. input()
B. get_input()

Document information

Uploaded on
September 27, 2026
Number of pages
54
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$27.09

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
353
Last sold
-




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions