Question:
Python Programming help with codes please 10 POINTS?
anonymous
2011-06-20 12:44:15 UTC
What is wrong with my code??
#Intro

print "Welcome!"
print "Press 1 for Celsius to Fahrenheit, or Press 2 for Fahrenheit to Celsius."
z=raw_input("1 or 2: ")
if z=="1":
x = input("Enter Celsius: ")
y = (float(x)*1.8)+32
print "It is ", y, "Fahrenheit."
while 1:
x = input("Enter Celsius: ")
y = (float(x)*1.8)+32
print "It is ", y, "Fahrenheit."
elif z=="2":
b = input("Enter the fahrenheit: ")
c = (float(b)-32)*(5.0/9.0)
print "It is ", c, "celsius."
while 1:
b = input("Enter the fahrenheit: ")
c = (float(b)-32)*(5.0/9.0)
print "It is ", c, "celsius."


And how do I create an option to quit either 1 or 2. I have only 3 days studying and writing codes in python PLEASE help! Revise my code please and correct it plz!! What's wrong with elif!?!!?!?!?!?!?
Three answers:
Nick Thrasher
2011-06-20 20:59:16 UTC
Well I'm not quite sure this is what your looking for, i added a menu to allow you to re-choose or exit.

There is a great site to learn Python, i started here a few days ago myself - http://www.alan-g.me.uk/tutor/index.htm - hope this helps



import sys

print "Welcome!"

print "Pick a conversion."

menu = """

1) Celsius to Fahrenheit

2) Fahrenheit to Celsius

3) Quit

"""

z=int(raw_input(menu))

while z != 3:

if z== 1:

x = input("Enter Celsius: ")

y = (float(x)*1.8)+32

print "It is ", y, "Fahrenheit."

print "Press 1 for Celsius to Fahrenheit, or Press 2 for Fahrenheit to Celsius."

z=int(raw_input(menu))

elif z== 2:

b = input("Enter the fahrenheit: ")

c = (float(b)-32)*(5.0/9.0)

print "It is ", c, "celsius."

print "Press 1 for Celsius to Fahrenheit, or Press 2 for Fahrenheit to Celsius."

z=int(raw_input(menu))
Dj
2011-06-21 10:48:38 UTC
He is right if you want a menu after each one. if you want to keep going on the same conversion for however long you want, but push e to exit, mine is good. it keeps asking you for the c/f until you enter e to exit:

import sys

print "Welcome!"

print "Pick a conversion."

menu = """

1) Celsius to Fahrenheit

2) Fahrenheit to Celsius

3) Quit

"""

z=int(raw_input(menu))

while z != 3:

if z== 1:

x = input("Enter Celsius: ")

y = (float(x)*1.8)+32

print "It is ", y, "Fahrenheit."

print "Press 1 for Celsius to Fahrenheit, or Press 2 for Fahrenheit to Celsius."

z=int(raw_input(menu))

elif z== 2:

b = input("Enter the fahrenheit: ")

c = (float(b)-32)*(5.0/9.0)

print "It is ", c, "celsius."

print "Press 1 for Celsius to Fahrenheit, or Press 2 for Fahrenheit to Celsius."

z=int(raw_input(menu))



FOR NICK THRASHER:

I answered your question again but in a comment so look there. if you cant find it, just go to:

http://pythonscripts.weebly.com/mics.html

and it will be there
genthner
2016-10-04 07:04:05 UTC
you do no longer tell it that the a million is advantageous, do away with the plus. So... assert(compare_dictionary_order("abcd"… "abc") == +a million); must be assert(compare_dictionary_order("abcd"… "abc") == a million); assert(compare_dictionary_order("ABc", "AbC") == -a million); must be assert(compare_dictionary_order("ABc", "AbC") == a million); that could desire to be authentic, precise? ABC is comparable to abc, shouldnt ABc be comparable to AbC? you need to asset for a million, no longer -a million.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...