# Let's print text - very simple I hope! # Python programs are less formal than Java. # You don't need to enclose your code inside a class, etc. # No semicolon at end of statement. # PythonWin has a help feature that includes a Python tutorial. # And you can trace thru your program if you want # by changing the Run option. print "Hello, world!" # This statement will print a message on the next line. print "Sun, wind, rain" # Let's print the numbers from 1 to 10. for i in range (1, 11): print i # Note that we stay at 10! print "After the loop..." print i # Expression statement? 5+2 print "Did I accomplish anything by saying 5+2?" # No, saying 5+2 doesn't cause any output. # Let's convert number to string: # Note that if you have a long statement, put backslash to continue # to the next line. first = 5 second = 2 sum = first + second print "The sum of " + str(first) + " and " + str(second)\ + " is " + str(sum) # Can we make sound? It's loud! import winsound import math #c = 128.0 #winsound.Beep (c, 100) #winsound.Beep (c * math.pow(2.0, 4.0/12), 100) #winsound.Beep (c * math.pow(2.0, 7.0/12), 100)