-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
90 lines (53 loc) · 1.25 KB
/
__init__.py
File metadata and controls
90 lines (53 loc) · 1.25 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
class primes:
def listprimes(start, end = None):
L=[]
if end == None:
starting, ending = 2, start
else:
starting, ending = start, end
if start < 2:
return L
for i in range(starting, ending+1):
isprime = True
for j in range(2, round(i**0.5)+1):
if i % j == 0:
isprime = False
break
if isprime:
L.append(i)
return L
def isprime(nb):
if nb < 2:
return False
for i in range(2,round(nb**0.5)+1):
if nb % i == 0:
return False
return True
class math:
def absolute(nb):
return (-(nb*(nb<0)) + (nb*(nb>0)))
def root(nb, root = 2):
return (nb ** (1/root))
class logic:
def logicand(c1, c2):
return ((c1*c2) == 1)
def logicnand(c1, c2):
return ((c1+c2) == 0)
def logicor(c1, c2):
return ((c1+c2) >= 1)
def logicnor(c1, c2):
return((c1+c2) <= 1)
def logicxor(c1, c2):
return ((c1+c2)*(c1!=c2) == 1)
def logicnot(c):
return (c == 0)
class lists:
def show(L, mode = "vertical"):
if mode == "vertical":
ending = "\n"
elif mode == "horizontal":
ending = " "
else:
ending = mode
for i in L:
print(i, end = ending)