print('------------------Modules-------------------------')
# olin ckass niileeg packeg , olon pac niineed
# Build in moduls:
import random
import datetime
from collections import Counter, Defaultdict
print('random::', random.randint(0, 10))
#time
print('datetime::', datetime.time(22, 20, 15))
# date - today
print('datetime.todey::', datetime.date.today())
# Counter
print('Counter::', Counter([1, 2, 1, 3, 2, 4, 2, 3]))
# defaultdict::
# Error:::
myDict = {'a': 1, 'b': 2, 'c': 3}
# var = myDict['d']
# print(var)
myDict = Defaultdict(lambda: 'No key from Lambda', myDict)
var = myDict['d']
print(var)
def no_key():
return 'No key from Function'
def_dic = Defaultdict(no_key, {'a': 1, 'b': 2, 'c': 3})
print(def_dic['d'])
No comments:
Post a Comment