import random #Functions #A function is a mini program we can 'call' to run at any time, as many times #as we want #Inputs: values the function needs to run #Outputs: values the function generates, done via 'return' statement #Functions can use both, one or none of the above ###################################################################### #Examples #Function that needs nothing, and returns nothing def boop(): print("boop!") print("more things") print("very many important things") boop() boop() #Function with inputs def oneAndN(n): print(random.randint(1,n)) #oneAndN(10) #oneAndN(int(input())) #Function with Outputs def gimme(): return 12 score = gimme() def calcAvg(nums): sum = 0 for i in range(len(nums)): sum += nums[i] sum / len(nums) marks = [20,30,40,50,60,70, 80, 99] marks2 = [40,40,40,40,40, 900] print(calcAvg(marks)) print(calcAvg(marks2)) Make functions that do this stuff: 1) say your name 5 times, call the function a few times, see what happens 2) the can say any name, sayMyName(name) 3) inputs: 4 numbers, returns the avg of the 4 4) inputs: 3 numbers, returns the highest 5) inputs: 1 array, outputs the sum of the array 6) inputs: 1 array of names, outputs one of the names at random