Your Python program should perform the following four tasks: 1. Create a diction
ID: 3673243 • Letter: Y
Question
Your Python program should perform the following four tasks:
1. Create a dictionary with the following elements: 1. “IS340” : “Business Application Programming”
2. “IS445” : “Internet Application Development” 3. “IS457” : “Wireless Systems and Mobile App” 2. After getting a word of input from the user (i.e., a string such as “IS340”) as the key, your program should find the matching value and print out it. If there is no matching, print out “Not Exist!” message. Note that you need to use the input word as the key in the dictionary.
3. Receive another key and value (i.e., course number and title) from the user and insert it to the dictionary.
4. Print out the entire dictionary to check if your insertion is correctly done.
Explanation / Answer
course = {'IS340': 'Business Application Programming', 'IS445': 'Internet Application Development', 'IS457': 'Wireless Systems and Mobile App'};
key = raw_input("Enter course number to search")
print
if(course.has_key(key)):
print key," : ",course[key]
else :
print "Not Exist!"
key = raw_input("Enter course number")
value = raw_input("Enter course title")
print
course[key] = value
print course
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.