lab_2

here is my lab 2

 

 

In this lab we learn how to use integer’s numbers in python and use them to perform arithmetic operations. The program works the same as a calculator; if you try to divide by zero it will show you an error message. If you try to multiply 2 very large integers it will not give you the exact answer.  Also if you try to multiply a number by a letter without quotations marks in it, the program will send an error message, but if you put the quotations marks it will only create more of the same letters depending on the integer.

 

 

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.
>>> a=50
>>> b=25
>>> a+b
75
>>> a-b
25
>>> a*b
1250
>>> a/b
2
>>> c=0
>>> a/c

Traceback (most recent call last):
  File “<pyshell#7>”, line 1, in <module>
    a/c
ZeroDivisionError: integer division or modulo by zero
>>> d=10000000000000000000
>>> a*d
500000000000000000000L
>>> f=99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
>>> f*a*d
49999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999500000000000000000000L
>>> a*t

Traceback (most recent call last):
  File “<pyshell#12>”, line 1, in <module>
    a*t
NameError: name ‘t’ is not defined
>>> a*(‘t’)
‘tttttttttttttttttttttttttttttttttttttttttttttttttt’
>>>

 

 

Restorative dentistry