In [2]:
print "look at me go"
look at me go
In [3]:
a=5.5
b=8.9

c= a + b

print "sum: ",c,"=",a,"+",b,""
sum:  14.4 = 5.5 + 8.9 
In [4]:
a=5.5
b=8.9

c= a - b

print "sum: ",c,"= ",a,"-" ,b,""
sum:  -3.4 =  5.5 - 8.9 
In [5]:
a= 4.5
b= 3.3

c=a+b

print "sum: ",c," =",a,"+",b,""
sum:  7.8  = 4.5 + 3.3 
In [6]:
float(input("enter value of a:"))
float(input("enter value of b:"))
float(input("enter value of c:"))

f=a+b+c

"sum: ",a,"+",b,"+",c,"=",f,""
enter value of a:3.0
enter value of b:4.5
enter value of c:6.2
Out[6]:
('sum: ', 4.5, '+', 3.3, '+', 7.8, '=', 15.6, '')
In [7]:
first_name = " shreya"
family_name = " sinha"

name = first_name + family_name

print first_name ," + ", family_name ," = ", name,
 shreya  +   sinha  =   shreya sinha
In [8]:
a=9
b=7

if (a<5,a!=5 ): 
 print  "a is less than 5"
    
else: 
   print "you are stupid"
a is less than 5
In [9]:
a=5
b=4

print a

a,b=b,a

print a
5
4
In [10]:
first_name = " Johnny"
family_name = " Depp"
name = first_name + family_name
print first_name, " + ", family_name, " = ", name, 
 Johnny  +   Depp  =   Johnny Depp
In [11]:
count_to = 657+765

print count_to


count_to=109/9

print count_to
1422
12
In [17]:
import math

length = float(input("enter value of length:"))
breadth= float(input("enter value of breadth:"))
height= float(input("enter value of height:"))

surface_area = 2*(length*breadth+breadth*height+height*length)

side_diag = math.sqrt(length*length + breadth*breadth)
body_diag = math.sqrt(side_diag*side_diag + height*height)

print surface_area  
print body_diag
enter value of length:3.0
enter value of breadth:4.0
enter value of height:5.0
94.0
7.07106781187
In [6]:
df = [1.0,6.3,9.2,4.5,9.0,12.0]

print len(df)

df.append(90.6)

print df

import numpy as np

print np.mean(df)

print np.std(df)
6
[1.0, 6.3, 9.2, 4.5, 9.0, 12.0, 90.6]
18.9428571429
29.4402958614
In [11]:
 #while loop
    
    i=0
while i<=10:
      print i
      i=i+1
    
0
1
2
3
4
5
6
7
8
9
10
In [3]:
#for loop


i=0

for i in range  (1,10):

 print i
1
2
3
4
5
6
7
8
9
In [21]:
for i in range (0,20,5):

    print i
0
5
10
15
In [27]:
for i in range(0,-10,-1):
    
    print i*20
0
-20
-40
-60
-80
-100
-120
-140
-160
-180
In [29]:
range (0,100,3)
Out[29]:
[0,
 3,
 6,
 9,
 12,
 15,
 18,
 21,
 24,
 27,
 30,
 33,
 36,
 39,
 42,
 45,
 48,
 51,
 54,
 57,
 60,
 63,
 66,
 69,
 72,
 75,
 78,
 81,
 84,
 87,
 90,
 93,
 96,
 99]

backlash to prevent string breaking

print 'There\'s a snake in my boot'

In [6]:
#modulo
spam = 615%25

print spam
15