60 likes | 193 Views
Functions. lecture04. A Couple We’ve Seen Already. range () len (). Functions. They’re like mini programs, they reduce reduce repetition. def my_sum ( array ): sum = 0 if len ( array ) == 0 : return 0 for item in array : sum += item return sum numbers = range ( 101 )
E N D
Functions lecture04
A Couple We’ve Seen Already range() len()
Functions They’re like mini programs, they reduce reduce repetition. defmy_sum(array): sum = 0 iflen(array) == 0: return0 for item inarray: sum += item returnsum numbers = range(101) printmy_sum(numbers)
my_sum defmy_sum(array): sum = 0 iflen(array) == 0: return0 for item inarray: sum += item returnsum numbers = range(101) printmy_sum(numbers)
Which is Bigger Find the biggest of two numbers def bigger(num1, num2): if num1 >= num2: returnTrue else: returnFalse
Which is Bigger Find the biggest number in an array