Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1: Determine the output of the print function where the dictionary studentData contains the names of students and their ages. studentData ={ 'std1': 'John',

image text in transcribed
image text in transcribed
Question 1: Determine the output of the print function where the dictionary studentData contains the names of students and their ages. studentData ={ 'std1': 'John', 'std1_age': 20, 'std2': 'Harry', 'std2_age': 21\} 1. print (len (studentData)) 2. print( studentData['std1_age ']) 3. print("John" in studentData) 4. print(list (studentData.items ()) [3]) 5. print('std1' in studentData) 6. print('std1_age' not in studentData) 7. print(list(studentData.values ())) 8. print(studentData.get("std1", "None")) 9. print(studentData.get("A", "Not Found")) 10. del studentData ["std2"] print (studentData) 11. studentData ["std2"] = 'Smith' print (studentData) 12. studentData.clear() print (len (studentData)) 13. for x in studentData: print ( x ) 14. for x in studentData.values () : print ( x ) 15. dupData = dict (studentData) dupData ["std1_age"] =2 print (studentData ["std1_age"]) 16. studentData. update ( { "std1_age": 30 , "std2_age": 45\}) print (studentData) Question 2: Rewrite the code using a dictionary instead of an if statement. 1. def determineRank (years): if years == 1: return "Freshman" elif years == 2 : return "Sophmore" elif years = 3 : return "Junior" return "Senior

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Shouhong Wang, Hai Wang

1st Edition

1612330150, 978-1612330150

More Books

Students also viewed these Databases questions

Question

1. How can evolutionary theory explain prosocial behaviour?

Answered: 1 week ago