Page 130 - CloudGPT_C8_Flipbook
P. 130
Output:
Critical Thinking
Python Information Literacy
B. Write a program to find sum of all elements in a list using functions.
C. Type the given program and view the output.
Code:
DAYS = [
("Sunday", 1),
("Monday", 2),
("Tuesday", 3),
("Wednesday", 4),
("Thursday", 5),
("Friday", 6),
("Saturday", 7)
]
for day, number in DAYS:
print(day, ":", number)
D. Type the given program to find maximum and minimum number in a list and view the output.
Code:
lst = []
num = int(input("How many numbers: "))
for n in range(num):
numbers = int(input("Enter number "))
lst.append(numbers)
print("Maximum element in the list is :", max(lst))
print("Minimum element in the list is :", min(lst))
E. Type the given program to enter a number from the keyboard and then it will print:
the sum of the digits of the number
the reverses the number
128 Premium Edition-VIII

