<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
<span style="color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; line-height: 17px; background-color: rgb(255, 255, 255); ">here is my code for a calculator:</span><div style="line-height: 17px; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; background-color: rgb(255, 255, 255); "><br></div><div style="line-height: 17px; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; background-color: rgb(255, 255, 255); "><div>def menu():</div><div><br></div><div>&nbsp; &nbsp; print "Welcome to calculator.py"</div><div>&nbsp; &nbsp; print "your options are:"</div><div>&nbsp; &nbsp; print " "</div><div>&nbsp; &nbsp; print "1) Addition"</div><div>&nbsp; &nbsp; print "2) Subtraction"</div><div>&nbsp; &nbsp; print "3) Multiplication"</div><div>&nbsp; &nbsp; print "4) Division"</div><div>&nbsp; &nbsp; print "5) Quit calculator.py"</div><div>&nbsp; &nbsp; print " "</div><div>&nbsp; &nbsp; return input ("Choose your option: ")</div><div>&nbsp; &nbsp;&nbsp;</div><div><br></div><div>def add(a,b):</div><div>&nbsp; &nbsp; print a, "+", b, "=", a + b</div><div>&nbsp; &nbsp;&nbsp;</div><div><br></div><div>def sub(a,b):</div><div>&nbsp; &nbsp; print b, "-", a, "=", b - a</div><div>&nbsp; &nbsp;&nbsp;</div><div><br></div><div>def mul(a,b):</div><div>&nbsp; &nbsp; print a, "*", b, "=", a * b</div><div>&nbsp; &nbsp;&nbsp;</div><div><br></div><div>def div(a,b):</div><div>&nbsp; &nbsp; print a, "/", b, "=", a / b</div><div>&nbsp; &nbsp;&nbsp;</div><div>def main():</div><div>&nbsp; &nbsp; loop = 1</div><div>&nbsp; &nbsp; choice = 0</div><div>&nbsp; &nbsp; while loop == 1:</div><div>&nbsp; &nbsp; &nbsp; &nbsp; choice = menu()</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if choice == 1:</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; add(input("Add this: "),input("to this: "))</div><div>&nbsp; &nbsp; &nbsp; &nbsp; elif choice == 2:</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sub(input("Subtract this: "),input("from this: "))</div><div>&nbsp; &nbsp; &nbsp; &nbsp; elif choice == 3:</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mul(input("Multiply this: "),input("by this: "))</div><div>&nbsp; &nbsp; &nbsp; &nbsp; elif choice == 4:</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; div(input("Divide this: "),input("by this: "))</div><div>&nbsp; &nbsp; &nbsp; &nbsp; elif choice == 5:</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loop = 0</div><div><br></div><div>&nbsp; &nbsp; print "Thank you for using calculator.py!"</div><div><br></div><div><br></div><div><br></div><div>main()</div></div><div style="line-height: 17px; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; background-color: rgb(255, 255, 255); "><br></div><div style="line-height: 17px; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; background-color: rgb(255, 255, 255); "><br></div><div style="line-height: 17px; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; background-color: rgb(255, 255, 255); ">Few questions:</div><div style="line-height: 17px; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; background-color: rgb(255, 255, 255); "><br></div><div style="line-height: 17px; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; background-color: rgb(255, 255, 255); ">why do i have to press enter for it to initialise</div><div style="line-height: 17px; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; background-color: rgb(255, 255, 255); ">why does it print the stuff in menu() again after doing the equation</div><div style="line-height: 17px; color: rgb(42, 42, 42); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; background-color: rgb(255, 255, 255); ">i am trying to understand classes if anyone has time to make all these functions go into a class calculator and have it still work and send me the code so i can have an example to refer to that would be great</div>                                               </div></body>
</html>