[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> </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> print =
"please choose an=20
option"<BR> print<BR> print "1. =
circle=20
area"<BR> print "2. square area"<BR> =
print=20
"3. rectangle area"<BR> print "4. square=20
root"<BR> print "5. add numbers"<BR> =
shape =3D=20
input("> ")<BR> if shape =3D=3D=20
1:<BR> print "would you like =
to input=20
radius or diameter?"<BR> print =
"1.=20
radius"<BR> print "2.=20
diameter"<BR> question =3D =
input (">=20
")<BR> if question =3D=3D=20
1:<BR> =
print=20
"what is the=20
radius?"<BR> &=
nbsp;=20
radius =3D input(">=20
")<BR> =
radius=20
=3D=20
3.14*radius**2<BR> &=
nbsp; =20
print radius<BR> elif question =
=3D=3D=20
2:<BR> =
print=20
"what is the=20
diameter?"<BR>  =
; =20
diameter =3D input (">=20
")<BR> =
diameter =3D=20
diameter/2<BR>  =
; =20
diameter =3D diameter**2 *=20
3.14<BR>  =
; print=20
diameter<BR> =20
else:<BR> &nbs=
p;=20
print<BR> &nbs=
p;=20
print "whoops thats not=20
good"<BR> &nbs=
p;=20
print<BR> elif shape =3D=3D=20
2:<BR> print "what is the =
length of a=20
side?"<BR> side =3D =
input(">=20
")<BR> side =3D=20
side*4<BR> print=20
side<BR> elif shape =3D=3D=20
3:<BR> print "what is the=20
length?"<BR> length =3D =
input(">=20
")<BR> print "what is the=20
height?"<BR> height =3D =
input(">=20
")<BR> height =3D=20
height*length<BR> print=20
height<BR> elif shape =3D=3D 4:<BR> lauren =3D =
0<BR> print=20
"what number do you need the square root for?"<BR> number =3D =
input(">=20
")<BR> guess =3D 1.0<BR> while lauren !=3D =
guess:<BR> lauren =3D=20
(number / guess + guess)/2<BR> guess =3D (number / lauren +=20
lauren)/2<BR> print guess<BR> elif shape =3D=3D=20
5:<BR> krysten =3D =
input("first number=20
to add> ")<BR> add =3D =
input("second=20
number to add> ")<BR> =
equals =3D add=20
+ krysten<BR> print "is that=20
all?"<BR> print "1.=20
yes"<BR> print "2.=20
no"<BR> all =3D input(">=20
")<BR> if all =3D=3D=20
1:<BR> =
print=20
equals<BR> if all =3D=3D=20
2:<BR> =
while=20
all =3D=3D=20
2:<BR> &=
nbsp; =20
third =3D input("next number to add>=20
")<BR> &=
nbsp; =20
equals =3D equals +=20
third<BR> &nbs=
p; =20
print "is that all?"<BR> =
print "1. yes"<BR> =
print "2. no"<BR> =20
all =3D input("> =
")<BR> print=20
equals<BR> =
else:<BR> =20
print<BR> print "whoops thats =
not=20
good"<BR> =20
print</FONT></DIV></BODY></HTML>
------=_NextPart_000_000A_01C12F7E.047D7480--