e a solution that accepts three integer inputs representing the number of times an employee travels to a job site. Output the total distance traveled to two decimal places given the following miles per employee commute to the job site. Output the total distance traveled to two decimal places given ...
1.create a solution that accepts three integer inputs representing the
number of times an employee travels to a job site. Output the total
distance traveled to two decimal places given the following miles per
employee commute to the job site. Output the total distance traveled to
two decimal places given the following miles per employee commute to
the job site:
employee a: 15.62 miles
employee b: 41.85 miles
employee c: 32.67 miles
Times_traveled a = int(input())
times_traveled b = int(input())
times_traveled c = int(input())
employee a = 15.62 #miles
employee b = 41.85 #miles
employee c = 32.67 #miles
distance_traveled a = times_traveled a * employee a
distance_traveled b = times_traveled b * employee b
distance_traveled c = times_traveled c * employee c
total_miles_traveled = distance_traveleda + distance_traveledb +
distance_traveledc
print('distance: {:.2f} miles'.format(total_miles_traveled))
2.create a solution that accepts an input identifying the name of a text
file, for example, "wordtextfile1.txt". Each text file contains three rows
with one word per row. Using the open() function
and write() and read() methods, interact with the input text file to write a
, new sentence string composed of the three existing words to the end of
the file contents on a new line. Output the new file contents.
File_name = input()
with open(file_name, 'r') as f:
word1 = str(f.readline()).strip()
word2 = str(f.readline()).strip()
word3 = str(f.readline()).strip()
f = open(file_name, 'r')
lines = f.read().splitlines()
lines = ' '.join(lines)
f.close()
print(f'{word1}\n{word2}\n{word3}\n{lines}')
Brainpower
Read more
3.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.
Ounces_per_pound = 16
pounds_per_ton = 2000
number_ounces = int(input())
tons = number_ounces // (ounces_per_pound * pounds_per_ton)
remaining_ounces = number_ounces % (ounces_per_pound *
pounds_per_ton)
pounds = remaining_ounces // ounces_per_pound
remaining_ounces = remaining_ounces % ounces_per_pound
print('tons: {}'.format(tons))
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller EXAMLINKS. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $16.49. You're not tied to anything after your purchase.