+ 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 ------------------------------------

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])

+ 7

You have any source or something to show the full question?

+ 6

What you have tried so far?

+ 3

Mine yours doesn't understand.

+ 3

I don't know where the respond button is. If yes I will press ↑ but not ↓

+ 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

+ 3

Akkarawut 5105
Ok!, thanks
What would be the cost for 67 minutes?
I am still trying to get my head around the concept

+ 2

Rik Wittkopp :
I'm sure not 0.25 cause 0.2 my land is 7฿

+ 2

Your question is not that clear reframe it well please

+ 1

Rik Wittkopp :
Just try to fix it!
If you done send to me plz
Okie?

+ 1

Simba :
It's thai language
Here's a link that sums it all up! Translated!
https://code.sololearn.com/cM98SyXF3TTa/?ref=app

+ 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

0

Simon Sauter :
Thanks i gonna try it out!