2.2.1
>>> print (“hello world!”)
hello world!
>>> print (“hello world！”, “I love Python”, “Let’s enjoy it! ”)
hello world！ I love Python,  Let’s enjoy it!
>>> print (“The sum is:”+121)
>>> print (121) 
>>> print (121+56) 
>>> print (“The sum is:”+121)
The sum is:121
2.2.2
>>> teacher = raw_input()
>>> teacher
>>> print teacher
>>>myword= raw_input()
>>>print (“hello”, myword)
C:\Workspace> python hello.py
Michael
hello, world!
2.3.1
x = 457
y = 563763675
z = -7574

print(type(x))
print(type(y))
print(type(z))
x = 4.32
y = 5.0
z = -42.978

print(type(x))
print(type(y))
print(type(z))
x = 8e3
y = 29E5
z = -4567.2e30

print(type(x))
print(type(y))
print(type(z))
x = 4+5j
y = 6j
z = -9j

print(type(x))
print(type(y))
print(type(z))
2.3.2
print("Hello world!")
myword = "Hello world!"
print(myword)
longwords = """Python is a widely used general-purpose, high level programming language. 
It was initially designed by Guido van Rossum in 1991 
and developed by Python Software Foundation. 
It was mainly developed for emphasis on code readability, 
and its syntax allows programmers to express concepts in fewer lines of code."""
print(longwords)
a = "Hello, World!"
print(a[1])
b = "Hello, World!"
print(b[3:5])
b = "Hello, World!"
print(b[-5:-2])
a = "Hello, World!"
print(a*2)
a = "Hello, "
b = "World!"
print(a+b)
mywords = "Hello World!"
a = "at" in mywords
print(a)
mywords = "Hello World!"
a = "at"not in mywords
print(a)
print(r’hello\n’)
2.4.1
x = 23
y = "hello"
a = 8# a is of type int
a = "Tom"# a is now of type str
print(a)
a = 8
b = c = d =11
2.4.2
a = "Tom"
def func1():
  print(a+" is a cat.")

func1()
def func2 ():
a = "Tom"
  print(a+" is a cat.")
def func3():
  global s
s = "Tom"

func3 ()

print("The cat is " + s)
s = "Tom"

deffunc4():
  global s
s = "Mick"

myfunc()

print("The cat is " + s)

