In this lab I basically used Python as a calculator to add, multiply, divide and subtract two integers.
The Source code is:
numStr = raw_input(‘Please enter first number: ‘)
x = int(numStr)
numStr2 = raw_input(‘Please enter second number: ‘)
y = int(numStr2)
print x,’plus’,y,’equals’,x + y
print x,’times’,y,’equals’,x * y
print x,’divided by’,y,’equals’,x / y
print x,’subtracted by’,y,’eguals’,x-y
The Source code is:
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type “copyright”, “credits” or “license()” for more information.
>>> ================================ RESTART ================================
>>>
Please enter first number: 2
Please enter second number: 6
2 plus 6 equals 8
2 times 6 equals 12
2 divided by 6 equals 0
2 subtracted by 6 eguals -4
>>> ================================ RESTART ================================
>>> ================================ RESTART ================================
>>>
Please enter first number: 2222222
Please enter second number: 3333333
2222222 plus 3333333 equals 5555555
2222222 times 3333333 equals 7407405925926
2222222 divided by 3333333 equals 0
2222222 subtracted by 3333333 eguals -1111111
>>>