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
Analyze a software application that enables people to purchase prescription drugs on the internet. briefly describe this applica
stiv31 [10]
This question makes no sense
8 0
3 years ago
Write a function that receives a StaticArray where the elements are already in sorted order, and returns a new StaticArray with
Allisa [31]

The code that remove duplicate is as follows:

def remove_duplicate(mylist):

    mylist = list(dict.fromkeys(mylist))

    return mylist

print(remove_duplicate([1, 1, 2, 3, 3, 5, 6, 7]))

<h3>Code explanation</h3>

The code is written in python.

  • we defined a function named "remove_duplicate" and it accept the parameter "mylist".
  • The variable "mylist" is used to store the new value after the duplicate vallues has been removed.
  • Then, wed returned mylist.
  • Finally, we call the function with the print statement . The function takes the required parameter.

learn more on python here: brainly.com/question/21126936

7 0
2 years ago
Given the macro definition and global declarations shown in the image below, provide answers to the following questions:
galben [10]

Answer:

A. 243

B. True

C. 0

Explanation:

Macro instruction is a line of coding used in computer programming. The line coding results in one or more coding in computer program and sets variable for using other statements. Macros allows to reuse code. Macro has two parts beginning and end. After the execution of statement of quiz4 x, 4 the macro x will contain 243. When the macro is invoked the statement will result in an error. When the macro codes are executed the edx will contain 0. Edx serve as a macro assembler.

4 0
3 years ago
You can perform numbers___on binary
Masja [62]

Answer:

c) arithmetic operations

3 0
2 years ago
Read 2 more answers
What refers to the use of technology to create product styles and designs?
torisob [31]
The answer is graphic design
8 0
3 years ago
Other questions:
  • Read the scenario, and then answer the question that follows.
    10·1 answer
  • On computer X, a nonpipelined instruction execution would require 12 ns. A pipelined implementation uses 6 equal-length stages o
    9·1 answer
  • Translate the following MIPS code to C. Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3
    8·1 answer
  • All of this information is part of a ____ in a database.
    13·2 answers
  • An administrator running a port scan wants to ensure that no processes are listening on port 23. What state should the port be i
    7·1 answer
  • Translate each statement into a logical expression. Then negate the expression by adding a negation operation to the beginning o
    15·1 answer
  • You need to design a backup strategy. You need to ensure that all servers are backed up every Friday night and a complete copy o
    6·1 answer
  • Help me find the difference between these logos
    10·2 answers
  • Write a C program to input a character, then check if the input
    5·1 answer
  • Assignment 6: Animation
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!