Personal computing discussed

Moderators: SecretSquirrel, just brew it!

AMD Damo
Gerbil Jedi
Topic Author
Posts: 1663
Joined: Wed Jun 07, 2006 3:35 am
Location: Australia, the backwater of all things Technology!

### Python problem

I'm having a bit of trouble with python at the moment, I need to create an if statement but i'm not sure on how to go about it, example, if something equals 30, than the price is \$90, but after that 30 minutes, every 15 minutes after is another \$50 on top of that \$90?

How would i go about doing that?

FireGryphon
Darth Gerbil
Posts: 7509
Joined: Sat Apr 24, 2004 7:53 pm
Location: the abyss into which you gaze

### Re: Python problem

Not sure of the Python syntax, but in the loop I'd check the system clock to see if the proper amount of time is passed, and set the other variables appropriately.
Sheep Rustlers in the sky! <S> Slapt | <S> FUI | Air Warrior II/III

AMD Damo
Gerbil Jedi
Topic Author
Posts: 1663
Joined: Wed Jun 07, 2006 3:35 am
Location: Australia, the backwater of all things Technology!

### Re: Python problem

FireGryphon wrote:
Not sure of the Python syntax, but in the loop I'd check the system clock to see if the proper amount of time is passed, and set the other variables appropriately.

Hmm, I mean as in you put 30 into a variable, it will equal \$90 in the total price variable, but if that goes up to 45, it will be +\$50 on top of the original \$90 and so on so forth.

cheesyking
Minister of Gerbil Affairs
Posts: 2653
Joined: Sun Jan 25, 2004 7:52 am
Location: That London (or so I'm told)
Contact:

### Re: Python problem

Something like this?

``time=1while time > 0:        time = int(raw_input("Please enter a time: "))        total=90.0        if time > 30:                for x in xrange(30,time,15):                        total+=50        print total``

That for loop is a bit lame... should be something more like total+=((time-30)/15)*50 but that would only take into account whole 15 minute blocks.
Fernando!

AMD Damo
Gerbil Jedi
Topic Author
Posts: 1663
Joined: Wed Jun 07, 2006 3:35 am
Location: Australia, the backwater of all things Technology!

### Re: Python problem

Got it working with my own maths thing I came up with, thanks for the help

### Who is online

Users browsing this forum: No registered users and 1 guest