-
Notifications
You must be signed in to change notification settings - Fork 0
/
q9.py
43 lines (30 loc) · 763 Bytes
/
q9.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#Part (a)
def max_num(n):
max_n = -100
for elm in n:
if elm > max_n:
max_n = elm
return(max_n)
#Part (b)
def sum_list(n):
sum_n = 0
for elm in n:
sum_n += elm
return(sum_n)
#Part (b)
def mul_list(n):
mul_n = 1
for elm in n:
mul_n *= elm
return(mul_n)
inp_list=[]
no_elm = int(input("Enter the length of the list : "))
for i in range(no_elm):
num = int(input("Enter number " + str(i+1) + ' : '))
inp_list.append(num)
print("\n(a)\n")
print("Max value among", inp_list, " is", max_num(inp_list))
print("\n(b)\n")
print("Sum of values of", inp_list, " is", sum_list(inp_list))
print("\n(c)\n")
print("Product of values of", inp_list, " is", mul_list(inp_list))