Support Forums

Full Version: I Need Help with Python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Does anyone here know python? I need help with it real fast. Please reply here or PM me thanks!
Yes I know python somewhat. How advanced is the help you need? Either way I will give it a shot, what do you need help with?
Just post the code in here so more people can take a look...
I probably can help you, same as uber1337.
I need help making the following program

salted water does not freeze at 0 celcius, instead it requires a lower temp (pretend it's -10 celcius) ask if the water is salted or not, and ask for the temperature. print if the water will freeze or not.

I need it by tonight.

Please make it as simple as possible, thanks.
This is as simple as it can get...

Code:
#!usr/bin/env python

temp = raw_input("What's the Temperature? ")
water = raw_input("Is the Water salted? ")

if water == "yes" :
    if int(temp) <= -10:
        print "Water freezes"
    else:
        print "No, It's not cold enough!"
There is no value if I type "no" instead of "yes"
(02-04-2010, 06:35 PM)Kharnage Wrote: [ -> ]I need help making the following program

salted water does not freeze at 0 celcius, instead it requires a lower temp (pretend it's -10 celcius) ask if the water is salted or not, and ask for the temperature. print if the water will freeze or not.

I need it by tonight.

Please make it as simple as possible, thanks.

I trust that this is homework? I can make it but it would be better if I knew whether you just want your homework if you you are interested in the language. Anyway here it is:

Code:
x = raw_input('Is the water salted?')  
y = int(raw_input('What temperature is the water at?'))

if x=='yes' and y <= -10:
    print 'This water will freeze'
    raw_input()
elif x=='no' and y <= 0:
    print 'This water will freeze'
    raw_input()
else:
    print 'This water will not freeze'

This will declare variables that ask the user if it is salted or not and the temperature. If the water is salted and the temperature is less than or equal to -10, it will print 'This water will freeze'. If the water is not salted and the temperature is less than or equal to 0, it will print 'This water will freeze'. Any other input given it will print 'This water will not freeze'
Hope this helped! Blackhat
(02-04-2010, 06:53 PM)Kharnage Wrote: [ -> ]There is no value if I type "no" instead of "yes"


Well thought you can do it alone Tongue
edit: but go with uber1337's code, I think it's more what you're looking for
Code:
#!usr/bin/env python

temp = raw_input("What's the Temperature? ")
water = raw_input("Is the Water salted? ")

if water == "yes" :
    if int(temp) <= -10:
        print "Water freezes"
    else:
        print "No, It's not cold enough!"
elif water == "no":
    print "Do the magic here!"
(02-04-2010, 06:56 PM)Master of The Universe Wrote: [ -> ]Well thought you can do it alone Tongue
edit: but go with uber1337's code, I think it's more what you're looking for
Code:
#!usr/bin/env python

temp = raw_input("What's the Temperature? ")
water = raw_input("Is the Water salted? ")

if water == "yes" :
    if int(temp) <= -10:
        print "Water freezes"
    else:
        print "No, It's not cold enough!"
elif water == "no":
    print "Do the magic here!"
Lol I don't think he knows about Python, otherwise he would code such an easy program by himself, and I doubt he has any interest in learning it, due to his urgent need to get this program by tonight.
I don't have interest in learning python, I just want to pass the class to get the credit.
Pages: 1 2