Question

In: Computer Science

in python You're always in a hurry and worried about missing your classes. However, you are...

in python
You're always in a hurry and worried about missing your classes. However, you are afraid to get speed tickets in case you exceed the speed limit on the road if you leave late from home or work.
Therefore, you need to drive at the maximum speed allowed and make sure to reach your class on time.
For this purpose, you need to write a program that will read from the user the maximum speed
limit (assume it is the same across all roads) and the distance to be traveled (in KM) and then
print the time (in hours and minutes) at which they will have to leave home or work. You may
also assume that you'll maintain a constant speed till you arrive.
You may use any built-in function that can help you with that.
Example:
If the maximum speed limit is 80 km/hr and you're 20 km far from the university and your class starts at 2:00 pm then you need to leave your work or home at maximum at 01:45 pm since it takes you 15 minutes to arrive.

Solutions

Expert Solution

thanks for the question, here is the python program.

==================================================================

def main():
    # assuming the class starts at 2:00 pm every day
    # tracking the time in military hours and mins
   
class_hrs = 14
    class_mins = 0

    max_speed_limit = int(input('Enter maximum speed limit (km/hr): '))
    distance = int(input('Enter how far is your university (km): '))

    minutes_needed = (distance * 60) // max_speed_limit

    time_to_leave = class_hrs * 60 + class_mins - minutes_needed
    hours = time_to_leave // 60
    mins = time_to_leave % 60

    if hours>=12:
        print('You must leave at max by {:02d}:{:02d} p.m'.format(hours-12,mins))
    else:
        print('You must leave at max by {:02d}:{:02d} a.m'.format(hours,mins))
main()

=================================================================


Related Solutions

If you’re like some college students, you are always worried about having enough money. Suppose that...
If you’re like some college students, you are always worried about having enough money. Suppose that you decide to become an Uber driver, and you offer rides to students on weekends. For a fee, you will drive them to parties and pick them up at the end of the night. Your marginal cost per ride is $10. To keep things simple, assume you are the only person in your town providing this service; that is, you’re a monopolist. On any...
In a survey of 1007 adults, a poll? asked, "Are you worried or not worried about...
In a survey of 1007 adults, a poll? asked, "Are you worried or not worried about having enough money for? retirement?" Of the 1007 surveyed, 552 stated that they were worried about having enough money for retirement. Construct a 99?% confidence interval for the proportion of adults who are worried about having enough money for retirement. A 99?% confidence interval for the proportion of adults who are worried about having enough money for retirement is ?(___,___?).
In a survey of 1066 ​adults, a poll​ asked, "Are you worried or not worried about...
In a survey of 1066 ​adults, a poll​ asked, "Are you worried or not worried about having enough money for​ retirement?" Of the 1066 ​surveyed, 566 stated that they were worried about having enough money for retirement. Construct a 95​% confidence interval for the proportion of adults who are worried about having enough money for retirement.
Your friend is worried about an impending surgical procedure and tells you he's thinking about taking...
Your friend is worried about an impending surgical procedure and tells you he's thinking about taking a few extra pills of his prescription Valium before the surgery. What, if anything, do you say about it?
Explain the nursing implications of ascites. What would you be worried about with your patient in...
Explain the nursing implications of ascites. What would you be worried about with your patient in the acute presentation? What complications could you anticipate the patient developing? (Hint - remember your ABC's of prioritization)
This task is about classes and objects, and is solved in Python 3. We will look...
This task is about classes and objects, and is solved in Python 3. We will look at two different ways to represent a succession of monarchs, e.g. the series of Norwegian kings from Haakon VII to Harald V, and print it out like this: King Haakon VII of Norway, accession: 1905 King Olav V of Norway, accession: 1957 King Harald V of Norway, accession: 1991 >>> Make a class Monarch with three attributes: the name of the monarch, the nation...
1. Your patient has received 50ml of D10W with his medication. You are worried about the...
1. Your patient has received 50ml of D10W with his medication. You are worried about the patients high glucose level and want to calculate how much dextrose in grams he has received 2.The order is for 150ml of 0.45% NS. How many grams of sodium will the patient receive? ROOUND TO THE NEAREST 10TH.   3.Your patient is getting 250ml per hour of D51/2NS How many grams of dextrose will he get in 4 hours?
Someone says that face-to-face classes always do better than online classes, you disagree and think they...
Someone says that face-to-face classes always do better than online classes, you disagree and think they are the same. You gather data and below is some fictitious data. Group 1 percentage Group 2 percentage Median 0.610 Median 0.74553571 Mean 0.646 Mean 0.68526786 St. Deviation 0.225 St. Deviation 0.18357571 n 16 n 18 Hint you'll need to convert the percentages to something else, and ask yourself are they proportion or mean... Provide: Null and Alternative Hypothesis, Test statistic, p-value, (**alpha is...
You = gold producer, worried about the gold prices in the future. In May , you...
You = gold producer, worried about the gold prices in the future. In May , you buy six September gold futures contracts (short position) of 100 ounces each, with an exercise price of $860.00 per ounce. Ignore transaction costs. i)profit/loss be for your entire position, if gold prices turn out to be $900 per ounce at expiration? ii) profit or loss be for your entire position if gold prices turn out to be $820 per ounce at expiration? iii) Based...
You plan to retire in exactly 15 years and are worried about the money you will...
You plan to retire in exactly 15 years and are worried about the money you will have to live on during your retirement. Requirement 1: You currently have $100,000 in a bond account and you plan to add $4,000 per year at the end of each of the next 15 years to the account. If the bond account earns a return of 5 percent per year over the next 15 years, how much will you have in the bond account...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT