Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I Need Help with Python
#11
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 Smile
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"
[Image: 29ol3br.png]
Reply
#12
(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 Smile
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.
[Image: izsyo6.jpg]


Reply
#13
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.
[Image: 29ol3br.png]
Reply
#14
(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.
[Image: izsyo6.jpg]


Reply
#15
I'm in Highschool Tongue
[Image: 29ol3br.png]
Reply
#16
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?
[Image: izsyo6.jpg]


Reply
#17
I live in New York and it's for highschool credits.
[Image: 29ol3br.png]
Reply
#18
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')
Do what thou wilt shall be the whole of the Law. Love is the law, love under will.
.::The Rights of Man::.
Reply
#19
(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 Smile
[Image: izsyo6.jpg]


Reply
#20
I live in one of the five boroughs too.
[Image: 29ol3br.png]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Help Dεlluzion 3 1,758 09-30-2019, 12:59 AM
Last Post: samsmith001
  Simple Python Python Compiler Canoris 21 8,349 06-01-2011, 06:30 PM
Last Post: Filefinder
  Python 2 vs 3? Jake 8 2,224 12-11-2010, 04:13 PM
Last Post: Bursihido
  Python help Kharnage 2 748 02-12-2010, 09:07 PM
Last Post: Kharnage
  "==" and "is" in Python Canoris 1 740 02-07-2010, 03:55 PM
Last Post: uber1337

Forum Jump:


Users browsing this thread: 2 Guest(s)