MODULE – 4 ASSIGNMENT
Functions
Please write Python Programs for all the problems.
1. Write a Python function to find the Max of three numbers.
my_list = [10, 5, 8]
if len(my_list)==3:
print(max(my_list))
2. Write a Python function to sum all the numbers in a list.
def sum(numbers):
total = 0
for num in numbers:
total += num
return total
numbers_list = [1, 2, 3, 4, 5]
print("Sum of numbers in the list:", sum(numbers_list))
3. Write a Python function to multiply all the numbers in a list.
list1 = [1, 2, 3, 4, 5]
squares1 = []
for i in list1:
[Link](i ** 2)
print(squares1)
© 360DigiTMG. All Rights Reserved.
© 360DigiTMG. All Rights Reserved.