-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkingWithList.py
More file actions
55 lines (40 loc) · 1013 Bytes
/
WorkingWithList.py
File metadata and controls
55 lines (40 loc) · 1013 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
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
Students = []
Students.append("Rehman")
Students.append("Abdullah")
Students.append("Qasim")
Students.append("Ali")
# Iterating through loop
# for s in Students:
# print(s," ",end="")
# print()
# i = 0
# while len(Students)>i:
# print(Students[i],end=" ")
# i = i + 1
# print()
# Another way to iterate using for loop
# for j in range(len(Students)):
# print(Students[j],end=" ")
# print()
# # Reverse iterate
# for j in range(len(Students)-1-1,-1):
# print(Students[j],end=" ")
# print()
# # Starts from len-1 to 0 but here is -1 because of the ending index is exclusive in python and step by -1
# # Another simple way
# for i in reversed(Students):
# print(i,end=" ")
# print()
# for i in range(1,6,1):
# print(i)
#square = []
# for i in range(1,11):
# square.append(i*i)
# print(square)
# '''Simple Statistics'''
# print(min(square))
# print(max(square))
# print(sum(square))
# '''List Comprehension'''
# squares = [i**2 for i in range(1,11)]
# print(squares)