|
| 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') |
0 commit comments