0% found this document useful (0 votes)
2 views2 pages

Module 4 Functions Assignment

This document contains Python programs for three functions: one to find the maximum of three numbers, another to sum all numbers in a list, and a third to multiply all numbers in a list. Each function is defined with appropriate logic and includes user input for testing. The document is part of a module assignment from 360DigiTMG.

Uploaded by

Shubhada
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Module 4 Functions Assignment

This document contains Python programs for three functions: one to find the maximum of three numbers, another to sum all numbers in a list, and a third to multiply all numbers in a list. Each function is defined with appropriate logic and includes user input for testing. The document is part of a module assignment from 360DigiTMG.

Uploaded by

Shubhada
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

MODULE – 4 ASSIGNMENT

Functions

Please write Python Programs for all the problems.

1. Python function to find the maximum of three numbers

def max_of_three(a, b, c):

if a >= b and a >= c:

return a

elif b >= a and b >= c:

return b

else:

return c

num1 = int(input("Enter first number: "))

num2 = int(input("Enter second number: "))

num3 = int(input("Enter third number: "))

print("The maximum number is:", max_of_three(num1, num2, num3))

2. Python function to sum all the numbers in a list

def sum_of_list(numbers):

total = 0

for num in numbers:

total += num

return total

© 360DigiTMG. All Rights Reserved.


num_list = list(map(int, input("Enter numbers: ").split()))

print("The sum of all numbers in the list is:", sum_of_list(num_list))

3. Python function to multiply all the numbers in a list

def multiply_list(numbers):

result = 1

for num in numbers:

result *= num

return result

num_list = list(map(int, input("Enter numbers: ").split()))

print("The product of all numbers in the list is:", multiply_list(num_list))

© 360DigiTMG. All Rights Reserved.

You might also like