from pylab import *
#from numpy import *
a=1.2
b=a+2.3
print(b)
################  list examples ####################
lst=[1.2,2.3,4.] #example of list
print(lst)
#################  for examples ######################
for x in lst:    #for statement
	print(x+2.3)
lst1=["fero","jano"]   #list of strings
for s in lst1:
	print(s+" neznamy")
##############  range examples  ########################	
lst2=range(2,6,1)     # from, up_to-but-less-then, step (arguments must be integers)
print(lst2)
for i in range(0,10,2):
	print(2*i)
##############  arrays examples  ################################	
arr1=arange(2.1,6.1,1.9)   #array, arguments may be floats
print(arr1)
arr2=arange(0,10,0.1)
arr3=empty(10)
for i in range(0,10,1):
	arr3[i]=log(0.1*i)
print(arr3)
for i in range(0,10,1):
	if i<5:
		arr3[i]=i
	else:
		arr3[i]=2*i
print(arr3)
#####################  plot example  ################
yarr2=sin(arr2)    #apply function to a list
plot(arr2,yarr2)
y2=2.*yarr2;
plot(arr2,y2)
show()   #blocking execution until plot window closed
###################  user function example  #################
def is_inside(x,y):
	# returns true if the point x,y is inside a unit circle, false if not
	if (x*x+y*y)<1:
		return (True)
	else:
		return (False)
################# random number example  ##############
# Monte Carlo calculation of circle area
area=0.
for trial in range(0,10000,1):
	x=-1.+2.*np.random.random()
	y=-1.+2.*np.random.random()
	if is_inside(x,y):
		area=area+1
print(4.*area/10000.)  #should be pi		



