-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
89 lines (77 loc) · 1.53 KB
/
main.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
# 2024 may 3rd fri am 10:35 utc+09:00
# sum of evens 1 ~ 10
def sum_for(a, b):
for i in range(1, 10, 1):
if (i%2==0):
a=a+i
b=b+1
print(a, b)
sum_for(0, 0)
# sum x to 1
def sum_down(x):
total = 0
while (x>=1):
total=total+x
x=x-1
print(total)
sum_down(10)
# calculation function
def multi(c, d):
return c * d
# print function
def show(y):
print(y)
# function result
e = multi(4, 6)
show(e)
# class using
class prime:
def secondary(self, k): # sum 1 to k
j, sum = 0, 0
while(j < k):
j += 1
if (j%2==1):
continue
sum += j
return sum
def tertiary(self, l): # avg 1 to l
m, total, avg = 0, 0, 0
while(m < l+1):
total += m
m += 1
if(m == l):
avg = total / l+1
return avg
# class child using
# sum 10(a) under to k
class sub(prime):
def another(self, k):
a, sum = 10, 0
while(k < a):
a-= 1
sum += a
if (a == k):
break
return sum
class third(sub):
def more(self, z):
a, sum, avg = 0, 0, 0
while(a < z):
a+=1
sum+=a
if(a == z):
avg = sum / z
break
return avg
g = prime()
c = sub()
l = third()
q = c.secondary(10)
now = g.tertiary(10)
result = c.another(5)
averge = l.more(5)
# using print function
show(q)
show(int(now))
show(result)
show(averge)