-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab exe2.py
264 lines (173 loc) · 4.28 KB
/
lab exe2.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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# 1 to find 5 present or not
# l =[1,2,3,4,5]
# for i in range (len(l)):
# if 5==l[1]:
# print("true")
# else:
# print("false")
# 2 to print marks result
# mark1 = int(input("Enter your math mark :"))
# mark2 = int(input("Enter your science mark :"))
# mark3 = int(input("Enter your english mark :"))
# mark4 = int(input("Enter your nepali mark :"))
# total = mark1+mark2+mark3+mark4
# print("your total mark is ",total)
# percentage = (total/400)*100
# print("your perecentage is ",percentage)
# if percentage>70:
# print("you got distinction")
# elif percentage>60:
# print("you got first division")
# elif percentage>40:
# print("you are pass")
# else:
# print(("study hard"))
#
# print("GPA = ",percentage/25)
# 3 to print odd or even
# n = int(input("enter a limit num : "))
# for i in range(n):
# if i%2==0:
# print(i, "EVEN")
# else:
# print(i, "ODD")
# 4 to print smallest one
# i = 0
# l=[]
# while i<3:
# a = int(input("enter a number"))
# i = i+1
# l.append(a)
# if l[0]<l[1] and l[0]<l[2]:
# print(l[0], "is smallest")
# elif l[1]<l[0] and l[1]<l[2]:
# print(l[1], "is smallest")
# elif l[2]<l[1] and l[2]<l[0]:
#
# print(l[2], "is smallest")
# 5 to print true and false for intiger
# a = int(input("Enter a number"))
#
# if a > 0:
# print("True")
# elif a < 0:
# print("False")
# else:
# print("zero")
# 6 to print intiger last digit
# n = int(input('enter three number'))
# if n<=999:
# a = n//100
# b = (n-(a*100))//10
# c = (n-((a*100)+(b*10)))
# # print(a)
# # print(b)
# print(c)
# else:
# print("Invalid")
# 7 to print positive number and its fractional part
# num = float(input("enter number"))
#
# integralPart = int(num)
# fractionalPart = num - integralPart
# print("positive part is ", integralPart
# print("fraction part is ", fractionalPart)
# 8 to add sum of number
# num = int(input('enter a number'))
# def sum_digits(n):
# s = 0
# while n:
# s += n % 10
# n //= 10
# return s
#
# print("sum of digit is", sum_digits(num))
# 9 to find leap year or not
# year = 2001
# if (year % 4) == 0:
# if (year % 400) == 0:
# print(str(year) +" is a leap year")
# else:
# print(str(year) +" is not a leap year")
#
# else:
# print(str(year) + " is not a leap year")
# 10 if value are equal sum will be zero
# a = int(input("enter a number : "))
# b = int(input("enter a number : "))
# c = int(input("enter a number : "))
# if a==b or a==c:
# print("sum is equal to '0'")
# elif b==a or b==c:
# print("sum is zero")
# elif c==a or c==b:
# print("sum is zero")
# else:
# print("sum is", a+b+c)
# 11 to find square root
# number = 10
# print(number**3)
# 12 to find x
# x = 5
# x += 3
# print(x)
# 13 to print apple
# to print apple > apple
# print('Apple' > 'apple')
# # 14 to print float
# print(float(1))
# 15 to find output of a,b,c,d
# a =int(input("enter value for a :"))
# b =int(input("enter value for b :"))
# c = int(input("enter value for c :"))
# d =int(input("enter value for d :"))
# if a == b:
# print("a and b are equal")
# else:
# print("a and b are not equal")
# if a != d:
# print("a and d is not equal")
# else:
# print("a and d is equal")
# if b == d:
# print("b and d are equal")
# else:
# print("b and d are not equal")
# if a != c:
# print("a is not equal to c")
# else:
# print("a is equal to c")
# if b > a:
# print("b is greater than a")
# else:
# print("b is not greater than a")
# if a < d:
# print("d is greater than a")
# else:
# print("d is not greater than a")
# if b-a == c-b:
# print("b-a==c-b")
# else:
# print("b-a==c-b is not equal")
# if b >= d:
# print("b is greater or equal to d")
# else:
# print("b is not greater nor equal to d")
# a += c
# print("a+c =", a)
# b /= d
# print("b/d=", d)
# ---------------------------------------------------------------------------------------------------------------------
# print individual number.
# a=("Anil")
# b = a.replace('',' ')
# print(b)
#
# for i in range(len(b)):
# print(b[i])
# to print factorial part
# n = int(input("enter a number"))
# a = 1
# for i in range (1,n+1):
# a = a*i
# print(a)