Skip to content

Commit 0fc73e7

Browse files
Add files via upload
1 parent 79f8997 commit 0fc73e7

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

Fibonacci Natural Numbers.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Type and execute/run the Fibonacci Natural Number
2+
# Sequence program or just simply enjoy this Python
3+
# program example instead. Note: you must execute/run
4+
# this program example, via double-clicking on this Python
5+
# file itself to be able to see all the cool coloured text.
6+
# Also note: Python Idle was used to create this Python
7+
# Program Example:
8+
9+
import os,math,time,winsound
10+
11+
os.system(f'title Fibonacci Natural Number Sequence')
12+
13+
text_colours=(
14+
'\x1b[31m', # index 0 = red
15+
'\x1b[32m', # index 1 = green
16+
'\x1b[33m', # index 2 = yellow
17+
'\x1b[34m', # index 3 = blue
18+
'\x1b[35m', # index 4 = purple
19+
'\x1b[36m', # index 5 = cyan
20+
'\x1b[37m' # index 6 = white
21+
)
22+
23+
text_words=(
24+
f'{text_colours[1]}Fibonacci Natural Number Sequence in Action...',
25+
26+
f'\n\n{text_colours[2]}Fibonacci Natural Number Sequence example: \
27+
[0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610...]',
28+
29+
f'\n\n{text_colours[5]}Fibonacci Natural Numbers go on forever!',
30+
f'\n\nFibonacci Natural Numbers can only be found in \
31+
nature, such as plants and animals...'
32+
)
33+
34+
sounds=('Ring03','Speech Off')
35+
36+
winsound.PlaySound(sounds[0],winsound.SND_ASYNC)
37+
38+
for i in range(25):
39+
print('\n',' '*i,text_words[0])
40+
time.sleep(.25)
41+
os.system('cls')
42+
43+
num1=0
44+
num2=1
45+
fib=[num1,num2]
46+
47+
while True:
48+
num3=num1+num2
49+
fib.append(num3)
50+
num1=num2
51+
num2=num3
52+
clock=(time.asctime())
53+
54+
print('\n',' '*25,text_words[0],text_words[1],text_words[2])
55+
56+
print(f'\nFibonacci Natural Number Sequence: {text_colours[2]}\
57+
{num1} {text_colours[5]}+ {text_colours[2]}{num2}{text_colours[5]} = \
58+
({text_colours[0]}{num1+num3}{text_colours[5]}){text_colours[5]}\n\n\
59+
Fibonacci Natural Numbers: "{text_colours[0]}{num1+num3:,}{text_colours[5]}\
60+
"\n\n{text_colours[0]}Date & Time:\n\n{clock}')
61+
62+
winsound.PlaySound(sounds[1],winsound.SND_ALIAS)
63+
os.system('cls')

Fibonary Bits In Action.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This is for advanced Python programmers, who want something a little bit saltier.
2+
# Create this Fibonary Bits In Action! Python program using a single print() function.
3+
# Use the backslash '\' to create line breaks within the print() function.
4+
5+
# Type and execute/run this Python program example below and see what happens.
6+
7+
# Note: after you save your file, you must double click this file to view it's cool coloured
8+
# text and layout.
9+
10+
# Created by Joseph C. Richardson
11+
12+
import os;os.system('title fibonary bits in action!'.title())
13+
from time import sleep as delay
14+
15+
red='\x1b[31m'
16+
green='\x1b[32m'
17+
blue='\x1b[34m'
18+
yellow='\x1b[33m'
19+
purple='\x1b[35m'
20+
white='\x1b[37m'
21+
22+
title_text=f'fibonary bits in action!'.title(),'fibonacci natural number sequence'.title()
23+
text=('binary digits: ','octal digits: ','hexadecimal digits: ','decimal digits: ',
24+
'fibonacci digits: '.title())
25+
26+
lb='\n';lbb='\n\n';elb='=\n';eq='=';sp=' '
27+
28+
num1=0;num2=1
29+
fib=[num1,num2]
30+
31+
pause=1
32+
33+
while True:
34+
os.system('cls')
35+
num3=num1+num2
36+
fib.append(num3)
37+
num1=num2;num2=num3
38+
39+
b=f'{num3:b}';o=f'{num3:o}'
40+
x=f'{num3:X}';d=f'{num3:d}'
41+
42+
print(white+lb+sp*16+title_text[0],lb+red,lb,sp*2,len(b),green+text[0].title()+\
43+
yellow+b+blue,elb,sp*2+green+red,len(o),green+text[1].title()+yellow+\
44+
o+blue,elb,sp*2+green+red,len(x),green+text[2].title()+yellow+x+\
45+
blue,eq,green,lb,sp*2+red,len(d),green+text[3].title()+blue+eq,yellow+\
46+
d+lbb+white+sp*11+title_text[1]+lbb+green+sp*4+text[4]+yellow+f'{num3:,}')
47+
delay(pause)

0 commit comments

Comments
 (0)