# Practice Problem 1
# Write a function that returns the maximum of two numbers.
#
def max2(num1,num2): # function header or function signature; contains NAME of function and a list of parameter NAMES
if num1 > num2:
return num1
else:
return num2
# What is a parameter?
# it is a generic name to variable that is typically an INPUT to a function
print(max2(10,20))
print(max2(30,5))
max2(100,200)
def nationality(name):
???
???
def uselessFunction(name):
if nationality(name) == "India":
return "Namaste"
else:
return "Hello"
uselessFunction("")
uselessFunction("James")
for i in range(10):
print(uselessFunction())
print("Namaste")
def square(n):
return n*n
square(10000000000000000000000000000) == 100000000000000000000000000000000000000000000000000000000
# FINITE DIGITAL COMPUTER
# ANALOG COMPUTER
# INIFINITE PRECISION ARITHMETIC
# Problem 2
# Write a function called fizz_buzz that takes a number as parameter.
# If the number is divisible by 3, it should return “Fizz”. C1
# If it is divisible by 5, it should return “Buzz”. C2
# If it is divisible by both 3 and 5, it should return “FizzBuzz”. C3
# Otherwise, it should return the same number.
# C3 implies C1 and C2
def fizz_buzz(num):
if num%3 == 0 and num%5 == 0:
return "FizzBuzz"
elif num%3 == 0:
return "Fizz"
elif num%5 == 0:
return "Buzz"
else:
return str(num)
fizz_buzz(8)
9%3
13//3
13%3
+, -, *, /, %, //,