-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathwelcome.py
60 lines (55 loc) · 1.82 KB
/
welcome.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
#!/usr/bin/env python3
import math
# l33t ascii art :)
MH_ASCII_ART = '''
....... ......
`kKXXXX0: cKXXXXKx.
:NMMMMMWo .xMMMMMMK:
:NMMMMMWo .xMMMMMMK:
:NMMMMMWo .xMMMMMMK:
:NMMMMMWo .xMMMMMMK:
:NMMMMMWo .xMMMMMMK:
:NMMMMMWo .xMMMMMMK:
:NMMMMMWo .xMMMMMMK:
:NMMMMMWo .xMMMMMMX: ....
:NMMMMMM0l:::::,,,:kK00Okxo:````.
...``l0K0Okxxdolc:::,``....
..``......
....``,::clll:````.
....`,:::clol:,::ccclokXWWMMMMX:
.`````oXWWMMMWx. .kMMMMMMK,
:XMMMMMWo .xMMMMMMK:
:NMMMMMWo .xMMMMMMK:
:NMMMMMWo .xMMMMMMK:
:NMMMMMWo .xMMMMMMK:
:NMMMMMWo .xMMMMMMK:
:NMMMMMWo .xMMMMMMK,
:NMMMMMWo .xMMMMMMK:
:XMMMMMWl .dWMMMMMK,
.:lllll:. .cllllc,
'''
def fib(n: int):
"""Calculate the nth Fibonacci number.
Uses Binet's Formula!
Args:
n (int): nth number
"""
numerator = math.pow(1 + math.sqrt(5), n) - math.pow(1 - math.sqrt(5), n)
denom = math.sqrt(5) * math.pow(2,n)
return round(numerator / denom)
def is_even(n: int):
"""Print whether n is even or not."""
if n % 2:
return 'not even :('
return 'EVEN!'
print(MH_ASCII_ART)
print('Hello from Michigan Hackers!')
print('Learn more: https://www.youtube.com/watch?v=dQw4w9WgXcQ')
num1 = int(input("input your 1st favorite number: "))
num2 = int(input("input your 2nd favorite number: "))
print('Doing some math...')
print(f'fib({num1}) = {fib(num1)}')
print(f'fib({num2}) = {fib(num2)}')
print('The magical numbers 6 and 42 are... EVEN!')
num3 = int(input('Give me another number and I will tell you if it is even: '))
print(f'{num3} is... {is_even(num3)}')