I was looking for a simple code like this.
Code:
x=input ("is your water salted or pure?")
y=input ("what is the temperature?")
if x=="salted" and y>= -10:
print "the water will not freeze"
elif x=="salted" and y< -10:
print "the water will freeze"
elif x=="pure" and y>= 0:
print "the water will not freeze"
elif x== "pure" and y< 0:
print "the water will freeze"
here's one I made
Code:
x=input("Is the water salted?<yes/no>")
y=input("What is the temperature?")
if x=="no" and y>=0:
print "the water will freeze"
elif x=="yes" and y>10:
print "the water will freeze"
else:
print "the water will not freeze"
(02-05-2010, 02:14 PM)Kharnage Wrote: [ -> ]I was looking for a simple code like this.
Code:
x=input ("is your water salted or pure?")
y=input ("what is the temperature?")
if x=="salted" and y>= -10:
print "the water will not freeze"
elif x=="salted" and y< -10:
print "the water will freeze"
elif x=="pure" and y>= 0:
print "the water will not freeze"
elif x== "pure" and y< 0:
print "the water will freeze"
here's one I made
Code:
x=input("Is the water salted?<yes/no>")
y=input("What is the temperature?")
if x=="no" and y>=0:
print "the water will freeze"
elif x=="yes" and y>10:
print "the water will freeze"
else:
print "the water will not freeze"
That is the exact program I made for you with the if/elif's switched around. so you took a python class but have no interest or knowledge of/in python? I just don't undestand people anymore.
First off, it's your opinion whether or not it is "easy". I take Python at school for credits, not for enjoyment. If I cut or am absent for a class I miss part of the Python "training". I don't read tutorials online where I can just re-read it until I understand it. It's either you're at class or you won't understand it. I had trouble making the program because I wasn't at class and I didn't learn about the "==" "if" "elif" "else" etc.
(02-05-2010, 04:51 PM)Kharnage Wrote: [ -> ]First off, it's your opinion whether or not it is "easy". I take Python at school for credits, not for enjoyment. If I cut or am absent for a class I miss part of the Python "training". I don't read tutorials online where I can just re-read it until I understand it. It's either you're at class or you won't understand it. I had trouble making the program because I wasn't at class and I didn't learn about the "==" "if" "elif" "else" etc.
I see, I just figured someone taking a python class (presumably in college) would be a lot more advanced than me. Sorry for getting cocky, but this really should have gone in the Home Work help section, because when you post it in the Python section I'm going to assume you want to learn more about Python.
I'm in Highschool
Wow never heard of a Python class in highschool, wish they had that in mine. Where do you live?(not a stalker you could just tell me the country/state etc.) Your taking it for high school credits or are you a senior taking it for college credits?
I live in New York and it's for highschool credits.
This is how I would have coded it.
Code:
#setting input variables
x=raw_input('Is the water salted?<yes/no>\n>>> ')
y=raw_input('What is the temperature?\n>>> ')
#processing variables
if (x is 'no' and y >= 0):
print('>>> the water will freeze')
elif (x is 'yes' and y > 10):
print('>>> the water will freeze')
else:
print('>>> the water will not freeze')
(02-05-2010, 10:30 PM)Аноним Интерфейс Wrote: [ -> ]This is how I would have coded it.
Code:
#setting input variables
x=raw_input('Is the water salted?<yes/no>\n>>> ')
y=raw_input('What is the temperature?\n>>> ')
#processing variables
if (x is 'no' and y >= 0):
print('>>> the water will freeze')
elif (x is 'yes' and y > 10):
print('>>> the water will freeze')
else:
print('>>> the water will not freeze')
Eh, either one of our codes work, I personally don't care for the ">>>"'s and the parentheses and comments aren't really necessary but whatever floats your boat I guess.
(02-05-2010, 09:04 PM)Kharnage Wrote: [ -> ]I live in New York and it's for highschool credits.
Me too! you live in the city or what? I really don't want to say where I live on the Internet but it's in one of the 5 boroughs
I live in one of the five boroughs too.