-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.py
More file actions
234 lines (182 loc) · 3.74 KB
/
function.py
File metadata and controls
234 lines (182 loc) · 3.74 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
'''
def function_name ():
FUNCTION BODY
_
_
-
'''
# def display():
# print("hi")
# print("herllo")
# print("bey")
# display()
# a=10
# b=90
# sum=a+b
# display()
# def add():
# a=10
# b=90
# sum=a+b
# print(sum)
# add()
# def add():
# a=int(input("enter a no"))
# b=int(input("enter a no"))
# sum=a+b
# print('addition of no',sum)
# add()
# def f1(a,b):
# print(a+b)
# f1(10,45)
# f1(90,10)
# def f1(a,b):
# print(a+b)
# return "hello"
# print(f1(10,45))
# f1(10,90)
# """
# user define function
# parameter return
# yes yes
# no yes
# yes no
# no no
# """
# def sum():
# a= 10
# b = 20
# sum = a+b
# return sum
# sum()
# def f1(a,b):
# print(a+b)
# return "hello"
# print(f1(10,45))
# f1(10,90)
# def add(a, b):
# result = a + b
# return result
# sum = add(5, 3)
# print("Sum:", sum)
# def f1(a = 10,b = 5, c = 0):
# return a,b,c
# print(f1(10,90,))
# """"lamda function """
# multiply = lambda a,b : a*b
# print(multiply (10,6))
# def f1():
# return "hello from f1"
# def f2(n):
# print(n)
# return f1()
# print(f2(90))
# def print_numbers(n):
# if n > 10: ex of recirsion function
# return
# print(n)
# print_numbers(n + 1)
# print_numbers(1)
# def factorial(n):
# if n==1:
# return 1
# return n*factorial(n-1)
# print(factorial(5))
# def f1(n):
# count = 0
# if n ==5:
# return 0
# while n>0:
# print(n)
# count+=1
# if count ==2:
# break
# n-=1
# return f1(n+3)
# f1(3)
# def febbo(n):
# a = 0
# b = 1
# for i in range(n):
# next = a+b
# a = b
# b = next
# print(b , end = " ")
# febbo(10)
"""nested function"""
# def outer():
# def inner():
# return 10
# return inner()
# print(outer())
"""highi oerder function"""
# def operation(a,b,op):
# return op(a,b)
# def add (a,b):
# return a+b
# def sub (a,b):
# return a-b
# print(operation(90,10,sub))
"""map function"""
# data =[1,2,3,4,5]
# def square(n):
# return n*n
# new = list(map(square,data))
# print(new)
# data = list(map(int, input("Enter : ").split()))
# print(data)
"""filter function"""
# data =[12,13,57,4,3,56]
# def filter_num(n):
# return n%2==0
# new=list(filter(filter_num,data))
# print(new)
"""variable argument function"""
# # print(1,2,3,4,5,6,)
# def display(*args):
# print(args)
# print(type(args))
# display(9,2,34,45,6,7,34)
# def display(*add):
# sum =0
# for i in add:
# sum+=i
# return sum
# print(add(1,2,3,4,56,11,22,33))
# def display(*even):
# sum = 0
# for i in even:
# if i%2 ==0:
# sum +=i
# return sum
# even= int(input("enter a:"))
"""keywards argument function """
# def f1 (**kwargs):
# print(kwargs)
# print(type(kwargs))
# f1(a =10,b = 90 , c =89)
# def f1(**kwargs):
# kwargs['a']=123
# return kwargs
# print (f1(a = 10,b=90,c=89))
# n = int (input ("enter a no ."))
# if n >1 :
# for i in range (2 , n ):
# if (n%i ==0 ):
# print (n , "is not a prime no .")
# break
# else :
# print ("it is aprime no.")
# n = 4867
# while n>=10:
# add = 0
# while n > 0:
# add += n%10
# n //= 10
# n = add
# print(n)
n = 4867
d = 0
while n >= 10:
n = sum(int(d) for d in str(n))
print(n)