[Tutor] calculator

melvin2001 melvin2001@earthlink.net
Tue, 28 Aug 2001 04:58:03 -0400


This is a multi-part message in MIME format.

------=_NextPart_000_000A_01C12F7E.047D7480
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

well......im 15 years old and i just started messing with python a few =
days ago so obviously im not gonna be very good :op but i wrote a little =
program that does basic calculations and its not done yet i add to it =
just about every day. just wanted to show you guys to see what you think =
maybe help me out a little too.

test =3D 1
print "alright now for some real math"
print
while test =3D=3D 1:
    print "please choose an option"
    print
    print "1. circle area"
    print "2. square area"
    print "3. rectangle area"
    print "4. square root"
    print "5. add numbers"
    shape =3D input("> ")
    if shape =3D=3D 1:
        print "would you like to input radius or diameter?"
        print "1. radius"
        print "2. diameter"
        question =3D input ("> ")
        if question =3D=3D 1:
            print "what is the radius?"
            radius =3D input("> ")
            radius =3D 3.14*radius**2
            print radius
        elif question =3D=3D 2:
            print "what is the diameter?"
            diameter =3D input ("> ")
            diameter =3D diameter/2
            diameter =3D diameter**2 * 3.14
            print diameter
        else:
            print
            print "whoops thats not good"
            print
    elif shape =3D=3D 2:
        print "what is the length of a side?"
        side =3D input("> ")
        side =3D side*4
        print side
    elif shape =3D=3D 3:
        print "what is the length?"
        length =3D input("> ")
        print "what is the height?"
        height =3D input("> ")
        height =3D height*length
        print height
    elif shape =3D=3D 4:
 lauren =3D 0
 print "what number do you need the square root for?"
 number =3D input("> ")
 guess =3D 1.0
 while lauren !=3D guess:
  lauren =3D (number / guess + guess)/2
  guess =3D (number / lauren + lauren)/2
 print guess
    elif shape =3D=3D 5:
        krysten =3D input("first number to add> ")
        add =3D input("second number to add> ")
        equals =3D add + krysten
        print "is that all?"
        print "1. yes"
        print "2. no"
        all =3D input("> ")
 if all =3D=3D 1:
            print equals
        if all =3D=3D 2:
            while all =3D=3D 2:
                third =3D input("next number to add> ")
                equals =3D equals + third
                print "is that all?"
          print "1. yes"
          print "2. no"
          all =3D input("> ")
        print equals
    else:
        print
        print "whoops thats not good"
        print

------=_NextPart_000_000A_01C12F7E.047D7480
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.100" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>well......im 15 years old and i just =
started=20
messing with python a few days ago so obviously im not gonna be very =
good :op=20
but i wrote a little program that does basic calculations and its not =
done yet i=20
add to it just about every day. just wanted to show you guys to see what =
you=20
think maybe help me out a little too.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>test =3D 1<BR>print "alright now for =
some real=20
math"<BR>print<BR>while test =3D=3D 1:<BR>&nbsp;&nbsp;&nbsp; print =
"please choose an=20
option"<BR>&nbsp;&nbsp;&nbsp; print<BR>&nbsp;&nbsp;&nbsp; print "1. =
circle=20
area"<BR>&nbsp;&nbsp;&nbsp; print "2. square area"<BR>&nbsp;&nbsp;&nbsp; =
print=20
"3. rectangle area"<BR>&nbsp;&nbsp;&nbsp; print "4. square=20
root"<BR>&nbsp;&nbsp;&nbsp; print "5. add numbers"<BR>&nbsp;&nbsp;&nbsp; =
shape =3D=20
input("&gt; ")<BR>&nbsp;&nbsp;&nbsp; if shape =3D=3D=20
1:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "would you like =
to input=20
radius or diameter?"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print =
"1.=20
radius"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "2.=20
diameter"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; question =3D =
input ("&gt;=20
")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if question =3D=3D=20
1:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
print=20
"what is the=20
radius?"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;=20
radius =3D input("&gt;=20
")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
radius=20
=3D=20
3.14*radius**2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;=20
print radius<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elif question =
=3D=3D=20
2:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
print=20
"what is the=20
diameter?"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;=20
diameter =3D input ("&gt;=20
")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

diameter =3D=20
diameter/2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;=20
diameter =3D diameter**2 *=20
3.14<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
; print=20
diameter<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
else:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
print<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
print "whoops thats not=20
good"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
print<BR>&nbsp;&nbsp;&nbsp; elif shape =3D=3D=20
2:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "what is the =
length of a=20
side?"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; side =3D =
input("&gt;=20
")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; side =3D=20
side*4<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
side<BR>&nbsp;&nbsp;&nbsp; elif shape =3D=3D=20
3:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "what is the=20
length?"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; length =3D =
input("&gt;=20
")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "what is the=20
height?"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height =3D =
input("&gt;=20
")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height =3D=20
height*length<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
height<BR>&nbsp;&nbsp;&nbsp; elif shape =3D=3D 4:<BR>&nbsp;lauren =3D =
0<BR>&nbsp;print=20
"what number do you need the square root for?"<BR>&nbsp;number =3D =
input("&gt;=20
")<BR>&nbsp;guess =3D 1.0<BR>&nbsp;while lauren !=3D =
guess:<BR>&nbsp;&nbsp;lauren =3D=20
(number / guess + guess)/2<BR>&nbsp;&nbsp;guess =3D (number / lauren +=20
lauren)/2<BR>&nbsp;print guess<BR>&nbsp;&nbsp;&nbsp; elif shape =3D=3D=20
5:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; krysten =3D =
input("first number=20
to add&gt; ")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; add =3D =
input("second=20
number to add&gt; ")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
equals =3D add=20
+ krysten<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "is that=20
all?"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "1.=20
yes"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "2.=20
no"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; all =3D input("&gt;=20
")<BR>&nbsp;if all =3D=3D=20
1:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
print=20
equals<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if all =3D=3D=20
2:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
while=20
all =3D=3D=20
2:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;=20
third =3D input("next number to add&gt;=20
")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;=20
equals =3D equals +=20
third<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;=20
print "is that all?"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

&nbsp;print "1. yes"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

&nbsp;print "2. no"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;all =3D input("&gt; =
")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
equals<BR>&nbsp;&nbsp;&nbsp; =
else:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
print<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "whoops thats =
not=20
good"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
print</FONT></DIV></BODY></HTML>

------=_NextPart_000_000A_01C12F7E.047D7480--