WGU D335 INTRO TO PYTHON (OA)
PRACTICE QUESTIONS AND ANSWERS
WITH COMPLETE SOLUTIONS 100%
CORRECT RATED A+ ||NEWLY
UPDATED 2026
Program Logic: Multi-Employee Distance Calculator ✔✔ A script designed to
collect travel counts for three specific employees, calculate their individual
mileage based on fixed commute distances, and output the grand total formatted to
two decimal places.
Python Solution ✔✔
Python
# Fixed commute distances for each staff member
commute_distances = {
'Employee A': 15.62,
'Employee B': 41.85,
'Employee C': 32.67
}
# Collecting the number of trips via user input
trip_counts = {
'Employee A': int(input("Trips for A: ")),
'Employee B': int(input("Trips for B: ")),
'Employee C': int(input("Trips for C: "))
}
, # Calculating total miles by multiplying trips by distance
total_miles = sum(commute_distances[emp] * trip_counts[emp] for emp in
trip_counts)
# Displaying the final result with precision formatting
print(f'Distance: {total_miles:.2f} miles')
Create a Python solution to the following task. Ensure that the solution produces
output in exactly the same format shown in the sample(s) below, including
capitalization and whitespace.
Task:
Create a solution that accepts an integer input representing any number of ounces.
Output the converted total number of tons, pounds, and remaining ounces based on
the input ounces value. There are 16 ounces in a pound and 2,000 pounds in a ton.
The solution output should be in the format
Tons: value_1 Pounds: value_2 Ounces: value_3 -ANSWER ✔✔opp = 16
top = 2000
ounces = int(input())
tons = ounces // (opp * top)
ro = ounces % (opp * top)
pounds = ro // opp
ro %= opp
print(f'Tons: {tons}')
print(f'Pounds: {pounds}')
print(f'Ounces: {ro}')
PRACTICE QUESTIONS AND ANSWERS
WITH COMPLETE SOLUTIONS 100%
CORRECT RATED A+ ||NEWLY
UPDATED 2026
Program Logic: Multi-Employee Distance Calculator ✔✔ A script designed to
collect travel counts for three specific employees, calculate their individual
mileage based on fixed commute distances, and output the grand total formatted to
two decimal places.
Python Solution ✔✔
Python
# Fixed commute distances for each staff member
commute_distances = {
'Employee A': 15.62,
'Employee B': 41.85,
'Employee C': 32.67
}
# Collecting the number of trips via user input
trip_counts = {
'Employee A': int(input("Trips for A: ")),
'Employee B': int(input("Trips for B: ")),
'Employee C': int(input("Trips for C: "))
}
, # Calculating total miles by multiplying trips by distance
total_miles = sum(commute_distances[emp] * trip_counts[emp] for emp in
trip_counts)
# Displaying the final result with precision formatting
print(f'Distance: {total_miles:.2f} miles')
Create a Python solution to the following task. Ensure that the solution produces
output in exactly the same format shown in the sample(s) below, including
capitalization and whitespace.
Task:
Create a solution that accepts an integer input representing any number of ounces.
Output the converted total number of tons, pounds, and remaining ounces based on
the input ounces value. There are 16 ounces in a pound and 2,000 pounds in a ton.
The solution output should be in the format
Tons: value_1 Pounds: value_2 Ounces: value_3 -ANSWER ✔✔opp = 16
top = 2000
ounces = int(input())
tons = ounces // (opp * top)
ro = ounces % (opp * top)
pounds = ro // opp
ro %= opp
print(f'Tons: {tons}')
print(f'Pounds: {pounds}')
print(f'Ounces: {ro}')