-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.py
67 lines (56 loc) · 1.24 KB
/
types.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""
Different Types in python
"""
def func():
pass
class Sample:
pass
# Types of data
print('string', type(''))
print('0', type(0))
print('1.0', type(1.0))
print('True', type(True))
print('[]', type([]))
print('{}', type({}))
print('{0}', type({0}))
print('()', type(()))
print('lambda', type(lambda a: 10))
print('func', type(func))
print('Class()', type(Sample()))
print(None, type(None))
# Output
# string <class 'str'>
# 0 <class 'int'>
# 1.0 <class 'float'>
# True <class 'bool'>
# [] <class 'list'>
# {} <class 'dict'>
# {0} <class 'set'>
# () <class 'tuple'>
# lambda <class 'function'>
# func <class 'function'>
# Class() <class '__main__.Sample'>
# None <class 'NoneType'>
# Types of types (Meta Data)
print('\n\n-----------------')
print('str', type(str))
print('int', type(int))
print('float', type(float))
print('float', type(bool))
print('list', type(list))
print('dict', type(dict))
print('set', type(set))
print('tuple', type(tuple))
print('type', type(type))
print('class Sample', type(Sample))
# Output
# str <class 'type'>
# int <class 'type'>
# float <class 'type'>
# float <class 'type'>
# list <class 'type'>
# dict <class 'type'>
# set <class 'type'>
# tuple <class 'type'>
# type <class 'type'>
# class Sample <class 'type'>