WGU D335 Practice Test 2
Question and answers verified to
pass 2026
1. Create a solution that accepts three times_traveledA =
integer inputs representing the int(input()) times_traveledB
= int(input())
number of times an employee
times_traveledC =
travels to a job site. Output the
int(input())
total distance traveled to two decimal places employeeA =
15.62 #miles given the following miles per employee com-
employeeB = 41.85 #miles mute to the job site. Output the
total distance employeeC = 32.67 #miles
traveled to two decimal places given the distance_traveledA =
fol-lowing miles per employee times_traveledA * employeeA
commute to the job site: distance_traveledB =
Employee A: 15.62 times_traveledB * employeeB
miles Employee B: distance_traveledC =
41.85 miles Employee times_traveledC * employeeC
C: 32.67 miles total_miles_traveled =
distance_travele-dA +
distance_traveledB + distance_trav-
eledC
print('Distance: {:.2f}
miles'.format(to-
tal_miles_traveled))
2. Create a solution that accepts an input
iden-tifying the name of a text file, for file_name = input()
example, "WordTextFile1.txt". Each with open(file_name, 'r') as f:
text file contains word1 = str(f.readline()).strip()
three rows with one word per row. Using the word2 = str(f.readline()).strip()
open() function and write() and read() word3 = str(f.readline()).strip()
meth-ods, interact with the input text
file to write a new sentence string f = open(file_name, 'r')
composed of the three
1/
13
, existing words to the end of the file contents lines = f.read().splitlines()
on a new line. Output the new file lines = ' '.join(lines)
contents. f.close()
print(f'{word1}\n{word2}\n{word3}\
n{lines
3. Create a solution that accepts an ounces_per_pound = 16
integer input representing any pounds_per_ton = 2000
number of ounces.
2/
13
Question and answers verified to
pass 2026
1. Create a solution that accepts three times_traveledA =
integer inputs representing the int(input()) times_traveledB
= int(input())
number of times an employee
times_traveledC =
travels to a job site. Output the
int(input())
total distance traveled to two decimal places employeeA =
15.62 #miles given the following miles per employee com-
employeeB = 41.85 #miles mute to the job site. Output the
total distance employeeC = 32.67 #miles
traveled to two decimal places given the distance_traveledA =
fol-lowing miles per employee times_traveledA * employeeA
commute to the job site: distance_traveledB =
Employee A: 15.62 times_traveledB * employeeB
miles Employee B: distance_traveledC =
41.85 miles Employee times_traveledC * employeeC
C: 32.67 miles total_miles_traveled =
distance_travele-dA +
distance_traveledB + distance_trav-
eledC
print('Distance: {:.2f}
miles'.format(to-
tal_miles_traveled))
2. Create a solution that accepts an input
iden-tifying the name of a text file, for file_name = input()
example, "WordTextFile1.txt". Each with open(file_name, 'r') as f:
text file contains word1 = str(f.readline()).strip()
three rows with one word per row. Using the word2 = str(f.readline()).strip()
open() function and write() and read() word3 = str(f.readline()).strip()
meth-ods, interact with the input text
file to write a new sentence string f = open(file_name, 'r')
composed of the three
1/
13
, existing words to the end of the file contents lines = f.read().splitlines()
on a new line. Output the new file lines = ' '.join(lines)
contents. f.close()
print(f'{word1}\n{word2}\n{word3}\
n{lines
3. Create a solution that accepts an ounces_per_pound = 16
integer input representing any pounds_per_ton = 2000
number of ounces.
2/
13