-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhile_loop.py
More file actions
163 lines (131 loc) · 3.39 KB
/
while_loop.py
File metadata and controls
163 lines (131 loc) · 3.39 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# # python loops
# The while loop repeatedly executes a block of code as long as the condition is true.
'''--> python has two primitive loop commands ( for loops)( while loops)
--> with the while loop we can executes a set of statements as long as a conditionis true.
'''
# # print i as long as i is less than 6
# i = 1
# while i < 6:
# print(i)
# i += 1
# output 1 2 3 4 5
# # The break statement
'''--> with the brak statement we can stop the loop even is the while condition is true.'''
# exit the loop when i is 3.
# i = 0
# while i < 6:
# i += 1
# if i==4:
# break
# print(i)
# i = 1
# while i <= 10:
# print(i)
# if i == 8:
# break
# i += 1
# # The continue statement we can stop the current iteration, anf continue with the next.
# i = 0
# while i <= 10:
# i += 1
# if i == 3:
# continue
# print(i)
# a = [1,2,3,4,5]
# itr = iter(a)
# tuple(itr)
# is_failed = True
# i = 1 #attempt
# while is_failed and i<=100 :
# print(f"Try {i}")
# i += 1
# print("i give up")
# is_failed = True
# i = 1
# while is_failed:
# if i%2!=0:
# i = i+1
# continue
# print(f"Attempt {i}")
# i = i+1
# if i>100:
# break
# print("i give up")
# i = 0
# while i<=10:
# x = 0
# while x<i:
# print(i*"hemi",end="-")
# x +=1
# print("")
# i +=1
import time
pin = '1234'
# input_pin = input("enter the pin:")
trails = 1
while trails <=3:
input_pin = input(f"trail-{trails} | enter the pin:")
trails +=1
if input_pin == pin:
print("CORRECT")
break
elif trails ==3:
if input_pin != pin:
print("wait a sec..!")
time.sleep(10)
else:
print("INCORRECT")
# pin = ""
# correct_pin = "1234"
# while pin != correct_pin:
# pin = input("enter the pin:")
# if pin != correct_pin:
# print("enter the correct pin")
# print("PIN accepted , you can proced")
# branch = ""
# branch_ISE ="ISE"
# while branch != branch_ISE:
# branch = input("enter the branch:").upper()
# if branch != branch_ISE:
# print("this is not your branch")
# print("ok, you'r belongs to our branch")
# # write a program taht counts from 1 to 10 using a while loop.
# i = 1
# while i <= 10:
# print(f"Times{i}",i)
# i += 1
# # creat a program that prints all odd numbers b/w 1 to 20 using a while loop.
# i = 1
# while i <20:
# if i%2 !=0:
# print(i)
# i = i+1
# # writea program that simulate a bus tucket booking system. the bus has 10 seats.
# # Each time a available seats decrease. when there are no seats left, the loop stops and display a message saying"All seats are booked".
# available_seats = 10
# while available_seats >0:
# print(f"{available_seats}available for booking")
# booking = input("Do you want book seats?(yes/no):").lower()
# if booking == "yes":
# available_seats -= 1
# print("seat is booked")
# else:
# print("no booking is made")
# print("All seats are booked")
# # Write program that counts down from 10 to 1 using a while loop and prints " Happy New Year " after the countdown is over.
# import time
# countdown = 10
# while countdown>0:
# print(countdown)
# time.sleep(1)
# countdown -= 1
# print("Happy New Year..!")
# is_failed=True
# i=0
# while is_failed :
# if i%2==0:
# print(f"try{i}")
# if i>=100:
# break
# i+=1
# print("i try the max time")