In [3]:
x=500
y=5.0
z="Hello"

print x,y

print type(x)
print type(y)
print type(z)


500 5.0
<type 'int'>
<type 'float'>
<type 'str'>

In [9]:
#print "Hello, world!" as many times as you want
for i in range(0,5,1):
 print "Hi"


Hi
Hi
Hi
Hi
Hi

In [64]:
print    " First ==========="
for i in range(2):
 print i
for j in range(1):
 print j
    
print    " second ==========="
for i in range(3):
 for j in range(1):
     print i
     print j


 First ===========
0
1
0
 second ===========
0
0
1
0
2
0

In [126]:
for i in range(1,11,1):
 for j in range(1,11,1):
  print i*j
        
# How can we print out  in one line?
# How many lines after for will be affected by the for command and how can we separate them?


1
2
3
4
5
6
7
8
9
10
2
4
6
8
10
12
14
16
18
20
3
6
9
12
15
18
21
24
27
30
4
8
12
16
20
24
28
32
36
40
5
10
15
20
25
30
35
40
45
50
6
12
18
24
30
36
42
48
54
60
7
14
21
28
35
42
49
56
63
70
8
16
24
32
40
48
56
64
72
80
9
18
27
36
45
54
63
72
81
90
10
20
30
40
50
60
70
80
90
100

In [125]:
x=5
y=7
if x>y :
    print "x is greater than y"
elif x<y:
        print "x is smaller than y"
else:
            print "x and y are equal"


x is smaller than y

In [55]:
# How can we couple two loops? It starts with i=0 and then does not go to loop j  in the First case .
# while for the case 2 it is true. So when you fill the gap between two loops you automacillay separete two loops and
# they will work separeately.

In [74]:
def sum(x,y):
    sum=x+y
    return sum
Z=sum(5,7)
print Z


12

In [84]:
import numpy
a=numpy.array([11,23,43,54])
print a
print a[0],a[3]
print a[1:3]
print a[2:]

# the lower index in a slicing range is inclusive, while the upper index is exclusive


[11 23 43 54]
11 54
[23 43]
[43 54]

In [95]:
if x>=7 and x<=10 :
 print "x is between 7 and 10"
elif x>10 or x<7 :
     print " x is out of data"


 x is out of data

In [100]:
p=True
if(p):
 x=5
else:
 x=7
print x


5

In [150]:
import numpy #can't forget this!
import matplotlib.pyplot as plt #our shortcut

x = numpy.linspace(-4,4,30)      #create our first array
y1 = x**2    #this is how Python does exponents
y2 = x**3

plt.plot(x,y1)and plt.plot(x,y3)           #create the plot
plt.show()              #show the plot

# linspace means from 0 to 5 devided by 20 sections.


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-150-0bc1ea32276b> in <module>()
      6 y2 = x**3
      7 
----> 8 plt.plot(x,y1)and plt.plot(x,y3)           #create the plot
      9 plt.show()              #show the plot
     10 

NameError: name 'y3' is not defined

In [102]:
a=numpy.array([1,2,3])
b=a.copy()
print b
b[1]=7
print a
print b

# in this case any changing in b does not lead to change in a (just b). however if we assugned b=a instead of 
# b.a.copy() by changing the b also array a changes.


[1 2 3]
[1 2 3]
[1 7 3]

In [146]:
# How can we edit our graph or creating contour?

In [ ]: