# hello.py3 example file indetation and blank lines important # simple .py can be without def main(): # if __name__ == '__main__': # main() import math def main(): print("hello from python") # three ways to print the same line print('hello from python') print("hello","from python") a_int=7 a_float=7.25 a_real=7.2597256357e+300 print("a_int=",a_int) print("a_float=",a_float) print("a_real=",a_real) a_list=[7, 7.25, "abc"] print("a_list=",a_list) print("a_list[2]=",a_list[2]) a_list.append("def") print("append=", a_list) del a_list[1] print("delete=", a_list) print("len(a_list)=",len(a_list)) print(" ") a_tuple=2, 3, 5, 7 # can not modify b_tuple=(2, 3, 5, 7) # same as above print("a_tuple=",a_tuple) print("b_tuple=",b_tuple) print("b_tuple[2]=",b_tuple[2]) print(" ") dict={1:'a', 2:'b', 3:'c'} # dictionary key : value print("dict=",dict) dict[5]='e' print("dict 5=",dict) print("dict[3]=",dict[3]) # look up by key print(" ") z=range(5) print("range(5)=",z) z=range(1,5) print("range(1,5)=",z) z=range(1,7,2) print("range(1,7,2)=",z) x = 0.7071 print("x = ",x) print("anyfunct(x) =",anyfunct(x)) # note complex result", # end of main def anyfunct(x): # thus main can be in front of needed funstions, cmath also z = math.cos(x) + 1.0j*math.sin(x) - math.sqrt(x) return z if __name__ == '__main__': main() # end of hello.py3 see also test_math.py3