In: Computer Science
Minutes parked |
Hrs*Fee=parking fee |
25 minutes (0 hour and 25 minutes) |
1*5.00 |
05 minutes (0 hour and 5 minutes) |
1*5.00 |
55 minutes (0 hours and 55 minutes) |
1*5.00 |
30 minutes (0 hour and 30 minutes) |
1*5.00 |
10 minutes (0 hour and 10 minutes) |
1*5.00 |
60 minutes (1 hour and 0 minutes) |
1*5.00 |
Minutes parked |
Hrs*Fee=parking fee |
65 minutes (1 hour and 5 minutes) |
2*4.00 |
95 minutes (1 hour and 35 minutes) |
2*4.00 |
120 minutes (2 hours) |
2*4.00 |
135 minutes (2 hour and 15 minutes) |
3*4.00 |
180 minutes (3 hour and 0 minutes) |
3*4.00 |
195 minutes (3 hour and 15 minutes) |
4*4.00 |
240 minutes (4 hours) |
4*4.00 |
260 minutes (4 hours 20 minutes ) |
5*4.00 |
300 minutes (5 hours) |
5*4.00 |
Minutes parked |
Hrs*Fee = parking fee |
320 minutes (5 hour and 20 minutes) |
6*2.00 |
400 minutes (6 hour and 40 minutes) |
7*2.00 |
800 minutes (13 hour and 20 minutes) |
14*2.00 |
825 minutes (13 hour and 45 minutes) |
14*2.00 |
600 minutes (10 hours) |
10*2.0 |
my work:
rate1=5 rate2=4 rate3=2 fees=0 minutes = int(input("Please Enter the number of minutes parked : ")) print(minutes) if minutes>=0 and minutes<=60: if minutes%60==0: hrs=int(minutes/60) fees=hrs*rate1 print("Parking Fees (in $) is ",fees ) else: hrs=int(minutes/60)+1 fees=hrs*rate1 print("Parking Fees (in $) is ",fees ) elif minutes>60 and minutes<=300: print("It Falls in Table 2") if minutes%60==0: hrs=int(minutes/60) fees=hrs*rate2 print("Parking Fees (in $) is ",fees ) else: hrs=int(minutes/60)+1 fees=hrs*rate2 print("Parking Fees (in $) is ",fees ) elif minutes>300: print("It Falls in Table 3") if minutes%60==0: hrs=int(minutes/60) fees=hrs*rate3 print("Parking Fees (in $) is ",fees ) else: hrs=int(minutes/60)+1 fees=hrs*rate3 print("Parking Fees (in $) is ", fees) else: print("Invalid Minutes")
getting error line 36
else:
^
SyntaxError: invalid syntax please help.
The error in the line 36 is nothing but the indentation error.
You wrote two else statements in the second elif condtition (i.e., elif minutes>300:) but actually it should be act as else statement for the first if condition (i.e., if minutes>=0 and minutes<=60:)
That's why it shown the syntax error.
I changed the code now it works perfectly
proof with output:
corrected code:
rate1=5
rate2=4
rate3=2
fees=0
minutes = int(input("Please Enter the number of minutes parked :
"))
print(minutes)
if minutes>=0 and minutes<=60:
if minutes%60==0:
hrs=int(minutes/60)
fees=hrs*rate1
print("Parking Fees (in
$) is ",fees )
else:
hrs=int(minutes/60)+1
fees=hrs*rate1
print("Parking Fees (in
$) is ",fees )
elif minutes>60 and minutes<=300:
print("It Falls in Table 2")
if minutes%60==0:
hrs=int(minutes/60)
fees=hrs*rate2
print("Parking Fees (in
$) is ",fees )
else:
hrs=int(minutes/60)+1
fees=hrs*rate2
print("Parking Fees (in
$) is ",fees )
elif minutes>300:
print("It Falls in Table 3")
if minutes%60==0:
hrs=int(minutes/60)
fees=hrs*rate3
print("Parking Fees (in
$) is ",fees )
else:
hrs=int(minutes/60)+1
fees=hrs*rate3
print("Parking Fees (in
$) is ", fees)
else:
print("Invalid Minutes")
***Please give a like if you are satisfied with the answer. If you have any doubts or you need any further information ask me through comments. THANK YOU! ***