Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Thanks to programming experience and language evolution, we have a rather easy fix to this problem. Python has another kind of data type that is
Thanks to programming experience and language evolution, we have a rather easy fix to this problem. Python has another kind of data type that is exactly applicable here.
Try this example that creates what Python calls a dictionary.
days_in = {'Jan': 31, 'Feb': 28, 'Mar': 31, 'Apr': 30, 'May': 31, 'Jun': 30, 'Jul': 31, 'Aug': 31, 'Sep': 30, 'Oct': 31, 'Nov': 30, 'Dec': 31}
The Python dictionary is actually designed specifically for associative data. See if you can figure out how to fill in this blank:
month_name = input('Abbreviated month name: ') month_days = days_in[ Please Enter the Answer Here ] print(month_name,'has',month_days,'days')
Hint: The values from a dictionary are not chosen by their position within that dictionary, so this is actually much simpler than the earlier question that looked like this.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started