Chapter 1

Here is a sample interaction with a Python shell:


#The first statement asks Python to display the literal phrase Hello, World!.
------------------------------------------
>>> print("Hello , World!")
Hello , World!

>>> print(2 + 3)
5


#Python prints the part in quotes, 2 + 3 =, followed by the result of adding 2 + 3, which is 5.
--------------------------------------------
>>> print("2 + 3 =", 2 + 3)
2 + 3 = 5


#The first line tells Python that we are defining a new function and we are naming it hello.
#The following lines are indented to show that they are part of the hello function.
-------------------------
>>> def hello():
            print ("Hello")
            print("Computers are fun!")

>>> hello()
Hello
Computers are fun!


#An example of a customized greeting using a parameter.
------------------------------------
>>> def greet(person):
            print("Hello", person)
            print("How are you?")

#Now we can use our customized greeting.
------------------------------------
>>> greet("John")
Hello John
How are you?
>>>

>>> greet("Emily")
Hello Emily
How are you?
>>>