-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice.py
More file actions
55 lines (42 loc) · 1.04 KB
/
Copy pathpractice.py
File metadata and controls
55 lines (42 loc) · 1.04 KB
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
x = 25
class TestSample:
x = 15
def sample(self):
x = 12
print(f"global var x = {globals()['x']}, class var x = {self.x}, local var x = {x}")
obj = TestSample()
obj.sample()
y = {
'name': 'abhay',
'marks': 95,
'price': 250.25,
'is_good_to_buy':True,
'item_list': [1,2,3,4,5,6]
}
print(y)
print(y['item_list'][3])
str = "Let’s see how to double each elements of the given list"
str_to_list = str.split()
print(type(str_to_list), str_to_list)
back_to_str = ' '.join(str_to_list)
print(type(back_to_str), back_to_str)
str_with_delimiter = str.replace(' ', '-')
print(type(str_with_delimiter), str_with_delimiter)
list1 = [3,5,7,9,12]
list2 = ['blue','red','green']
combo_list = list1 + list2
print(combo_list)
list1.extend(list2)
print(list1)
list3 = list()
print(len(list3))
list4 = [3,12,5,15,7,27,9,32]
list4.sort()
print(list4)
list5 = [3,12,5,15,7,25,27,9,32,30]
print(sorted(list5))
list4.sort(reverse=True)
print(list4)
print(sorted(list5,reverse=True))
list6 = []
assert bool(list6), "list is empty"