• 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 48 pages
Exam (elaborations)

Wgu D335 – Introduction To Programming In Python Examination – Questions With Answers And Rationales

Document preview thumbnail
Preview 4 out of 48 pages

WGU D335 – INTRODUCTION TO PROGRAMMING IN PYTHON EXAMINATION – QUESTIONS With Answers and Rationales

Content preview

https://www.stuvia.com/user/performance


WGU D335 – INTRODUCTION TO PROGRAMMING IN PYTHON EXAMINATION –
QUESTIONS With Answers and Rationales



1. Which of the following is the correct way to print "Hello,
World!" in Python?
A) print("Hello, World!")
B) echo "Hello, World!"
C) console.log("Hello, World!")
D) printf("Hello, World!")
Answer: A
Rationale: Python uses the print() function to output text.
2. What is the output of the following code?
python
x=5
y=2
print(x // y)
A) 2.5
B) 2
C) 2.0
D) 3

,https://www.stuvia.com/user/performance


Answer: B
Rationale: // is floor division, which returns the integer part of
the quotient (5 // 2 = 2).
3. Which of the following is a valid variable name in Python?
A) 2variable
B) my-variable
C) _variable
D) class
Answer: C
Rationale: Variable names cannot start with a digit, cannot
contain hyphens, and cannot be Python keywords. _variable is
valid.
4. What data type is the result of in Python 3?
A) int
B) float
C) str
D) bool
Answer: B
Rationale: In Python 3, the / operator always returns a float
(1.5).
5. What is the output of the following code?
python
s = "Python"

,https://www.stuvia.com/user/performance


print(s[1])
A) P
B) y
C) t
D) h
Answer: B
Rationale: String indexing starts at 0, so s[1] is the second
character, 'y'.
6. Which of the following is used to define a function in
Python?
A) function
B) def
C) define
D) func
Answer: B
Rationale: Python uses the def keyword to define functions.
7. What will be the output of the following code?
python
print(2 ** 3)
A) 6
B) 8
C) 5
D) 9

, https://www.stuvia.com/user/performance


Answer: B
Rationale: ** is the exponentiation operator; 2 raised to the
power 3 equals 8.
8. Which of the following is a valid list in Python?
A) [1, 2, 3]
B) {1, 2, 3}
C) (1, 2, 3)
D) 1, 2, 3
Answer: A
Rationale: Square brackets [] denote a list.
9. How do you add an element to the end of a list?
A) list.add(item)
B) list.append(item)
C) list.insert(item)
D) list.push(item)
Answer: B
Rationale: The append() method adds an item to the end of a
list.
10. What is the output of the following code?
python
x = [1, 2, 3]
print(len(x))

Document information

Uploaded on
September 4, 2026
Number of pages
48
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
CA$28.42

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

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Performance
4.3
(244)
Sold
591
Followers
45
Items
20000
Last sold
3 days ago



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