def main(): #defining a function
print "Hello World!"
main()
def printMessage(): # defining function
print "Hello world!"
printMessage() # calling the function
printMessage();
def printMessage():
print "Hello world!"
def printMessage():
print "Hello world!"
printMessage()
def printMessage():
times = 0
times += 1
print "This function called ", times, " times"
choice = '1'
while(choice != 'Q'):
print "Enter Q to quit, any other character to continue: ",
choice = raw_input()
if (choice == 'Q'):
print "Input stopped"
else:
printMessage()
def printMessage():
times = 0
times += 1
print "This function called ", times, " times"
choice = '1'
while(choice != 'Q'):
print "Enter Q to quit, any other character to continue: ",
choice = raw_input()
if (choice == 'Q'):
print "Input stopped"
else:
printMessage()
times = 0
def printMessage():
global times
times += 1
print "This function called ", times, " times"
choice = '1'
while(choice != 'Q'):
print "Enter Q to quit, any other character to continue: ",
choice = raw_input()
if (choice == 'Q'):
print "Input stopped"
else:
printMessage()
times = 0
def printMessage():
global times
times += 1
print "This function called ", times, " times"
choice = '1'
while(choice != 'Q'):
print "Enter Q to quit, any other character to continue: ",
choice = raw_input()
if (choice == 'Q'):
print "Input stopped"
else:
printMessage()
def printMessage():
print "You inputted ", str
print "Enter a string: ",
str = raw_input()
printMessage()
def printMessage(s):
print "You inputted ", s
print "Enter a string: ",
str = raw_input()
printMessage(str)
def printMessage(firstName, lastName):
print "Your name is ", firstName, " ", lastName
print "Enter first name:",
name1 = raw_input()
print "Enter last name:",
name2 = raw_input()
printMessage(name1, name2)
def printMessage(thename, theage):
print "Your name is ", thename, " and your age is", theage
print "Enter name:",
name = raw_input()
print "Enter age:",
age = int(raw_input())
printMessage(name, age)
printMessage(age, name)
def doubleIt(x):
print "The number to be doubled is ", x
x *= 2
print "The number doubled in doubleIt is ", x
print "Enter number: ",
num = int(raw_input())
doubleIt(num)
print "The number doubled outside the function is ", num,
li = [0]
def doubleIt():
print "The number to be doubled is ", li[0]
li[0] *= 2
print "The number doubled in doubleIt is ", li[0]
print "Enter number: ",
num = int(raw_input())
li[0] = num
doubleIt()
print "The number doubled outside the function is ", li[0]
z = []
def addNumbers (a, b):
z.append(a + b)
print "Enter first number: ",
firstNum = int(raw_input())
print "Enter second number: ",
secondNum = int(raw_input())
addNumbers(firstNum, secondNum)
print firstNum, " + ", secondNum, " = ", z[0]
def addNumbers(x, y):
return x + y
print "Enter first number: ",
firstNum = int(raw_input())
print "Enter second number: ",
secondNum = int(raw_input())
sum = addNumbers(firstNum, secondNum)
print firstNum, " + ", secondNum, " = ", sum