ANSWERS
1. Create a solution that accepts three integer inputs representing the number of
h; h; h; h; h; h; h; h; h; h; h;
h; times an employee travels to a job site. Output the total distance traveled to
h; h; h; h; h; h; h; h; h; h; h; h; h;
two decimal places given the following miles per employee commute to the job
h; h; h; h; h; h; h; h; h; h; h; h; h;
h; site. Output the total distance traveled to two decimal places given the
h; h; h; h; h; h; h; h; h; h; h;
h; following miles per employee commute to the job site:
h; h; h; h; h; h; h; h;
Employee A: 15.62 miles h; h; h;
h; Employee B: 41.85 miles h; h; h;
Employee C: 32.67 miles: times_traveledA = int(input())
h; h; h; h; h; h;
h; times_traveledB = int(input()) h; h;
times_traveledC = int(input()) h; h;
h; employeeA = 15.62 #miles h; h; h;
h; employeeB = 41.85 #miles h; h; h;
h; employeeC = 32.67 #miles h; h; h;
distance_traveledA = times_traveledA * employeeA h; h; h; h;
h; distance_traveledB = times_traveledB * employeeB h; h; h; h;
h; distance_traveledC = times_traveledC * employeeC h; h; h; h;
1 / h;
12
, total_miles_traveled = distance_traveledA + distance_traveledB + distance_trav- h; h; h; h; h; h;
h; eledC
print('Distance: {:.2f} miles'.format(total_miles_traveled)) h; h;
2. Create a solution that accepts an input identifying the name of a text file,for
h; h; h; h; h; h; h; h; h; h; h; h; h; h;
h; example,"WordTextFile1.txt".Each text file contains three rows with one word
h
; h
; h; h; h; h; h; h; h; h;
h; per row. Using the open() function and write() and read() methods, interact
h; h; h; h; h; h; h; h; h; h; h;
h; with the input text file to write a new sentence string composed of the three
h; h; h; h; h; h; h; h; h; h; h; h; h; h;
h; existing words to the end of the file contents on a new line. Output the new
h; h; h; h; h; h; h; h; h; h; h; h; h; h; h;
h; file contents.: file_name = input()
h; h; h; h;
with open(file_name, 'r') as f:
h; h; h; h;
word1 = str(f.readline()).strip() h; h;
h; word2 = str(f.readline()).strip() h; h;
h; word3 = str(f.readline()).strip()h; h;
f = open(file_name, 'r')
h; h; h;
h; lines= f.read().splitlines()
h; h;
h; lines = ' '.join(lines)h; h; h;
h; f.close()
print(f'{word1}\n{word2}\n{word3}\n{lines}')
3. Create a solution that accepts an integer input representing any number of
h; h; h; h; h; h; h; h; h; h; h;
h; ounces. Output the converted total number of tons, pounds, and remaining
h; h; h; h; h; h; h; h; h; h;
h; ounces based on the input ounces value.There are 16 ounces in a pound and
h; h; h; h; h; h; h
; h; h; h; h; h; h; h;
h; 2,000 pounds in a ton.: ounces_per_pound = 16
h; h; h; h; h; h; h;
2 /
h;
12