100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

WGU D335 Practice Test 2/Intro to python (OA) practice With complete solution Newest 2025/26 RATED A+

Rating
-
Sold
-
Pages
15
Grade
A+
Uploaded on
07-03-2025
Written in
2024/2025

WGU D335 Practice Test 2/Intro to python (OA) practice With complete solution Newest 2025/26 RATED A+ WGU D335 Practice Test 2/Intro to python (OA) practice With complete solution Newest 2025/26 RATED A+ WGU D335 Practice Test 2/Intro to python (OA) practice With complete solution Newest 2025/26 RATED A+ WGU D335 Practice Test 2/Intro to python (OA) practice With complete solution Newest 2025/26 RATED A+ WGU D335 Practice Test 2/Intro to python (OA) practice With complete solution Newest 2025/26 RATED A+ WGU D335 Practice Test 2/Intro to python (OA) practice With complete solution Newest 2025/26 RATED A+ WGU D335 Practice Test 2/Intro to python (OA) practice With complete solution Newest 2025/26 RATED A+

Show more Read less
Institution
WGU D335
Course
WGU D335









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
WGU D335
Course
WGU D335

Document information

Uploaded on
March 7, 2025
Number of pages
15
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

WGU D335 Practice Test 2/Intro to python
(OA) practice With complete solution
Newest 2025/26 RATED A+
Create a solution that accepts three integer inputs representing the number of times an employee travels
II! II! II! II! II! II! II! II! II! II! II! II! II! II! II!




to a job site. Output the total distance traveled to two decimal places given the following miles per
II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II!




employee commute to the job site. Output the total distance traveled to two decimal places given the
II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II!




following miles per employee commute to the job site:
II! II! II! II! II! II! II! II! II!




Employee A: 15.62 miles II! II! II!




Employee B: 41.85 miles II! II! II!




Employee C: 32.67 miles II! II! II!




times_traveledA = int(input()) II! II!




times_traveledB = int(input()) II! II!




times_traveledC = int(input()) II! II!




employeeA = 15.62 #miles II! II! II!




employeeB = 41.85 #miles II! II! II!




employeeC = 32.67 #miles II! II! II!




distance_traveledA = times_traveledA * employeeA II! II! II! II!




distance_traveledB = times_traveledB * employeeB II! II! II! II!




distance_traveledC = times_traveledC * employeeC II! II! II! II!




total_miles_traveled = distance_traveledA + distance_traveledB + distance_traveledC II! II! II! II! II! II!




print('Distance: {:.2f} miles'.format(total_miles_traveled)) II! II!




Create a solution that accepts an input identifying the name of a text file, for example,
II! II! II! II! II! II! II! II! II! II! II! II! II! II! II!




"WordTextFile1.txt". Each text file contains three rows with one word per row. Using the open() function
II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II!




and write() and read() methods, interact with the input text file to write a new sentence string composed
II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II!




of the three existing words to the end of the file contents on a new line. Output the new file contents.
II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II!




file_name = input() II! II!




with open(file_name, 'r') as f:
II! II! II! II!




word1 = str(f.readline()).strip()
II! II!




word2 = str(f.readline()).strip()
II! II!




word3 = str(f.readline()).strip()
II! II!




f = open(file_name, 'r')
II! II! II!




lines = f.read().splitlines()
II! II!




lines = ' '.join(lines) II! II! II!




f.close()
print(f'{word1}\n{word2}\n{word3}\n{lines}')

, Create a solution that accepts an integer input representing any number of ounces. Output the converted
II! II! II! II! II! II! II! II! II! II! II! II! II! II! II!




total number of tons, pounds, and remaining ounces based on the input ounces value. There are 16
II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II!




ounces in a pound and 2,000 pounds in a ton.
II! II! II! II! II! II! II! II! II! II!




ounces_per_pound = 16 II! II!




pounds_per_ton = 2000 II! II!




number_ounces = int(input()) II! II!




tons = number_ounces // (ounces_per_pound * pounds_per_ton)
II! II! II! II! II! II!




remaining_ounces = number_ounces % (ounces_per_pound * pounds_per_ton) II! II! II! II! II! II!




pounds = remaining_ounces // ounces_per_pound II! II! II! II!




remaining_ounces = remaining_ounces % ounces_per_pound II! II! II! II!




print('Tons: {}'.format(tons)) II!




print('Pounds: {}'.format(pounds)) II!




print('Ounces: {}'.format(remaining_ounces)) II!




Create a solution that accepts an input identifying the name of a CSV file, for example, "input1.csv". Each
II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II!




file contains two rows of comma-separated values. Import the built-in module csv and use its open()
II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II!




function and reader() method to create a dictionary of key:value pairs for each row of comma-separated
II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II!




values in the specified file. Output the file contents as two dictionaries.
II! II! II! II! II! II! II! II! II! II! II! II!




import csv II!




input1 = input() II! II!




with open(input1, "r") as f:
II! II! II! II!




data = [row for row in csv.reader(f)]
II! II! II! II! II! II!




for row in data:
II! II! II!




even = [row[i].strip() for i in range(0, len(row), 2)]
II! II! II! II! II! II! II! II!




odd = [row[i].strip() for i in range(1, len(row), 2)]
II! II! II! II! II! II! II! II!




pair = dict(zip(even, odd))
II! II! II!




print(pair)

Create a solution that accepts an integer input representing the index value for any any of the five
II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II!




elements in the following list:
II! II! II! II! II!




various_data_types = [516, 112.49, True, "meow", ("Western", "Governors", "University"), {"apple": 1, II! II! II! II! II! II! II! II! II! II!




"pear": 5}]
II! II!




Using the built-in function type() and getting its name by using the .name attribute, output data type (e.g.,
II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II!




int”, “float”, “bool”, “str”) based on the input index value of the list element.
II! II! II! II! II! II! II! II! II! II! II! II! II! II!




index_value = int(input()) II! II!




name = various_data_types[index_value]
II! II!




data_type = type(name).__name__ II! II!




print(f"Element {index_value}: {data_type}") II! II!




Create a solution that accepts an integer input. Import the built-in module math and use its factorial()
II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II!




method to calculate the factorial of the integer input. Output the value of the factorial, as well as a
II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II! II!




Boolean value identifying whether the factorial output is greater than 100.
II! II! II! II! II! II! II! II! II! II! II!

Get to know the seller

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.
STUVEX NURSING
Follow You need to be logged in order to follow users or courses
Sold
723
Member since
2 year
Number of followers
313
Documents
15137
Last sold
4 days ago
STUVATE - STUVIA USA

Our store is a comprehensive destination for buying and selling a variety of documents. we offer a vast range of documents that cater to different needs and requirements, our documents are well-researched, accurate, and of high quality, ensuring customer satisfaction. whether you are looking for legal documents, academic papers, business reports or miscellaneous documents we`ve got you covered.

3.8

110 reviews

5
42
4
29
3
23
2
7
1
9

Recently viewed by you

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

Frequently asked questions