-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.py
More file actions
297 lines (227 loc) · 7.09 KB
/
functions.py
File metadata and controls
297 lines (227 loc) · 7.09 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
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# def hello(x):
# print('hello world')
# print(x)
# # inbilt function
# print('hello')
# hello(10)
"""Divisibility Checker"""
def Divisibilty_Check():
a=1
while a!=0:
x = int(input("Enter a first number:"))
y = int(input("Enter a second number:"))
if x//y == x/y:
print(f"The {x} is dividable by {y}.")
else:
print(f"The {x} is not dividable by {y}.")
a = int(input("\nEnter 0 to end program:\nEnter 1 to run again program:\n"))
else:
print("Program ended.")
"""marks to grade converter"""
def Result():
marks = float(input("Enter your marks:"))
if 100<marks:
print("Enter marks between 0 and 100")
elif 100>=marks>80:
print("A")
elif marks>60:
print("B")
elif marks>40:
print("C")
elif marks>=35:
print("D")
elif 0<=marks<35:
print("F")
elif marks<0:
print("Enter marks between 0 and 100")
"""Comparing values"""
def Compare_value():
a = float(input("Enter the value of A:"))
b = float(input("Enter the value of B:"))
print("A is equal to B" if a==b else "A is greater than B"if a>b else "B is greater than A")
"""Odd even"""
def odd_even():
number = int(input("Enter any number:"))
if number%2==0:
print("The given number is Even.")
else:
print("The given number is Odd.")
"""Phibonachi sequence"""
"""method-1"""
def Phibonachi():
a, b = 0, 1
n = int(input("enter the number: "))
for i in range(n):
print(a)
a, b = b, a + b
"""method-2"""
# def fibonachi(n):
# if n <= 0:
# return 0
# elif n = 1:
# return 1
# else:
# return fibonachi(n-1)+fibonachi(n-2)
# # Example: Print first 10 Fibonacci numbers
# for i in range(10):
# print(fibonacci(i), end=" ")
# A=int(input("print 1 to run Divisibilty_Check() program.\nprint 2 to run Result() program.\nprint 3 to run Compare_value().\nprint 4 to run odd_even() program.\nprint 5 to Phibonachi() program.:\n"))
# if A == 1:
# Divisibilty_Check()
# elif A==2:
# Result()
# elif A==3:
# Compare_value()
# elif A==4:
# odd_even()
# elif A==5:
# Phibonachi()
# num =5
# def hellos():
# print(num)
# hellos()
# print(num)
# x = [1,2,-1,-4,6.5,-23,-2.3]
# for i in x:
# if i<0:
# print(i)
# name = ["jay","jay shah","patel jay"]
# for i in name:
# if len(i)==3:
# print(i)
"""is_prime()"""
# def is_prime(n):
# if n in [2, 3]:
# return True
# if (n == 1) or (n % 2 == 0):
# return False
# r = 3
# while r * r <= n:
# if n % r == 0:
# return False
# r += 2
# return True
# n=int(input("Enter any number to if it is prime or not:"))
# print(is_prime(n))
"""*args for variable number of arguments"""
# def myFun(*argv):
# for arg in argv:
# print(arg)
# myFun('Hello', 'Welcome', 'to', 'GeeksforGeeks')
"""lamba function"""
# x = lambda y:(y*2,y+4,y%4)
# print(x(20))
# Kdot = lambda x,b,c,d:(x+b,x-c,x**d,c//d,b/x,d*b)
# print(Kdot(5,6,7,8))
# x = lambda a,b,c,d:(a+1,b+c*a,b%d,a-c)
# print(x(4,56,23,12))
# def myfunctionb(shanu,virani):
# return lambda s:(s*shanu,s+virani)
# TG = myfunctionb(10,9)
# print(TG(115))
# def myfunc(x,y):
# return lambda fun_1 :(fun_1*x,fun_1/y)
# Object_1 = myfunc(2,3)
# print(Object_1(10))
# def mydata(Djengo,panda,syntex):
# return lambda y,h,c: (Djengo+y, panda*h, syntex-c)
# hii = mydata(1.2,1.3,1.4)
# TG = mydata(1,2,3)
# print(TG(1.2,1.3,1.4))
# print(hii(20,30,40))
#array
# import array
# from array import *
# value = array('i',[1,2,3,4,5,6,7])
# print(value)
# print(value.buffer_info())
# print(value.typecode)
# print(value[3])
# def is_palindrome(s):
# s = s.lower()
# left = 0
# right = len(s) - 1
# while left < right:
# if s[left] != s[right]:
# return False
# left += 1
# right -= 1
# return True
# input_string = input("Enter a string: ")
# if is_palindrome(input_string):
# print(f'"{input_string}" is a palindrome!')
# else:
# print(f'"{input_string}" is not a palindrome.')
"""KBC"""
# qestions = [
# [
# "Which language was used to create fb?", "Python","none", "French", "JavaScript","d"
# ],
# [
# "India Prime minister name?", "Modi", "Rahul", "none","Jay","d"
# ],
# [
# "Surat kesa city he", "Smart", "Cleane", "Green","none","a"
# ],
# [
# "Apdi Company kevi che?", "Gosod", "V.Good", "Bed","none","c"
# ],
# ]
# levels = [1000,2000,3000,5000,10000,20000,40000,80000,160000,3200000]
# money = 0
# for i in range(0,len(qestions)):
# qestion = qestions[i]
# print(f"Qestions for Rs.{levels[i]} is {qestions[i][0]}")
# print(f"a. {qestions[i][1]} b.{qestions[i][2]}")
# print(f"c. {qestions[i][3]} d.{qestions[i][4]}")
# reply = str(input("Enter your answer:"))
# if(reply == qestions[i][5]):
# print(f"Correct answear, you have win Rs.{levels[i]}")
# else:
# print("Wrong answer!")
# break
"""Guessing game"""
# import random
# def guessing_game():
# # Randomly generate a number between 1 and 100
# number_to_guess = random.randint(1, 100)
# # Set the maximum number of attempts
# max_attempts = 10
# attempts_left = max_attempts
# print("Welcome to the Guessing Game!")
# print("I'm thinking of a number between 1 and 100.")
# print(f"You have {max_attempts} attempts to guess the number.")
# # Start the guessing loop
# while attempts_left > 0:
# guess = int(input(f"\nYou have {attempts_left} attempts left. Enter your guess: "))
# # Check if the guess is correct
# if guess == number_to_guess:
# print("Congratulations! You guessed the number correctly!")
# break
# # Provide hints for high or low guesses
# if guess < number_to_guess:
# print("Too low!")
# else:
# print("Too high!")
# # Offer additional hints based on how close the guess is
# if attempts_left <= 5: # Give closer hints after 5 attempts
# difference = abs(number_to_guess - guess)
# if difference <= 10:
# print("You're within 10 of the number!")
# if difference <= 5:
# print("You're very close! Within 5 of the number!")
# attempts_left -= 1
# # If the player runs out of attempts
# if attempts_left == 0:
# print(f"Sorry, you're out of attempts. The number was {number_to_guess}.")
# # Run the game
# guessing_game()
# import qrcode
# x = qrcode.make("https://monkeytype.com/")
# x.save('1.png')
"""1 link = 10 qrcode"""
# import qrcode
# x = qrcode.make("https://www.w3schools.com/python/trypython.asp")
# a=1
# for a in range (1,11):
# x.save(f'a{a}.png')