Repository navigation
Expand file tree
/
Copy pathLoops
More file actions
117 lines (100 loc) · 2.78 KB
/
Copy pathLoops
File metadata and controls
117 lines (100 loc) · 2.78 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
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
#######LOOOOOPPSSSS =====>>
# END FUNCTION IN LOOP WILL GET EXICUTED AFTER EACH AND EVERY ROTATION
# EXAMPLE=======>>>>>
#
# i = 1
#
# while i<6:
# # print(i,end="\t\n")
# # i=i+1
#
# the function pass used at the end of loops and conditional statements for pausing the loops or coditions
#### BREAK &&&& CONTINUE
# BREAK == it is used to Stop the loops or conditiional statements
# CONTINUE == it is used to reopen the loop from any condition
# #
# # Example-->>>
# print("password making\n\n")
# while True:
# email = input("Enter Email :: ")
#
# if email == "shurmaliya@gmail.com" :
# print("Email Verified!!\n")
# passw = int(input("Enter Password :: "))
# if passw == 9301299012:
# print("Password Verified\n")
# print("WELCOME SHUBHAM")
# break
# else:
# print("TRY AGAIN!!\n")
# continue
#A F0R LOOP === CONTAINS ANY REGULAR VARIABLE STATEMENT THAT LIES IN THE CONDITION
#
# student_names = ["Shubham","Nimish","Rohit","Rohan"]
# student_id = [2,6,1,4]
#
# while True:
# val = int(input("What do You want\n1.Names\n2.ID NO\n"))
# if val == 1:
# for names in student_names:
# print(names)
#
# elif val == 2:
# for id in student_id:
# print(id)
#
#
# else:
# continue
# ELSE BLOCK LOOP=====>>>>>>
# ELSE STATEMENT CAN BE USED IN LOOPS EXAMPLE====>>>>
#
# i = 1,23,45,67
#
# for z in i:
# print(i[0])
# else:
# print("hello")
# RANGE FUNCTION=====>>>>
# it is used in loops to get value from one range to another and for a given sequence-->>>
# for i in range(1000,99,-100):
# print(i)
#
#
# here 1000 is start value == "n",,99 is stop value== "n-1",, -100 is sequence interval
# lst = [12,65,7,46]
#
# for i in range(len(lst)):
# print(lst[i])
### Some more functions in loopssss
# ___>>>>>>> reversed() function reverse the values of loops
# example---->>>
#
# x = ["abhay","shubham","nimish"]
#
# for z in reversed(range(len(x))):
# print(x[z])
# SORTED FUNCTIONNN====>>>>>
# example---->>>>>
#
# x = ["shubham","nimish","rohit","rohan","abhay"]
#
# for z in sorted(x):
# print(z)
# a function called reverse in sorted fun====>>>>
# x = [55,23,67,40,23]
#
# for f in sorted(x ,reverse= True):
# print(f)
# A FUNCTION CALLED enumerate() wich gives the index or length value of list
#
# lst = ["java","python","c","kotlin"]
#
# for index, z in enumerate(lst):
# print(index,":",z,"\n")
# Another Fnctin called as zip() is used to joint the lists but condition is that combining lists should have same elements:::
# lst1 = ["Java","Python","Javascript","Kotlin"]
# lst2 = ["50%","70%","89%","80%"]
#
# for l1,l2 in zip(lst1, lst2):
# print("Course : ",l1," ","Rate : ",l2)