Skip to content

Commit 7fb23d4

Browse files
Add files via upload
1 parent a641dc8 commit 7fb23d4

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

Fibonary Bits In Action II.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
# f' string formated print() function:
43+
44+
print(f'{white}{lb}{sp*16}{title_text[0]}{lb}{red}{lb}{sp*4}{len(b)}{green}{text[0].title()}'+\
45+
f'{yellow}{b}{blue}{elb}{sp*4}{green}{red}{len(o)}{green}{text[1].title()}{yellow}'+\
46+
f'{o}{blue}{elb}{sp*4}{green}{red}{len(x)}{green}{text[2].title()}{yellow}{x}'+\
47+
f'{blue}{eq}{green}{lb}{sp*4}{red}{len(d)}{green}{text[3].title()}{blue}{eq}{yellow}'+\
48+
f'{d}{lbb}{white}{sp*11}{title_text[1]}{lbb}{green}{sp*4}{text[4]}{yellow}{num3:,}')
49+
delay(pause)

0 commit comments

Comments
 (0)