-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctions.py
More file actions
50 lines (35 loc) · 778 Bytes
/
functions.py
File metadata and controls
50 lines (35 loc) · 778 Bytes
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
# def functionName(arguments):
# code
# return value
import math
def hello():
print('hello')
def helloWorld():
print('hello world')
def addition(a, b):
print(a + b)
# shadows the global a
a = 20
def multiplication(a, b, c):
print(a * b * c)
def factorial(number):
result = 1
for i in range(1, number + 1):
result *= i
return result
def permutation(n, r): # nPr
return factorial(n) / factorial(n - r)
def combination(n, r): # nCr
return permutation(n, r) / factorial(r)
# global
a = 10
val = factorial(4)
# f(g(x))
print(factorial(9))
print(permutation(3, 2))
print(combination(3, 3))
print(sum([1, 2, 3, 9.3, -4]))
print(max([100, 200, -67]))
print(abs(45))
print(bool('d'))
print(math.factorial(110))