Computer Science, asked by justhackthis999, 2 days ago

Write a program to create a 3 points dictionary with keys as “name of months" and values as "no. of days" in the month. Display only those month names which has 31 days. *​

Answers

Answered by Equestriadash
3

C‎ode: [in Python language]

\tt month\_dict\ =\ \{"January":31,\ "February":28, "March":31,\\ "April":30,\ "May":31, "June":30,\ "July":31,\ "August":31,\\ "September":30,\ "October":31,\ "November":30,\ "December":31\}\\\\for\ i\ in\ month\_dict:\\{\ \ \ \ \ }if\ month\_dict[i]\ ==\ 31:\\{\ \ \ \ \ }{\ \ \ \ \ }print(i)

Explanation:

A dictionary is a data type that stores data in the form of a key-value pair, where the key acts as the index to the value. As per the question, a dictionary was created accordingly. A \tt for loop was initiated to traverse through the dictionary. When a loop is done for a dictionary, the variable considers the keys only. To test for the number of days, we use a conditional statement. If the condition is satisfied, the key will be printed.

Answered by ADITYABHAIYT
1

____________________

A dictionary is a data type that stores data in the form of a key-value pair, where the key acts as the index to the value. As per the question, a dictionary was created accordingly. A for loop was initiated to traverse through the dictionary. When a loop is done for a dictionary, the variable considers the keys only. To test for the number of days, we use a conditional statement. If the condition is satisfied, the key will be printed.

Explanation:

____________________

Similar questions