Page 116 - Modular v1.1 Pyhton
P. 116
Project 9
Type the given program to traverse a dictionary and display its elements on the different lines
and view the output.
Code:
DAYS = {
"Sunday": 1,
"Monday": 2,
"Tuesday": 3,
"Wednesday": 4,
"Thursday": 5,
"Friday": 6,
"Saturday": 7,
}
for i in DAYS:
print(i,":", DAYS[i])
Project 10
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))
Project 11
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
Code:
sum = 0
rev = 0
number=int(input("Enter a number: "))
n = number
while (number):
digit = number % 10
sum += digit
rev = rev * 10 + digit
number //= 10
print("Reverse of number is : ",rev)
print ("Sum of digits of the number is : ",sum)
114 Touchpad MODULAR (Version 1.0)

