-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcst_loops.py
More file actions
220 lines (122 loc) · 2.65 KB
/
Copy pathcst_loops.py
File metadata and controls
220 lines (122 loc) · 2.65 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# age = int(input("enter the age = "))
#
# if(age >= 21 and age <= 29):
# print("eligible")
# print("good luck")
# else:
# print("not eleigible")
# print("bad luck")
# simple if else block
#
# age = int(input("enter the age = "))
#
# print(type(age))
#
# if(age >= 21 and age <= 30):
# print("eligible")
# print("if block")
# else:
# print("not eligible")
# print("else block")
# Nested if example
# age = int(input("enter the age = "))
#
# if(age >= 21):
#
# if(age <= 29):
# print("perfect age to get married")
#
# if(age == 21):
# print("sweet age ")
#
# if(age > 29 and age < 35):
# print("marry soon")
#
# if(age >= 35 and age < 40):
# print("last chance")
#
# if(age >= 40):
# print("age barred no marraige")
#
# else:
# print("not eligible")
# print("else block")
# if -elif - else or switch cond
#
# age = int(input("enter the age = "))
#
# if(age >= 21):
# if(age < 30):
# print("correct age")
# elif(age >= 30 and age < 35):
# print("Marry soon")
# elif(age >= 35):
# print("No Marraige")
# elif(age == 21):
# print("sweet age")
# else:
# print("not eligible")
# print("else block")
# #
######### LOOPS ############################
# nums = [10,20,30,40,50]
# for x in nums:
# print(x*3)
# perc = [78,23,89,44,17,21,90,98]
# for x in perc:
# if(x >= 80):
# print(x)
# perc = [78,23,89,44,17,21,90,98,132,-30,113]
# failc = 0
# firstc = 0
# secondc = 0
# thirdc = 0
# distc = 0
# for x in perc:
# if(x >= 0 and x < 35):
# failc += 1
# elif(x >= 35 and x < 50):
# thirdc += 1
# elif(x >= 50 and x < 60):
# secondc += 1
# elif(x >= 60 and x < 80):
# firstc += 1
# elif(x >= 80 and x <= 100):
# distc += 1
# else:
# print("invalid perc ", x)
# print(distc)
# print(firstc)
# print(secondc)
# print(thirdc)
# print(failc)
# for x in range(10):
# print(x)
# for x in range(1,11):
# print("sandy")
# a = 5
# while(a > 0):
# print(a)
# a = a - 1
# a = 50
# while(a > 0):
# if(a % 5 == 0):
# print(a)
# a = a - 1
# mynum = 3
# count = 0
# while(True):
# guessnum = int(input("guess the number from 1 to 10 = "))
# count = count + 1
# if(mynum == guessnum):
# print("bingo u guessed it right in counts ", count)
# break
# else:
# print("sorry wrong guess pls try again ")
#
#### break , continue and pass
# nums = [10,20,30,40,50,60]
# for x in nums:
# if( x == 40):
# pass
# print(x)