You don't know what a Ti 83 is.  Calculator.  The most basic programming 
available.  It already has so many functions built into it that it is much 
easier to tell it to do things.  You don't have to do all this integer 
conversion and such whatnot.  Wow... I'm really unsure of how this thing is 
supposed to work.  It seems the more I learn about Python, the more confused I 
become.  It's enough to bring tears to your eyes.  Not really but ya.Someone 
else helped me with the problem of accepting numbers and words.  I used:if 
shape in["1","circle"]:something like that.  It works wonderfully.  I'm not 
sure why, but I know that it does and that is enough.  Someone else also said 
that I had to convert to int, and I did.  That was another problem, which is 
now fixed.But, as usual, it is just one problem after another.  Now I have run 
into this error message: Traceback (most recent call last):  File "C:\Documents 
and Settings\HP_Owner\Python0\area.py", line 23, in <module>    area = 
3.14*(radius**2)TypeError: unsupported operand type(s) for ** or pow(): 'str' 
and 'int'>>> and others like this:Traceback (most recent call last):  File 
"C:\Documents and Settings\HP_Owner\Python0\area.py", line 19, in <module>    
area = height*widthTypeError: can't multiply sequence by non-int of type 
'str'>>> Very frustrating.  What is a non-int and what is 'str'?  Why can't it 
multiply the sequence?  I guess I should include the program I'm using for 
these things.I'm having this problem with both of these attached.  The messages 
above are from area.py.  area.py is sort of a prototype of radiacir.py, a test 
version.  You know, I should probably try that int trick, which I seem to have 
forgotten.  And guess what that did it.  It's amazing when you apply the things 
that you learn.  Apparently  I am quite absent minded.  Well It seems I don't 
need any of this help anymore.  Oh well.  Thanks anyway.Au > To: 
tutor@python.org> From: [EMAIL PROTECTED]> Date: Thu, 24 May 2007 23:34:05 
+0100> Subject: Re: [Tutor] trouble with "if"> > "adam urbas" <[EMAIL 
PROTECTED]> wrote > > >  It won't even accept words.  > > I can only get it to 
accept numbers.  > > try this(untested code!):> > number = None> data = 
raw_input('Type something: ')> try: number = int(data)> except: data = 
data.split()    # assume a string> > if number:    # user entered a number>     
if number == 1:  print 'circle'>     elif number == 2: print 'another'> else:   
      # user entered words>     if data[0].lower() == 'circle': print 'circle'> 
    else: print 'user entered ', data[0]> > Notice that to use ithe input as a 
number you have to > convert the raw input characters to a number (using int)> 
To get the individual words we can use split() which by > default splits a 
string into the individual words.> > Is that the kind of thing you mean?> > 
I've no idea what a Ti83 is BTW. :-)> > Alan G.> > 
_______________________________________________> Tutor maillist  -  
Tutor@python.org> http://mail.python.org/mailman/listinfo/tutor
_________________________________________________________________
Create the ultimate e-mail address book. Import your contacts to Windows Live 
Hotmail.
www.windowslive-hotmail.com/learnmore/managemail2.html?locale=en-us&ocid=TXT_TAGLM_HMWL_reten_impcont_0507
#"Area calculation program"

print "Welcome to the Area calculation program"
print "–––––––––––––"
print

# "Print out the menu:"
print "Please select a shape:"
print "1,  Rectangle"
print "2,  Circle"

#"Get the user’s choice:"
shape = raw_input("> ")

#"Calculate the area:"
if shape in["1","rectangle"]:
    height = raw_input("Please enter the height: ")
    width = raw_input("Please enter the width: ")
    area = height*width
    print "The area is", area
if shape in["2","circle"]:
    radius = raw_input("Please enter the radius: ")
    area = 3.14*(radius**2)
    print "The area is", area
#"Circle Data Calculation Program:"
print "Welcome to the Circle Data Calcuation Program."
print

#"Menu 1:"
print "Pick a shape:"
print "(NOTE: You must select the number of the shape and not the shape itself)"
print "1 Circle"
print "2 Square"
print "3 Triangle"

#"User's Choice:"
shape=raw_input("> ")

        #"Select Given:"
if shape == "1" or shape == "circle":
        print "Choose the given value:"
        print "1 radius"
        print "2 diameter"
        print "3 circumference"
        print "4 area"

#"User's Choice:"
given=raw_input("> ")

if given in["1", "radius"]:
        radius=raw_input("Enter Radius:")
        pi=3.14
        diameter=(radius*2)
        circumference=(radius*2*pi)
        area=(radius**2*3.14)
        print "Diameter:", diameter
        print "Circumference:", circumference
        print "Area:", area

if given == 2:
        diameter=raw_input("Enter Diameter:")
        radius=(diameter/2)
        circumference=(diameter*3.14)
        area=(radius**2*3.14)
        print "Radius:", radius
        print "Circumference:", circumference
        print "Area:", area

if given == 3:
        circumference=raw_input("Enter Circumference:")
        radius=(circumference/3.14/2)
        diameter=(radius*2)
        area=(radius**2*3.14)
        print "Radius:", radius
        print "Diameter:", diameter
        print "Area:", area

if given == 4:
        area=raw_input("Enter Area:")
        radius=(area/3.14)
          


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to