+ 4

Rule : Do not use (if else), Problem at Description (cause it long). Thank sir for your answer! (Full version)

#Problem ##Do not use (if else) Problem : ------------------------------------ 20 minutes free parking 1 hour 10 baht 2 hours later, the price is 20 baht/hour. 3 hours or more, 40 baht/hour Fractions of minutes rounded up to hours. (allowed to use "math.floor" and "math.ceil") ------------------------------------ discussion : How did you benefit from this question? : Your knowledge of this language will not rust! unsolvable problem become solvable + IQ to Solve problems (Not using a teacher, just a mind.) ------------------------------------ Click ^ at the Answer If you agree with that comment! Click like This Question If you think can fix problem ------------------------------------

24th Nov 2021, 9:34 AM
Akkarawut 5105
Akkarawut 5105 - avatar
13 Answers
+ 5
Akkarawut 5105 The problem you have in your code is completely different to your original question. However solution below using tuples and slicing via a boolean return of comparison operators #Problem #Do not use (if else) #Write a program to calculate parking fees ''' 20 minutes free parking 1 hour 10 baht 2 hours later, the price is 20 baht/hour. 3 hours or more, 40 baht/hour Fractions of minutes rounded up to hours. (allowed to use "math.floor" and "math.ceil") translated by Akkarawut 5105 ''' import math time = int(input()) # in minutes hrs = math.ceil(time/60) rate = (hrs,4)[hrs >2] fee = 0 for i in range(1,hrs+1): fee += (0,rate *10)[time > 20] print(("free",f'${fee}')[fee !=0])
25th Nov 2021, 1:23 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 7
You have any source or something to show the full question?
24th Nov 2021, 10:26 AM
Simba
Simba - avatar
+ 6
What you have tried so far?
24th Nov 2021, 9:41 AM
Simba
Simba - avatar
+ 3
Mine yours doesn't understand.
24th Nov 2021, 9:47 AM
Shadoff
Shadoff - avatar
+ 3
I don't know where the respond button is. If yes I will press ↑ but not ↓
24th Nov 2021, 9:50 AM
Akkarawut 5105
Akkarawut 5105 - avatar
+ 3
Akkarawut 5105 Are you sure it is not 0.25$ for 15 minutes. Also is 7 minutes considered to be 15 minutes. Is 16 minutes considered to be 30 minutes. There is lots of missing info
24th Nov 2021, 10:02 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
Akkarawut 5105 Ok!, thanks What would be the cost for 67 minutes? I am still trying to get my head around the concept
24th Nov 2021, 10:14 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Rik Wittkopp : I'm sure not 0.25 cause 0.2 my land is 7฿
24th Nov 2021, 10:12 AM
Akkarawut 5105
Akkarawut 5105 - avatar
+ 2
Your question is not that clear reframe it well please
26th Nov 2021, 9:07 AM
Osei Michael
Osei Michael - avatar
+ 1
Rik Wittkopp : Just try to fix it! If you done send to me plz Okie?
24th Nov 2021, 10:21 AM
Akkarawut 5105
Akkarawut 5105 - avatar
+ 1
Simba : It's thai language Here's a link that sums it all up! Translated! https://code.sololearn.com/cM98SyXF3TTa/?ref=app
24th Nov 2021, 11:23 AM
Akkarawut 5105
Akkarawut 5105 - avatar
+ 1
- take time as input. - set sum = 0 - set time to time - 20 minutes (because the first 20 minutes are free) - set time to time - 1 hour and add price for first hour to sum - set time to time - x hours and add price for x hours to sum - and so on until time is <= 0
24th Nov 2021, 6:56 PM
Simon Sauter
Simon Sauter - avatar
0
Simon Sauter : Thanks i gonna try it out!
25th Nov 2021, 1:08 AM
Akkarawut 5105
Akkarawut 5105 - avatar