Question

python 3 beginner

In Boilerville, a bicycle can be rented between 8:00 am unti 9.0 0 are prot hour from 8:00 am until 3:30 pm. From 3:30 pm until 9:00o Partial ho bike, and they do not rent bikes before 8:00 am or Define a function named q50 that prm. The charge for each bike is $1 75p pm the rate is $2.50 an hour. These rates are per after 9:00 pm. Partial hours accepts the number of bicycles (an integer), a starting time ending time prorated String) and calculat (string) and r format, meaning that the string 08:00 would indicate 8 am and the tes the total rental fee. Assume that the starting and ending Some example calculations: string 16:30 would be 4:30 pm cattring 08:00 would nsisume that the starting and ending times are in # Bikes Start Time End Time Total Rent 1 3 2 16.0 08:30 11:15 09:00 17:00 18:30 20:10 44.82 46.08 NOTE: the g50 function should return the total rate as a Float value with 2 decimal places; it should no print it. Question 6(MTyB ne resulting values until you have a one-digit result. For example, the integer 1863 can be verfied as a to determine if an integer is a multiple of 9 is to sum the individual digits, then continue to sum even multiple of 9 One method that the starting value was an nultiple of 9 by adding the digits (1 +8+6+3 18), then adding the digits of the resulting value (1+89

top question please

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please give the thumbs up, if it is helpful for you!!. Let me know if you have any doubts.

# -*- coding: utf-8 -*-
"""
Created on Thu Mar 29 09:07:50 2018

@author:
"""
import datetime as dt

def q5(bikes,time1,time2):
time_format = '%H:%M'
start_time=dt.datetime.strptime(time1,time_format)
end_time=dt.datetime.strptime(time2,time_format)
total_rent=0
t1=dt.datetime.strptime('08:30',time_format)
t2=dt.datetime.strptime('15:30',time_format)
t3=dt.datetime.strptime('21:00',time_format)
if start_time >= t1 and end_time <= t2:
diff=end_time-start_time
hours = int(diff.seconds // (60 * 60))
mins = int((diff.seconds // 60) % 60)
total_rent=hours*1.75 + (mins/60)*1.75

elif start_time >= t1 and end_time<= t3:
if start_time <= t2 and end_time >= t2:
diff1=t2-start_time
hours1 = int(diff1.seconds // (60 * 60))
mins1 = int((diff1.seconds // 60) % 60)
  
diff2=end_time-t2
hours2 = int(diff2.seconds // (60 * 60))
mins2 = int((diff2.seconds // 60) % 60)
  
total_rent=bikes* (hours1*1.75 + (mins1/60)*1.75 +
hours2*2.50 + (mins2/60)*2.50)
return round(total_rent,2)


print('{} {} {} {}'.format('# Bikes', 'Start Time', 'End Time', 'Total Rent'))
print("======== ========== ======== ==========")
time1='08:30'
time2='17:00'
bikes=1
rent=q5(bikes,time1,time2)
print('{:5} {:^10} {:^10} {:^10}'.format(bikes,time1,time2,rent))

time1='11:15'
time2='18:30'
bikes=3
rent=q5(bikes,time1,time2)
print('{:5} {:^10} {:^10} {:^10}'.format(bikes,time1,time2,rent))

time1='09:00'
time2='20:10'
bikes=2
rent=q5(bikes,time1,time2)
print('{:5} {:^10} {:^10} {:^10}'.format(bikes,time1,time2,rent))

Output:

Add a comment
Know the answer?
Add Answer to:
python 3 beginner top question please In Boilerville, a bicycle can be rented between 8:00 am...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Chapter 2 M&I Begin Date: 9/3/2018 12:01:00 AM-Due Date: 9/11/2018 8:00:00 AM End Date: 9/28/2018 11:59:00...

    Chapter 2 M&I Begin Date: 9/3/2018 12:01:00 AM-Due Date: 9/11/2018 8:00:00 AM End Date: 9/28/2018 11:59:00 PM (9%) Problem 10: A racquetball (mass m-0.040 kg) an achieve speeds of the ball deforms by compressing about a distance of d 1.6 cm about v-66 ms. When hit by a racquet at that speed, & What is the average force exerted by the racquet in N over the time when the ball strikes the racquet to when it is at its maximum...

  • Å am- Requires Respondus LockDown Browser 0:00 Time Left:2:11:04 Saman Ansari: Attempt 1 3 Question 8...

    Å am- Requires Respondus LockDown Browser 0:00 Time Left:2:11:04 Saman Ansari: Attempt 1 3 Question 8 (5 points) Question (D): The following model test the effect of Credit Score and Student status on lurance Premium (response variable) Lemurance Premium is in 5 and Credit Score is in number of units (increasing implies better credit worthiness and lower default risk). Student is a dummy variable, which is equal to 1 if a person is student and oir the person is non-...

  • question 3 please under problems the cat measured along the ground. Also, determine the total flight...

    question 3 please under problems the cat measured along the ground. Also, determine the total flight time of the cat from launch to impact. Finally, determine the impact velocity of the cat with the ground. Newton's Laws: Questions: 1. If an automobile moving along a road at constant velocity experiences a force of 400 N in the forward direction, how much frictional force opposes the car's motion? Explain briefly. Problems: 1. (00) A 52 g bullet is fired horizontally from...

  • I need help with this assignment in C++, please! *** The instructions and programming style detai...

    I need help with this assignment in C++, please! *** The instructions and programming style details are crucial for this assignment! Goal: Your assignment is to write a C+ program to read in a list of phone call records from a file, and output them in a more user-friendly format to the standard output (cout). In so doing, you will practice using the ifstream class, I'O manipulators, and the string class. File format: Here is an example of a file...

  • In Problem Set 7 you designed and implemented a Message class. This time, let's design and...

    In Problem Set 7 you designed and implemented a Message class. This time, let's design and implement a Mailbox class in a file named Mailbox java. Do the following with this class • You may use the Message class from PS 7. You will have to add new features to the Message class from PS 7 as you work through this problem. You are welcome to start with my sample solution if you wish • Suppose there are multiple mail...

  • Using Merge Sort: (In Java) (Please screenshot or copy your output file in the answer) In...

    Using Merge Sort: (In Java) (Please screenshot or copy your output file in the answer) In this project, we combine the concepts of Recursion and Merge Sorting. Please note that the focus of this project is on Merging and don't forget the following constraint: Programming Steps: 1) Create a class called Art that implements Comparable interface. 2) Read part of the file and use Merge Sort to sort the array of Art and then write them to a file. 3)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT