# My first Python program print("Hello World") # The Python interpreter: # 1. reads a line code # 2. interprets the instruction # 3. executes the instruction # 4. increments the "program counter" and repeats until done print("Hello") print("my") print("name") print("is") print("Inigo") print("Montoya") # This is a function consisting of: # 1. a header (def ...): "def" is a keyword # 2. a body (print ...): the body is indented using def say_introduction(): print("My name is Inigo Montoya.") def threaten_vengeance(): print("You killed my father.") print("Prepare to die.") print("Hello.") # This is a function consisting of: # 1. a header (def ...): "def" is a keyword # 2. a body (print ...): the body is indented using def say_introduction(): print("My name is Inigo Montoya.") def threaten_vengeance(): print("You killed my father.") print("Prepare to die.") # Do something... print("Hello.") say_introduction() # this is a function call threaten_vengeance() # this is another function call print("Hello.") threaten_vengeance() # and another # Abstraction hides the details of how things work and # makes it easier to make changes def threaten_vengeance(): print("You killed my father.") print("Prepare to die.") def greet(): print("Hello.") print("My name is Inigo Montoya.") greet() threaten_vengeance() greet() threaten_vengeance() # We can use functions that someone else wrote # # In these examples, we *pass* parameters to a function from simplefunctions import print_sqrt # make a function available to you print_sqrt(4) # call the function print_sqrt(9) # We can use functions that someone else wrote from simplefunctions import print_date_and_time # make a function available to you print_date_and_time() # call the function