in Python
1. Employee Travel Distance Calculation
Question:
Create a solution that accepts three integer inputs representing the number of times
employees A, B, and C travel to a job site. Given the miles per employee commute (A:
15.62, B: 41.85, C: 32.67), output the total distance traveled to two decimal places in the
format:
Distance: total_miles_traveled miles
Answer:
python
Copy
Download
travels = {
"A": int(input()),
"B": int(input()),
"C": int(input())
}
miles_per_employee = {"A": 15.62, "B": 41.85, "C": 32.67}
total_miles_traveled = sum(travels[employee] * miles_per_employee[employee] f
or employee in travels)
print(f"Distance: {total_miles_traveled:.2f} miles")
2. Ounces to Tons, Pounds, Ounces Conversion
Question:
Create a solution that accepts an integer input representing any number of ounces.
Convert this to tons, pounds, and remaining ounces (16 oz = 1 lb, 2000 lb = 1 ton).
, Output the result in the format:
Tons: value_1 Pounds: value_2 Ounces: value_3
Answer:
python
Copy
Download
ounces = int(input())
value_1 = ounces // (16 * 2000)
value_2 = (ounces % (16 * 2000)) // 16
value_3 = ounces % 16
print(f"Tons: {value_1}")
print(f"Pounds: {value_2}")
print(f"Ounces: {value_3}")
3. Data Type Identification
Question:
Given a list various_data_types = [516, 112.49, True, "meow", ("Western",
"Governors", "University"), {"apple": 1, "pear": 5}], create a solution that
accepts an integer input representing an index. Output the data type of the element at
that index in the format:
Element index_value: data_type
Answer:
python
Copy
Download
index_value = int(input())
data_type = type(various_data_types[index_value]).__name__
print(f"Element {index_value}: {data_type}")