Skip to content

Commit 3edb8f4

Browse files
Add files via upload
1 parent dfdbb14 commit 3edb8f4

27 files changed

+3398
-968
lines changed

2d lists.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# A 2d list is a two dimensional array that can hold multiple
33
# 2d list array values under a single variable. For example:
44

5+
# HIGHLIGHT AND COPY CODE, THEN PASTE INTO YOUR PREFERABLE PYTHON APP/IDLE
6+
57
my_2d_list=['2d list0'],['2d list0']
68

79
print(my_2d_list[0][0])

Abstract Python Examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ def __init__(self):
11801180
# Here is a basic, skeletal structure of a Try: and Except: block.
11811181
# The 'Pass' statement ignores any empty code blocks, which are
11821182
# not used for now. In this case, only the skeletal structure of the
1183-
# program is clearly shown. Note: you do not need to invoke the
1183+
# program is clearly shown. Note: you do not need to invoke the
11841184
# 'finally' statement into try: and Except: blocks, but they can be
11851185
# quite handy when you want to show any output on the screen,
11861186
# no matter the outcome of the program's execution/run.

Args and Kwargs.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
'''
2+
Let's learn what *args are all about. The word 'args' simply means the word
3+
'arguments' for short. One asterisk * is used for *args. Use *args when you
4+
don't know how many argument variables you want within your define function
5+
parameters. Note: you do not need to call the word '*args' as args. However,
6+
you will need to invoke the asterisk * to make *args work. Programmers
7+
know the word as *args by standard definition, but you can use your own words.
8+
'''
9+
# HIGHLIGHT AND COPY CODE, THEN PASTE INTO YOUR PREFERABLE PYTHON APP/IDLE
10+
11+
def book(*args): # one argument variable
12+
print('Python Programmer\'s Glossary Bible\nby Joseph C. Richardson')
13+
14+
book('unknown number of argument values.','add another unknown argument value.') # two argument values
15+
16+
# Create your own *args function parameter variable as shown below.
17+
18+
def book(*my_unknown_num_arguments): # one argument variable
19+
print('Python Programmer\'s Glossary Bible\nby Joseph C. Richardson')
20+
21+
book('unknown number of argument values.','add another unknown argument value.') # two argument values
22+
'''
23+
As shown in the other define function() examples above, how we needed the exact
24+
number of argument values to the exact number of argument variables. However,
25+
with *args you no longer have to worry about how many argument values you will
26+
need to satisfy the number of argument variables within the define function parameters.
27+
'''
28+
# Let's do some more *args with return functions
29+
30+
def book(*args): # one argumant variable
31+
return 'Python Programmer\'s Glossary Bible'
32+
33+
print(book('by Joseph C. Richardson','add another unknown argument value.')) # two argument values
34+
35+
def nums(*args): # one argument variable
36+
return args
37+
38+
print(nums(2,3)) # two argument values
39+
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
40+
'''
41+
Let's learn what **kwargs are all about. The word 'kwargs' simply means the words
42+
'keyword arguments' for short. Two asterisks ** are used for **kwargs. Use **kwargs
43+
when you don't know how many keyword argument variables you want within your
44+
define function parameters. Note: you do not need to call the word '**kwargs' as kwargs.
45+
However, you will need to invoke two asterisks ** to make **kwargs work. Programmers
46+
know the word as **kwargs by standard definition, but you can use your own words.
47+
'''
48+
def book(**kwargs): # one keyword argument variable
49+
print('Python Programmer\'s Glossary Bible\nby Joseph C. Richardson')
50+
51+
book(keyword='keyword',argument='argument') # two keyword argument values
52+
53+
# This example is without any **kwargs at all; we have to name our keyword arguments.
54+
55+
def book(keyword_arg1,keyword_arg2): # two keyword argument variables
56+
print('Python Programmer\'s Glossary Bible\nby Joseph C. Richardson')
57+
58+
book(keyword_arg1='keyword',keyword_arg2='argument') # two keyword argument values
59+
'''
60+
As shown in the define function() example above, how we needed the exact number of keyword
61+
argument values to the exact number of keyword argument variables. However, with **kwargs
62+
you no longer have to worry about how many keyword argument values you will need to satisfy
63+
the number of keyword argument variables within the define function parameters.
64+
'''
65+
# Let's create some define functions that act like subroutines.
66+
'''
67+
Since there are no line numbers in Python, also means that we cannot create any such 'go to',
68+
or 'go sub' commands at all with Python. So how can we create subroutines with Python?. How
69+
can we create subroutines without making them jump to line numbers, like we did in the old days?
70+
Well the answer is quite simple. Let's use define functions() with a while loop to create our subroutine
71+
examples.
72+
'''
73+
def subroutine1():
74+
print('You picked subroutine1')
75+
76+
def subroutine2():
77+
print('You picked subroutine2')
78+
79+
def subroutine3():
80+
print('You picked subroutine3')
81+
82+
while True:
83+
message=input('Please type 1, 2 or 3 to select the subroutine you wish to \
84+
display or type (q) to quit: ').strip()
85+
86+
if message=='q':
87+
break
88+
while True:
89+
if message=='1':
90+
subroutine1()
91+
break
92+
elif message=='2':
93+
subroutine2()
94+
break
95+
elif message=='3':
96+
subroutine3()
97+
break
98+
else:
99+
print('Sorry! No subroutine for that.')
100+
break
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# ASCII CODE TRANSLATOR Python program example.
2+
3+
# Created by Joseph C. Richardson, GitHub.com
4+
5+
# Note: you must execute/run the program from
6+
# the OS output screen, via double-clicking the Python
7+
# program file itself.
8+
9+
# HIGHLIGHT AND COPY CODE, THEN PASTE INTO YOUR PREFERABLE PYTHON APP/IDLE
10+
11+
import os,math
12+
13+
text_features=(
14+
'cls', # index 0 = clear screen
15+
'\x1b[31m', # index 1 = red
16+
'\x1b[32m', # index 2 = green
17+
'\x1b[33m', # index 3 = yellow
18+
'\x1b[34m', # index 4 = blue
19+
'\x1b[37m' # index 5 = red
20+
)
21+
22+
text_words=(
23+
f'\n{text_features[3]}ASCII CODE NUMERIC VALUE TRANSLATOR\n', # index 0 = text_words
24+
25+
f'\n{text_features[3]}ASCII CODE CHARACTER VALUE TRANSLATOR\n', # index 1 = text_words
26+
27+
f'\n{text_features[3]}ASCII CODE TRANSLATOR', # index 2 = text_words
28+
29+
f'\n{text_features[3]}Thanks for choosing ASCII CODE TRANSLATOR', # index 3 = text_words
30+
31+
'title ASCII CODE TRANSLATOR' # index 4 = text_words
32+
)
33+
34+
word_info=(
35+
f'{text_features[5]}Please type a number, then press \
36+
(Enter) to confirm:{text_features[2]}', # index 0 = word_info
37+
38+
f'{text_features[5]}Please type a letter key or a number key, then press \
39+
(Enter) to confirm:{text_features[2]}', # index 1 = word_info
40+
41+
f'\n{text_features[3]}Please choose which ASCII code translator you \
42+
would like to use:\n\n{text_features[5]}Press (1) for ASCII code number \
43+
values.\nPress (2) for ASCII code character values.\nPress \
44+
(Q) to quit.{text_features[2]} ', # index 2 = word_info
45+
46+
f'\n\n{text_features[3]}Do you wish to continue? Press \
47+
(Enter) or press (Q) to quit:{text_features[2]}', # index 3 = word_info
48+
49+
f'\n{text_features[1]}This is a Value Error!', # index 4 = word_info
50+
51+
f'\n{text_features[1]}This is a Type Error!' # index 5 = word_info
52+
)
53+
54+
button=('1','2','q')
55+
56+
def ascii_codes():
57+
os.system(text_words[4])
58+
def subroutine1():
59+
while True:
60+
os.system(text_features[0])
61+
print(text_words[0])
62+
63+
try:
64+
ascii_code=int(input(word_info[0]).strip())
65+
ascii_code=input(f'\n{text_features[2]}{chr(ascii_code)}\
66+
{text_features[5]} = ASCII code: " {text_features[2]}{ascii_code}\
67+
{text_features[5]} " {word_info[3]}').lower().lower().strip()
68+
if ascii_code==button[2]:
69+
break
70+
71+
except ValueError:
72+
print(word_info[4])
73+
time.sleep(2)
74+
75+
def subroutine2():
76+
while True:
77+
os.system(text_features[0])
78+
print(text_words[1])
79+
80+
try:
81+
ascii_code=input(word_info[1]).strip()
82+
ascii_code=input(f'\n{text_features[2]}{ascii_code}\
83+
{text_features[5]} = ASCII code: " {text_features[2]}{ord(ascii_code)}\
84+
{text_features[5]} " {word_info[3]}').lower().strip()
85+
if ascii_code==button[2]:
86+
break
87+
88+
except TypeError:
89+
print(word_info[5])
90+
time.sleep(2)
91+
92+
while True:
93+
os.system(text_features[0])
94+
print(text_words[2])
95+
96+
butt=input(word_info[2]).lower().strip()
97+
if butt==button[0]:
98+
subroutine1()
99+
elif butt==button[1]:
100+
subroutine2()
101+
102+
else:
103+
if butt==button[2]:
104+
os.system(text_features[0])
105+
print(text_words[3])
106+
time.sleep(3)
107+
break
108+
109+
ascii_codes()

Ascii the Evil Fox.py

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,44 @@
1-
# Look what I did by accident. I then created this
2-
# spooky Python program example.
1+
# Try this Bone Chilling Ascii Code Python Program Example if You Dare!
2+
'''
3+
This is my uncut version of this scary, spooky Python program example, which this video does not
4+
show in it. Had I created and launched it on Halloween, I would have done such an uncut version
5+
like this Python program example shows. However, I couldn't let December, Friday the 13'th go by
6+
and by accident, I created one of my Minute Python videos #13 was the unlucky, but lucky enough
7+
number, that I didn't realize what I had done, until after I launched it up on YouTube that day.
8+
9+
I was simply bored right out of my skull, when I created the Devil's Python program example. Mind
10+
you, it did scare me to want to even try to think of things like this up. But sometimes, my mind
11+
takes me to such wonderous and scary things in me, that I cannot seem to ignore them at all. Yet,
12+
having Asperger's, I'm often more fearful of people than I am with a Manmade God or a Manmade Devil,
13+
which I do not believe in such things at all. Mankind is simply both of these things inside us all.
14+
The only thing is, which voice within you do you want to listen to. Good, or Evil? We are BOTH.
15+
One cannot live without the other, but the betterment of the two will always prevail as long as we
16+
want to survive as a species as a whole.
17+
18+
The Devil once liveD. Don't livE Evil.
19+
'''
20+
# Created by Joseph C. Richardson, GitHub.com
321

422
fox=ord('f')+ord('o')+ord('x')
523

6-
print(fox*2)
24+
print(':rebmuN ykcuL s\'liveD ehT'[::-1],fox*2)
725

826
# Or this example if you like.
927

1028
fox=(ord('f')+ord('o')+ord('x'))*2
1129

12-
print(fox)
30+
print(':rebmuN ykcuL s\'liveD ehT'[::-1],fox)
31+
32+
# Here are some string concatenation examples:
33+
34+
print('livE eht iicsA morf yawa yatS'[::-1],fox,'!elpmaxE margorP nohtyP'[::-1]) # non formatted string example
35+
36+
print(' livE eht iicsA morf yawa yatS'[::-1]+str(fox)+'!elpmaxE margorP nohtyP '[::-1]) # non formatted string example
37+
38+
print(' livE eht iicsA morf yawa yatS'[::-1]+str(fox),'!elpmaxE margorP nohtyP'[::-1]) # non formatted string example
39+
40+
# Here are the old and the new Python formatted string examples
41+
42+
print('!elpmaxE margorP nohtyP {} livE eht iicsA morf yawa yatS'.format(fox)[::-1]) # old formatted string example
43+
44+
print(f'!elpmaxE margorP nohtyP {fox} livE eht iicsA morf yawa yatS'[::-1]) # new formatted string example

Auto Type Colour Effect Demo.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Auto Type Colour Effect Demo Python program example.
2+
3+
# Created by Joseph C. Richardson, GitHub.com
4+
5+
# HIGHLIGHT AND COPY CODE, THEN PASTE INTO YOUR PREFERABLE PYTHON APP/IDLE
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+
import time,os;os.system('')
11+
12+
text_colours=(
13+
'\x1b[31m', # index 0 = red
14+
'\x1b[32m', # index 1 = green
15+
'\x1b[33m', # index 2 = yellow
16+
'\x1b[34m', # index 3 = blue
17+
'\x1b[35m', # index 4 = purple
18+
'\x1b[36m', # index 5 = cyan
19+
'\x1b[37m' # index 6 = white
20+
)
21+
22+
text_words=(
23+
f'\n"Python Programmer\'s Glossary Bible" by Joseph C. Richardson','cls'
24+
)
25+
26+
length=0
27+
while length<=len(text_words[0]):
28+
for i in text_colours:
29+
print(i+text_words[0][:length])
30+
time.sleep(.05)
31+
os.system(text_words[1])
32+
length+=1
33+
34+
print(i+text_words[0])
35+
36+
input('\nPress Enter to exit.')

Auto Type Colour Effect.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# AUTO TYPE COLOUR EFECT Python program example.
2+
3+
# Created by Joseph C. Richardson, GitHub.com
4+
5+
# HIGHLIGHT AND COPY CODE, THEN PASTE INTO YOUR PREFERABLE PYTHON APP/IDLE
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+
import os,time,winsound
11+
12+
text_colours=(
13+
'\x1b[31m', # index 0 = red
14+
'\x1b[32m', # index 1 = green
15+
'\x1b[33m', # index 2 = yellow
16+
'\x1b[34m', # index 3 = blue
17+
'\x1b[35m', # index 4 = purple
18+
'\x1b[36m', # index 5 = cyan
19+
'\x1b[37m' # index 6 = white
20+
)
21+
22+
clear_screen='cls'
23+
single_line_break='\n'
24+
double_line_break='\n\n'
25+
indent=' '*2
26+
wave_sound='TYPE'
27+
28+
text_words=(
29+
f'{single_line_break}{indent}"Python Programmer\'s Glossary Bible" \
30+
{single_line_break}{indent}by Joseph C. Richardson{double_line_break}{indent}\
31+
My Python Programmer\'s Glossary Bible has everything you need to get{single_line_break}\
32+
{indent}started. Because great programming always starts with a great programmer’s\
33+
{single_line_break}{indent}manual.{double_line_break}{indent}You can find \
34+
all you need to learn about Python programming on GitHub.com{double_line_break}\
35+
{indent}While you\'re at it, why not try out all my Robomaster S1 Python program\
36+
{single_line_break}{indent}examples, including my Robomaster S1 Comes to Life Python \
37+
program exercise.{double_line_break}{indent}For those who are into the Famous \
38+
Raspberry Pi 4, I also have quite a few{single_line_break}{indent}Python program \
39+
exercises to choose from.{double_line_break}{indent}Simply visit my YouTube channel \
40+
or my GitHub.com profile page to learn{single_line_break}{indent}more. Look for username: \
41+
ROBOMASTER-S1 to get started. Let\'s get into it...',
42+
43+
f'{single_line_break}{indent}Since the age of robotics began in the early \
44+
part of the twenty-first{single_line_break}{indent}century, early roboticists had also \
45+
scrambled about the concept of what{single_line_break}{indent}a robot should be and \
46+
do predictably. However, there is one man, who{single_line_break}{indent}wanted to \
47+
clarify that fact with a bit of a different abstract approach{single_line_break}{indent}to the \
48+
concept of what a robot should be and do. His solution is to create{single_line_break}{indent}\
49+
a robot with unpredictability, via the Random Generator. While roboticists{single_line_break}\
50+
{indent}in general still hash out the same old concepts of what a robot is supposed\
51+
{single_line_break}{indent}to be and do, this one man has set a revolutionary concept of what \
52+
a robot{single_line_break}{indent}isn\'t supposed to be and do. His approach is to create a \
53+
robot that is{single_line_break}{indent}unpredictable, meaning each behavior the robot\'s \
54+
programming consists of,{single_line_break}{indent}it\'s the random generator that gives the \
55+
appearance of a real, living thing{single_line_break}{indent}that is as unpredictable as any \
56+
other real, living being alike.{double_line_break}{indent}I now bring you into the wonderful \
57+
world of robotics and computer science,{single_line_break}{indent}combined with dash of \
58+
imagination.{double_line_break}{indent}And I now welcome you to the awesome Robomaster \
59+
S1 Comes to Life concept in{single_line_break}{indent}robotics science...','cls')
60+
61+
length=0
62+
63+
while length<=len(text_words[0]):
64+
for i in text_colours:
65+
print(i+text_words[0][:length])
66+
winsound.PlaySound(wave_sound,winsound.SND_ASYNC)
67+
time.sleep(.06)
68+
os.system(text_words[2])
69+
length+=1
70+
71+
print(text_colours[6]+text_words[0]);time.sleep(3)
72+
73+
length=0
74+
75+
while length<=len(text_words[1]):
76+
print(text_colours[5]+text_words[1][:length])
77+
winsound.PlaySound(wave_sound,winsound.SND_ASYNC)
78+
time.sleep(.06)
79+
os.system(text_words[2])
80+
length+=1
81+
82+
print(text_colours[6]+text_words[1]);time.sleep(3)

0 commit comments

Comments
 (0)