Programming Example

WAP to create a dictionary named year whose keys are month names and values are their corresponding number of days.

Solution

dict={}
ch='y'
while ch=='y' or ch=='Y':
    month=input("Enter name of month : ")
    days=eval(input("Enter no. of days of month : "))
    dict[month]=days
    ch=input("Want to add more months (Y/N) : ")
print(dict)
Output

Enter name of month : january
ENter no. of days of month : 31
Want to add more months (Y/N) : y
Enter name of month : February
ENter no. of days of month : 28
Want to add more months (Y/N) : n
{'january': 31, 'February': 28}
CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad