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
Code: [in Python language]
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 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.
____________________
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: