[Tutor] Calculator functions part II

Brendhan Horne brendhanhorne@hotmail.com
Wed, 20 Jun 2001 22:46:21 -0400


This is a multi-part message in MIME format.

------=_NextPart_000_003D_01C0F9DA.D3888460
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I got this response:
Close, but in most programming languages, the operations go on the right
and the result goes on the left.  That means you want

ans =3D a * b

Then all you need to do is print it, like this:

print 'Answer: ' , ans

So I now have this:
#Calculator functions
a =3D raw_input ("First Number:")
b =3D raw_input ("Second Number:")
ans =3D a*b
print 'Answer:', ans

I end up with this:
First Number:8   ( I typed in the 8 )
Second Number:7 ( Ityped in the 7)
Traceback (innermost last):
  File "C:\Python20\prog1.py", line 4, in ?
    ans =3D a*b
TypeError: can't multiply sequence with non-int
So I am definitly getting warmer just not quite. should I change line =
placement?
Thanks,
Brendhan
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GE d- s: a C++ U(++) P(++) L+(++) E- W+ N+ o+ K- w+
O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++
D G(++) e+(++) h-- r++ y++*
------END GEEK CODE BLOCK------


------=_NextPart_000_003D_01C0F9DA.D3888460
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 content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>I got this response:</FONT></DIV>
<DIV><FONT size=3D2>Close, but in most programming languages, the =
operations go on=20
the right<BR>and the result goes on the left.&nbsp; That means you=20
want<BR><BR>ans =3D a * b<BR><BR>Then all you need to do is print it, =
like=20
this:<BR><BR>print 'Answer: ' , ans<BR><BR>So I now have =
this:</FONT></DIV>
<DIV><FONT size=3D2>#Calculator functions<BR>a =3D raw_input ("First =
Number:")<BR>b=20
=3D raw_input ("Second Number:")<BR>ans =3D a*b<BR>print 'Answer:',=20
ans<BR></FONT></DIV>
<DIV><FONT size=3D2>I end up with this:</FONT></DIV>
<DIV><FONT size=3D2>First Number:8&nbsp;&nbsp; ( I typed in the 8 =
)<BR>Second=20
Number:7 ( Ityped in the 7)<BR>Traceback (innermost last):<BR>&nbsp; =
File=20
"C:\Python20\prog1.py", line 4, in ?<BR>&nbsp;&nbsp;&nbsp; ans =3D=20
a*b<BR>TypeError: can't multiply sequence with non-int</FONT></DIV>
<DIV><FONT size=3D2>So I am definitly getting warmer just not quite. =
should I=20
change line placement?</FONT></DIV>
<DIV><FONT size=3D2>Thanks,<BR>Brendhan<BR>-----BEGIN GEEK CODE=20
BLOCK-----<BR>Version: 3.1<BR>GE d- s: a C++ U(++) P(++) L+(++) E- W+ N+ =
o+ K-=20
w+<BR>O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++<BR>D G(++) =
e+(++) h--=20
r++ y++*<BR>------END GEEK CODE =
BLOCK------<BR></DIV></FONT></BODY></HTML>

------=_NextPart_000_003D_01C0F9DA.D3888460--