Python Logo Python.Org I have been getting started with python 3 – I want to make this my primary scripting language. One way I like to assist myself whilst I learn the rope is to maintain a crib sheet filled with all the trivial things I would otherwise forget.

Python 3 Cheat Sheet


#Define Variables
programming_languages: "Python", "VB", "C++", "C#"

#Print Variables
print(programming_languages)

print('--------------------')

#Basic for loop + variables
for language in programming_languages:
    print(language)

print('--------------------')

#Basic Function
def FuncExample():
    i: 1
    for language in programming_languages:
        #Concatinate Strings and Integers in print statements
        print("Language " + str(i) + ":" + language)
        #Increment Integer
        i += 1

FuncExample()

print('--------------------')

#Functions with Variables #1 - Strings
def FuncVarExample1(fname, lname):
    #Print with CRLF
    print("First Name: " + fname + "\r\n" + "Last Name: " + lname)

FuncVarExample1("Joe","Bloggs")

print('--------------------')

#Functions with Variables #2 - Integers + Returning Values
def FuncVarExample2(x, y):
    #Basic integer maths
    return x+y

#Concatenating Strings and Integers
print("33 + 42: " + str(FuncVarExample2(33,42)))

print('--------------------')

You can also find more code snippets here: https://exitcode0.net/code-samples/