-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDictionary.py
More file actions
30 lines (22 loc) · 915 Bytes
/
Copy pathDictionary.py
File metadata and controls
30 lines (22 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
"""Dictionary.py: Demo code for Dictionary"""
__author__ = "Sumit Kala"
'''Each key is separated from its value by a colon (:), the items are separated by commas, and the whole thing is
enclosed in curly braces. An empty dictionary without any items is written with just two curly braces, like this: {}.
Keys are unique within a dictionary while values may not be. The values of a dictionary can be of any type,
but the keys must be of an immutable data type such as strings, numbers, or tuples.'''
def mydict():
mydictionary = {'Name': 'Sumit', 'Age': 38, 'Gender': 'Male', 'Country': 'India'}
return mydictionary
def main():
x = mydict()
for k, v in x.items():
print(f'{k}{" "}{v}')
keys = x.keys()
for k in keys:
print(f'{k}')
values = x.values()
for v in values:
print(f'{v}')
if __name__ == '__main__':
main()