This new section will go over my Python knowledge from 2021 onward:
This section was last updated on 2021, Tuesday, October 5th at 12:22 am
print("Break")
break
(i) this is newer knowledge from 2021..
This section was last updated on 2021, Tuesday, October 5th at 1:03 pm
This section goes over my prior knowledge of Python (before the year 2020)
print ("Hello world")
Here is a version more suitable for displaying the message for more than 0.01 seconds:
print ("Hello world")
noMore = input("Press [ENTER] key to continue")
This section was last updated on 2021, Tuesday, October 5th at 12:20 am
def functionOne():
print ("Function one")
x = int(2)
y = int(16)
print (x ** y)
# Main thread
return functionOne()
This should output:
Function one
65536
This section was last updated on 2021, Tuesday, October 5th at 12:21 am
list123 = ["1", "2", "3"]
print (str(list123))
noMore = input("Press [ENTER] key to quit")
(i) This example may have problems.
This section was last updated on 2021, Tuesday, October 5th at 1:09 pm
array2D = ["entry1", "entry2", "entry3"]
print (str(array2D))
noMore = input("Press [ENTER] key to quit")
(i) This example may have problems.
This section was last updated on 2021, Tuesday, October 5th at 1:08 pm
strInput = str(input("String input: "))
print ("You typed: " + str(strInput))
intInput = int(input("Integer input (enter a number): "))
print ("You typed: " + str(intInput))
miscInput = input("Miscellaneous input (enter anything): "))
print ("You typed: " + str(miscInput))
noMore = input("Press [ENTER] key to quit")
# Can booleans be an input value?
This section was last updated on 2021, Tuesday, October 5th at 1:07 pm
x = int(2)
p = float(3.14)
print (x + " " + p)
noMore = input("Press [ENTER] key to quit")
This section was last updated on 2021, Tuesday, October 5th at 1:02 pm
trueFalse = bool(true)
falseTrue = bool("false")
This section was last updated on 2021, Tuesday, October 5th at 1:02 pm
This section was last updated on 2021, Tuesday, October 5th at 12:22 am
print("Break")
break
(i) this is newer knowledge from 2021. It should be moved out of this section.
This section was last updated on 2021, Tuesday, October 5th at 1:03 pm
inputLowercase = str(input("Enter something with at least 1 lowercase letter: "))
inputLowercase == inputLowercase.upper()
print ("Uppercase: " + str(inputLowercase))
noMore = input("Press [ENTER] key to quit")
This section was last updated on 2021, Tuesday, October 5th at 1:05 pm
inputELF = str(input("Do you like Python (y/N)"))
inputELF == inputELF.upper()
if (inputELF == "Y" or "YES"):
print ("HE IS THE MESSIAH!")
elif (inputELF == "N" or "NO"):
print ("sssssssssssssssss")
else:
print ("Invalid input. Please enter Y, YES, N, or NO")
noMore = input("Press [ENTER] key to quit")
This section was last updated on 2021, Tuesday, October 5th at 1:12 pm
input1 = str(input("Do you like Python (y/N)"))
input1 == input1.upper()
if (input1 == "Y" or "YES"):
print ("HE IS THE MESSIAH!")
else:
print ("ssssssssssssssssss")
noMore = input("Press [ENTER] key to quit")
This section was last updated on 2021, Tuesday, October 5th at 1:13 am
stringy = str(input("Enter some text: "))
print (str(stringy))
noMore = input("Press [ENTER] key to quit")
This section was last updated on 2021, Tuesday, October 5th at 1:14 pm
con1 = str(input("Enter a name: "))
cat2 = int(input("Enter an age: "))
ena3 = str(input("Enter a fruit: "))
tion = float(input("Enter the first 3 numbers of Pi with a decimal: "))
print ("Your name is " + str(con1)) + " and you just turned " + str(cat2) + " years old. You wanted to stop aging, you so ate a magical " + str(ena3) + " and now Pi is ready: " + str(tion))
noMore = input("Press [ENTER] key to quit")
This section was last updated on 2021, Tuesday, October 5th at 1:17 pm
This section was last updated on 2021, Tuesday, October 5th at 12:23 am
xwhile = int(0)
while (x == 0):
print ("Recursion")
stop1 = int(input("Enter the answer to the universe to stop the loop: "))
if (stop1 == 42):
xwhile == 1
else:
print ("Wrong answer. The recursion continues")
print ("You now hold the secret to the universe")
noMore = input("Press [ENTER] key to quit")
This section was last updated on 2021, Tuesday, October 5th at 1:20 pm
ra = str("ra")
for x in range(1, 2):
print (str(ra))
print ("Rasputin")
noMore = input("Press [ENTER] key to quit")
This section was last updated on 2021, Tuesday, October 5th at 1:21 pm
import random
randomNum = random(randint(0, 9))
print ("The randomizer chose: " + str(randomNum))
noMore = input("Press [ENTER] key to quit")
(i) This example may have problems.
This section was last updated on 2021, Tuesday, October 5th at 1:23 pm
This section was last updated on 2021, Tuesday, October 5th at 12:24 am
f = open("test.txt", "a")
f.write("This is a test file")
f.close()
This section was last updated on 2021, Tuesday, October 5th at 1:30 pm
# open and read the file
f = open("test.txt", "r")
print(f.read())
This section was last updated on 2021, Tuesday, October 5th at 1:32 pm
class computerScience2018():
print ("In 2018, I began learning Python in computer science class")
noMore = input("Press [ENTER] key to quit")
This section was last updated on 2021, Tuesday, October 5th at 1:24 pm
def object1():
print ("Block")
bblock = int(4)
print (str(bblock) + " sides")
return object1()
This section was last updated on 2021, Tuesday, October 5th at 1:34 pm
def object2():
print ("Triangle")
btri = int(3)
print (str(btri) + " sides")
object2()
This section was last updated on 2021, Tuesday, October 5th at 1:35 pm
a = int(input("Addition calculator:\nEnter the first number: "))
b = int(input("Num2: "))
c = int(input("Num3: "))
sum = int(a + b + c)
print ("Sum (answer): " + str(sum))
noMore = input("Press [ENTER] key to quit")
This section was last updated on 2021, Tuesday, October 5th at 1:37 pm
sfxIO = bool(true)
musicIO = bool(true)
print ("Audio settings:\n")
sfxC = str(input("Sound effects (y/N))
sfxC == sfxC.upper()
if (sfxC == "Y" or "YES"):
sfxIO == bool(true)
else:
sfxIO == bool(false)
musicC = str(input("Music (y/N))
musicC == musicC.upper()
if (musicC == "Y" or "YES"):
musicIO == bool(true)
else:
musicIO == bool(false)
noMore = input("Press [ENTER] key to quit")
This section was last updated on 2021, Tuesday, October 5th at 1:40 pm
This section was last updated on 2021, Tuesday, October 5th at 12:26 am
print ("The names text\n\n\n\n\n\nBottom text")
noMore = input("Press [ENTER] key to quit")
This section was last updated on 2021, Tuesday, October 5th at 1:25 pm
print ("Tabby\tLikes\tTo\tTab")
noMore = input("Press [ENTER] key to quit")
This section was last updated on 2021, Tuesday, October 5th at 1:25 pm
# 2 to the power of 16
x = int(2)
y = int(16)
z = int(x ** y)
print ("2^16 == " + str(z))
noMore = input("Press [ENTER] key to quit")
This section was last updated on 2021, Tuesday, October 5th at 1:26 pm
This section was last updated on 2021, Tuesday, October 5th at 12:27 am
This example will throw an error, as x is not defined.
try:
print(x)
except:
print("An exception occurred")
This example will NOT throw an error, as x IS defined.
x = int(1)
try:
print(x)
except:
print("An exception occurred")
This section was last updated on 2021, Tuesday, October 5th at 1:48 pm
This example will throw an error, as x is not defined.
try:
print(x)
except:
print("An exception occurred")
This example will NOT throw an error, as x IS defined.
x = int(1)
try:
print(x)
except:
print("An exception occurred")
This section was last updated on 2021, Tuesday, October 5th at 1:48 pm
This section was last updated on 2021, Tuesday, October 5th at 12:27 am
# This is a single line comment
This section was last updated on 2021, Tuesday, October 5th at 1:27 pm
''' Block comment A
This is a block comment
'''
""" Block comment B
Block comments can also be written like this.
"""
This section was last updated on 2021, Tuesday, October 5th at 1:27 pm
about:unknown$notFound
This section was last updated on 2021, Tuesday, October 5th at 12:24 am
More examples coming soon.