1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Cerrena [4.2K]
2 years ago
13

Write a function called mul_time that takes a Time_Elapsed object and a number and returns a new Time_Elapsed object that contai

ns the product of the original object and the number. Then use mul_time to write a function that takes a Time_Elapsed object that represents the finishing time in a race, and a number that represents the distance, and returns a Time object that represents the pace (time per mile). The function should return a nicely formatted pace in hour, minutes and second per mile
Computers and Technology
1 answer:
lisov135 [29]2 years ago
7 0

# Write a function called mul_time that takes a Time object and a number and

# returns a new Time object that contains the product of the original Time and

# the number.

# Then use mul_time to write a function that takes a Time object that

# represents the finishing time in a race, and a number that represents the

# distance, and returns a Time object that represents the average pace (time

# per mile).

# Current Status: Complete

class Time(object):

   """ represents the time of day.

   attributes: hour, minute, second"""

time = Time()

time.hour = 3

time.minute = 0

time.second = 0

def time_to_int(time):

   minutes = time.hour * 60 + time.minute

   seconds = minutes * 60 + time.second

   return seconds

def int_to_time(seconds):

   new_time = Time()

   minutes, new_time.second = divmod(seconds, 60)

   time.hour, time.minute = divmod(minutes, 60)

   return time

def mul_time(time, multicand):

   time_int = time_to_int(time) * multicand

   new_time = int_to_time(time_int)

   if new_time.hour > 12:

       new_time.hour = new_time.hour % 12

#    print ("New time is: %.2d:%.2d:%.2d"

#    % (new_time.hour, new_time.minute, new_time.second))

   return new_time

# mul_time(time, 2)

def race_stats(time, distance):

   print ("The finish time was %.2d:%.2d:%.2d"

         % (time.hour, time.minute, time.second))

   print "The distance was %d miles" % (distance)

   average = mul_time(time, (1.0 / distance))

   print ("The average is: %.2d:%.2d:%.2d per mile"

         % (average.hour, average.minute, average.second))

race_stats(time, 3)

You might be interested in
What is output? <br> Print (12 % 5)<br><br> Answer <br> 0<br> 5<br> 2<br> 1
pickupchik [31]

Answer:

5

Explanation:

7 0
3 years ago
Read 2 more answers
All of the following are characteristics of a 4 year college except
klasskru [66]
D they offer few programs
4 0
3 years ago
Read 2 more answers
Which tab is used to insert a hyperlink onto a slide?
babunello [35]

the answer is C. Insert

3 0
3 years ago
What time is it in Ohio?
skad [1K]
Geographically, the state of Ohio falls within the lines of latitude of 75 °W and 90 °W. The timezone corresponding to this portion of the globe is eastern standard time (EST). The prime meridian at 0 °, has the timezone greenwich mean time (GMT) from which all other timezones are referenced. And eastern standard time, local time in Ohio, will be 5 hours behind GMT.
5 0
3 years ago
Read 2 more answers
1. What does the term 'in season' mean?
yKpoI14uk [10]
Available at the time of year.
8 0
3 years ago
Read 2 more answers
Other questions:
  • Write a method that checks whether the input string or a sentence (a string with spaces) is a palindrome or not. The method shou
    13·1 answer
  • WILL GIVE BRANLYIST
    6·1 answer
  • How much electricity is in the human brain? ​
    8·2 answers
  • What should a password policy contain to reduce a hackers ability to crack the passwords?
    10·1 answer
  • Microsoft words spell checker
    9·1 answer
  • True / False<br> An instruction’s opcode generally indicates the number and type of its operands.
    5·1 answer
  • Can change the tab colors of the worksheets in excel
    13·1 answer
  • Who addicted to fnaf
    5·2 answers
  • In what ways is the human brain like a computer? In what ways is it different?
    14·2 answers
  • What command will prevent all unencrypted passwords from displaying in plain text in a configuration file?.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!