-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path01.py
120 lines (71 loc) · 2.14 KB
/
01.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# ---------------(Assignment 1)---------------
friends = ["Osama", "Ahmed", "Sayed", "Ali", "Mahmoud"]
print(friends[0]) # 1st method
print(friends.pop(0)) # 2nd method
print(friends[-1]) # 1st method
print(friends.pop(-1)) # 2nd method
print("="*40)
# ---------------(Assignment 2)---------------
friends = ["Osama", "Ahmed", "Sayed", "Ali", "Mahmoud"]
print(friends[ : :2])
print(friends[1: :2])
print("="*40)
# ---------------(Assignment 3)---------------
friends = ["Osama", "Ahmed", "Sayed", "Ali", "Mahmoud"]
print(friends[1:4])
print(friends[-2: ])
print("="*40)
# ---------------(Assignment 4)---------------
friends = ["Osama", "Ahmed", "Sayed", "Ali", "Mahmoud"]
friends[3] = 'Elzero'
friends[4] = 'Elzero'
print(friends)
print("="*40)
# ---------------(Assignment 5)---------------
friends = ["Osama", "Ahmed", "Sayed"]
friends.insert(0, "Ali")
print(friends)
friends.append("Gamal")
print(friends)
print("="*40)
# ---------------(Assignment 6)---------------
friends = ["Nasser", "Osama", "Ahmed", "Sayed", "Salem"]
friends.remove("Nasser")
friends.remove("Osama")
print(friends)
friends.remove("Salem")
print(friends)
print("="*40)
# ---------------(Assignment 7)---------------
friends = ["Ahmed", "Sayed"]
employees = ["Samah", "Eman"]
school = ["Ramy", "Shady"]
friends.extend(employees)
friends.extend(school)
print(friends)
print("="*40)
# ---------------(Assignment 8)---------------
friends = ["Ahmed", "Sayed", "Samah", "Eman", "Ramy", "Shady"]
friends.sort()
print(friends)
friends.sort(reverse=True)
print(friends)
print("="*40)
# ---------------(Assignment 9)---------------
friends = ["Ahmed", "Sayed", "Samah", "Eman", "Ramy", "Shady"]
print(len(friends))
print("="*40)
# ---------------(Assignment 10)---------------
technologies = ["Html", "CSS", "JS", "Python", ["Django", "Flask", "Web"]]
print(technologies[-1][0])
print(technologies[-1][-1])
print("="*40)
# ---------------(Assignment 11)---------------
my_list = [1, 2, 3, 3, 4, 5, 1]
my_list.remove(1)
my_list.remove(3)
my_list.sort()
unique_list = my_list
print(unique_list)
print(type(unique_list))
print(unique_list[0:4])