[Tutor] this is hard

Rob rob@uselesspython.com
Mon, 19 Aug 2002 14:58:49 -0500


#welcome
print "welcome ryan I just wanted you to have a second calculator!"
print "here you can ahose from what you would like o ind the rarea of..."
input = raw_input("type 1 for a rectangle")
if input == '1':

     height = raw_input("please type height here:")
     width = raw_input("please type width here:")
     area = int(height) * int(width)
     print "The area is" + str(area)

I made a few minor changes, including correcting one spelling error
("heigth").

You can use raw_input() to get input from the user, and then specify what
sort of data you want to translate the input into. For instance, you may
want to use int (integer) or float (floating-point) for the math part, and I
chose int here.

Also, on the 5th line, I changed 1 to '1', because raw_input() grabs the
user's input as a string, which uses quotes.

Rob

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
melvin terry
Sent: Monday, August 19, 2002 2:46 PM
To: Pythontutor
Subject: [Tutor] this is hard


why wont this work? When you type 1 noting happenes

#welcome
print "welcome ryan I just wanted you to have a second calculator!"
print "here you can ahose from what you would like o ind the rarea of..."
input = raw_input("type 1 for a rectangle")
if input == 1:

     heigth = input("please type height here:")
     width = input ("please type width here:")
     area = height*width
     print "The area is"
     area




Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com