How to add data to empty dictionary and types of data a dictionary can store


How to add data to empty dictionary and types of data a dictionary can store

which types of data a dictionary can store ?

Anything eg – numbers , strings , list ,dictionary

 Variables can hold values of different data types. Python is a dynamically typed language hence we need not define the type of the variable while declaring it. The interpreter implicitly binds the value with its type.

Python enables us to check the type of the variable used in the program. Python provides us the type() function which returns the type of the variable passed.


user_info = {
'name' : 'pramod',
'age' : 22 ,
'rollno' :'17691a05b9',
'class' : 'B-Tech'}
print(user_info['name'])
 print(user_info['age'])
 print(user_info['rollno'])
 print(user_info['class'])

How to add data to empty dictionary


user_info2 = {}
user_info2['name']='prem kumar'user_info2['age']=22
 print(user_info2)

How to add data to empty dictionary and types of data a dictionary can store

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories

You have successfully subscribed to myprogrammingschool

There was an error while trying to send your request. Please try again.

My Programming School will use the information you provide on this form to be in touch with you and to provide updates and marketing.