Python 3 basics

revised due to me forgetting to add branching and if statements. probably add more stuff in the future.

I first want to start off by this post is more of a reminder for myself, than a tutorial. I like to plan just in case for whatever reason, I forget how python works, I want to have a reference for me, by me. It doesn’t have to make sense to you but whatever. Take it or leave it.

I will also include a link to an online compiler. I am sure that there are libraries for me to use that can create an online compiler, or if not, since this website is powered by WordPress, and Minimally python, I’ll figure something out and update the post if no other solution is added to this blog page.

below is a sample from a python script, ran in PHP to be output in a WordPress shortcode, thus a successful integration of python3 into a WordPress shortcode being utilized as a display end for python3. Youtube-dl is a python library. This is proof of python being called from WordPress PHP.

[debug] System config: []

[debug] User config: []

[debug] Custom config: []

[debug] Command-line args: ['-v', '', '-o', 'bidenisaracist.mp4']

[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8

[debug] youtube-dl version 2021.06.06

[debug] Python version 3.8.5 (CPython) - Linux-5.10.123-xeon-hst-x86_64-with-glibc2.17

[debug] exe versions: ffmpeg 4.4.1-static, ffprobe 3.3.1-static

[debug] Proxy map: {}

[BitChute] VOukLYqQLOtp: Downloading webpage

[BitChute] VOukLYqQLOtp: Checking video URL

[debug] Default format spec: bestvideo+bestaudio/best

[debug] Invoking downloader on ''

[download] bidenisaracist.mp4 has already been downloaded

[download] 100% of 254.06MiB


You Dun’ Fked up naow!

type in the box print('racist liberals') and click the compile button

too lazy to work on security for ide so doing kode from

if you did it right, the output should be “racist liberals”. see?

Try out to your heart’s content

see? it’s easy to get started with python.

Now. Onto the hard part.

Setting up python

Now, to get python on your computer, you will need to go to the python website and download it. You could also download pydroid 3 from the google play store on android phones, and also use that.

If you have a windows computer, you would download the exe or MSI file, and run it. Follow the instructions and after it says it installed successfully, you can run python, or use the companion ide (IDLE I think it’s called.) or use the bash shell to type it in.

If you use MacOS, since apple sucks in general (more than you think, less than it should), download the dmg file and follow the instructions. I ain’t doing shit about apple or anything.

If Linux is your operating system, then you chose well young padawan (star wars. It sucks now. RIP STAR WARS). But this method will be a little bit more involved. Examples will be from Linux lite os I use. It uses Debian and ubuntu so there are means of installing python. Linux comes by default with python so if you want to upgrade your python version, more or less what it involves, then this instruction set is the way to go.

Generally, you will be given the tar.xz compression file extension (.zip in windows compressed files) and will need an extraction software to open. What I did was create a program files directory to organize my software like on windows and extracted all of that there, but you can extract where you want to.

I am going to do a copy/paste of the readme.rst file that should come with it. In case for whatever reason you can’t parse it ( you can check python website, stack exchange, or even github as python is open source) so when you type in the following, you would need to use a terminal, or sometimes it’s called terminal emulator. It’s to linux what the bash shell is to windows, just a terminal interface.

On Unix, Linux, BSD, macOS, and Cygwin::

make test
sudo make install

This will install Python as ``python3``.

You can pass many options to the configure script; run ``./configure --help``
to find out more. On macOS case-insensitive file systems and on Cygwin,
the executable is called ``python.exe``; elsewhere it's just ``python``

While you can install with optimizations, we will skip for now, and you shouldn’t run into any problems. You can use a text editor to write python code, but I recommend vs code. They call it a IDE (or integrated developers environment) and I have developed my own, use vim via terminal or even edit from my mobile android (via PyDroid 3) but I am well in the years and mastered engineering, so for you, I would recommend using vscode (even though bill gates is a bigot, and Microsoft sucks) starting off. If you use windows you can use both vscode or visual studio. Linux you just use vscode. I ain’t going no more into it. Find out for yourself.
When you type in `sudo make install` and it finishes, it would make your `python3` version to the most recent version. As of 09-26-2021, you shouldn’t need to upgrade your standard Linux OS python to follow the tutorial, but this is only if for some reason, you don’t have python on your Linux machine, or you want to upgrade from python 3.8.5 to 3.9.7. Refer to the readme from the python or github python page (use duckduckgo (or racist google)) for more information.

Getting started

Your python scripts are going to end with a .py extension so if you decided to do a hellopy file, you naturally would save it as If this is a challenge, please get basic computer usage courses, all free on sexist youtube. Other than that, lets proceed with breaking down a python script.

import os #importing libraries for additional functionality, from basic outputs to hell a fucking game engine

_01_dis_is_a_variable = "variable" # variable is a container for data. variables cannot begin with a number unless there is an underscore that comes before, and you cannot use a reserved keyword (more on that later)

def _test_function(parameter): #function subroutine is what you use to bundle a set of codes to call in sequence whenever called
return parameter #return keyword would return the data as given. more later as full understanding will not be expressed in this comment
#by the way this is a comment. comments are not red or executed in the code. It is a placeholder or you use it to
#communicate which each variable, sequence, function etc. does. Just think of taking notes.

_test_function(_01_dis_is_a_variable) #this is calling the function which should print "variable"

stolen from duckduckgo

The basics that I had started off with are in this area of expertise. Don’t worry its not over yet. so expect more training. Keep reading if you don’t believe me. Go ahead, don’t listen to the guy that integrated python 3 into usage for WordPress as a plugin module, written in PHP, so that includes HTML5 (not really a programming language), PHP, CSS3, Javascript, AJAX, and Python, and integrated into this single blog post. Sure don’t listen to the guy that managed that feat. Good luck wasting 3 years to learn things that at the most took me maybe at most 3 months for full comfort. You do you, booboo.

For the rest that decided to proceed, I will break down what each means and how it will evolve. Ready? too bad. Since I can’t safely get laid, you gotta suffer! I would go onto the playstore and utilize sololearn, udemy, eduonix, etc. Training is free, and mobile apps are designed carefully to keep you engaged. If I could collect affiliate links for people to bring them in, I would be making even more money. But you’re here, so I will not waste your time. Let’s proceed.

imports and variables

Well since you will be using variables throughout your code, we will need to discuss it. In a simple explanation, variables are described as containers for storing data values. Try to think of variables as placeholders for data. there are many reasons to use them. They can help the programs you would write to become more flexible. A variable is used to allow the programs you write to refer to a variable’s value in one location, instead of having to type out the values you would need. As I said before for the slower Kidz in the back, as rules for naming a variable, you don’t want variables to conflict with function names or reserved keywords, and since you cannot start a variable name with a number (unless an underscore ( _ ) is inserted before the number i.e. _01_data_var. Also another rule to keep in mind that with upper and lowercase letters in a variable name, They are interpreted as different variables so for example, _01_Variable, _01_variable, _01_VARIABLE, _01_VariaBle are all different variables. so you cannot use _01_variable as a substitute to _01_Variable, unless you code it that way, but we won’t get into that for right now. It’s better to understand as things go along.

In Python, there is no command for declaring a variable. Other programming languages can have a syntax that you need to specify before naming a variable. In javascript, to set a variable, you would need to set “var” before the variable name ie, var _x = 22; var VARIABLE = “the variable”.The variables are created as soon as you assign a value to it.

In Python, variables don’t need to be declared with any specific data type. But another thing to keep in mind is that variables can change the variable in question’s data type after they have been set, so be careful and keep this fact in mind.

print = print("Uh oh!") #Will cause an error and can cause your program to break

This will cause an error as you tried to name a variable after a reserved function. There are ways of doing that, but this way, will cause errors. Witness how these things work, few examples of what to do, and what not to do.

exampleVar = 55

The example below is not a valid datatype, and this will cause an error. You would need to throw quotes around the string.

cannotDoThisCrap = HeyFucker!


canDo = "HeyFucker!"

Hell, you are able to store the result of a calculation to a variable.

For example:

canpop = 5/4

You can set functions as well, but not reserved functions, nor keywords.

Try the examples below:

Got it? good! now we can move on….


Code written in python, is organized in modules & packages. On the website, it states that the definition of module is an object that serves as an organizational unit of Python code. Modules have a namespace containing arbitrary Python objects. Modules are loaded into Python by the process of importing. When implemented, a Python module is usually one .py file containing Python code. The magic of this tho’, is that modules can be imported and reused in other code. For example…

import math
# should output 3.141592653589793

on the import math part, you end up importing the code in the math module and make it available to use in your script. The second line which has math.pi inside the print function parameter, this is where the “pi” in the math module you can access. Pi is the variable in the math module. Since the math module is part of Python’s standard library, you can import it anytime you need. Also to note for the slow kids in the back, modules can act as a namespace that will keep all the attributes of the module together. Namespaces are used for keeping your code organized and in most cases, readable.

Packages are different. In the relevancy to it all, modules generally are composed of only one py script, and packages have many scripts, and sometimes can also depend on a binary executable, and be located in it’s own directory.
A package is still a module tho. To create a Python package yourself, you create a directory and a file named inside it. The file contains the contents of the package when it’s treated as a module. It can be left empty if need be. Directories can be treated as packages without an file. However, these aren’t regular packages, these are known as namespace packages. I’m sure if you kept up this long, you’ll figure it out later.

try this below:

# Import math Library
import math

# Print the value of pi
print (math.pi)


Functions are more or less a block of organized, reusable code that is used to perform a single, string of actions. Functions generally provide better readability, and generally provide a good portion of code reusing.
Take for example that python gives you many built-in functions like for the damn print(), etc. but you can also create your own functions call it fucks for all I care. These functions are referred to as “user-defined functions”.
As you know, functions can be defined to provide the required functionality. Here are some of the fucking rules to follow when your lame ass define a function in Python:

Function blocks begin with the keyword def followed by the function name and parentheses ( ( ) ). eg. “def _03_fuk_urself()”

Any input parameters or arguments should be placed within these parentheses. You can also define parameters inside these parentheses. eg. “def _02_eat_dirt(eeb, fap=”splash”)”

The code block within every function starts with a colon (:) and is indented. eg. def _24_somokz_zum_weed(strain): notice the colon

def _02_supa_drive(vroom, engine="vx"):

The statement return [expression] exits a function, optionally passing back an expression to the caller. A return statement with no arguments is the same as return None.

def _982954_simp_husband(sucker="cuckold"):
return "I am".sucker.",And I deserve nothing but spit on my face, and disrespect, because I'm a pathetic simp"

Homework to do when you move to next section:

You can call a function by using the following types of arguments −

Required arguments
Keyword arguments
Default arguments
Variable-length arguments

Google (preferably duck duck go, since google is racist.) each of these arguments and test them out on this ide or the other IDEs.

Information extracted from tutorials point. section located here at this link

An else statement can be combined with an if statement. An else statement contains the block of code that executes if the conditional expression in the if statement resolves to 0 or a FALSE value.

The else statement is an optional statement and there could be at most only one else statement following if.

The syntax of the if...else statement is −

if expression:





When the above code is executed, it produces the following result −

The elif statement allows you to check multiple expressions for TRUE and execute a block of code as soon as one of the conditions evaluates to TRUE.

if expression1:


elif expression2:


elif expression3:




Similar to the else, the elif statement is optional. However, unlike else, for which there can be at most one statement, there can be an arbitrary number of elif statements following an if.


var = 100

if var == 200:

print "1 - Got a true expression value"

print var

elif var == 150:

print "2 - Got a true expression value"

print var

elif var == 100:

print "3 - Got a true expression value"

print var


print "4 - Got a false expression value"

print var

print "Good bye!"

and when the kode above is run and shit, you get

3 - Got a true expression value


Good bye!

Core Python does not provide switch or case statements as in other languages, but we can use if..elif...statements to simulate switch case as follows −


When the above code is executed, it produces the following result −

© Copyright 2022. All Rights Reserved.

We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy.

Again, Stoopid bitch, Information extracted from tutorials point. section located here at this link


Python while/for loops

I would honestly rather have the w3 schools explain it, as it is a source I have learned from and it’s simple-simple. I could say that you could type in x= 100 while x > 0: x -= 1, but there is more information on these loops. The W3Schools website here in this link has it’s own and simplified details on it’s site. Plus examples and break and continues and stuff. click here to learn interactively. Don’t like it? Go Fuck Yourself! I’m not about to make it easy for you. You wanna be a python programmer? Take this “Homework” and swallow some knowledge, faggot. Do your research, punk! You lucky I left the link above for you to use to get a headstart. You wanna learn to make a game loop? the while loop is fundamental. so yea. This section will be homework for you. You learn this on your own, entitled ass butt snob!

Moving On….

Python classes

, Think of classes as a structure for a datatype. A blueprint if you will. For example standard datatypes include int, double, float, boolean, etc. Creating a class can be thought of as a “Blueprint structure of a custom datatype”. Since I am lazy, I am going to webscrape this section from tutorials point from directly off their website. Their website link is at the bottom if you don’t believe me. Follow the link. See for yourself I got lazy. I can be a lazy coder cause I gots skills. These are the basics you need. If you have questions, Google (or duck duck go) stack overflow and type your question in the search box.

ignore the rant. I hate the government. The democrats executed my wife and children, and the republicans bent the knee like the spineless bigots they are, and I'm out for blood! next section after the rant is the web scraped content from tutorials point.


Python has been an object-oriented language since it existed. Because of this, creating and using classes and objects are downright easy. This chapter helps you become an expert in using Python's object-oriented programming support.

If you do not have any previous experience with object-oriented (OO) programming, you may want to consult an introductory course on it or at least a tutorial of some sort so that you have a grasp of the basic concepts.

However, here is small introduction of Object-Oriented Programming (OOP) to bring you at speed −

Class − A user-defined prototype for an object that defines a set of attributes that characterize any object of the class. The attributes are data members (class variables and instance variables) and methods, accessed via dot notation.

Class variable − A variable that is shared by all instances of a class. Class variables are defined within a class but outside any of the class's methods. Class variables are not used as frequently as instance variables are.

Data member − A class variable or instance variable that holds data associated with a class and its objects.

Function overloading − The assignment of more than one behavior to a particular function. The operation performed varies by the types of objects or arguments involved.

Instance variable − A variable that is defined inside a method and belongs only to the current instance of a class.

Inheritance − The transfer of the characteristics of a class to other classes that are derived from it.

Instance − An individual object of a certain class. An object obj that belongs to a class Circle, for example, is an instance of the class Circle.

Instantiation − The creation of an instance of a class.

Method − A special kind of function that is defined in a class definition.

Object − A unique instance of a data structure that's defined by its class. An object comprises both data members (class variables and instance variables) and methods.

Operator overloading − The assignment of more than one function to a particular operator.

The class statement creates a new class definition. The name of the class immediately follows the keyword class followed by a colon as follows −

The class has a documentation string, which can be accessed via ClassName.__doc__.

The class_suite consists of all the component statements defining class members, data attributes and functions.

Following is the example of a simple Python class −

The variable empCount is a class variable whose value is shared among all instances of a this class. This can be accessed as Employee.empCount from inside the class or outside the class.

The first method __init__() is a special method, which is called class constructor or initialization method that Python calls when you create a new instance of this class.

You declare other class methods like normal functions with the exception that the first argument to each method is self. Python adds the self argument to the list for you; you do not need to include it when you call the methods.

To create instances of a class, you call the class using class name and pass in whatever arguments its __init__ method accepts.

You access the object's attributes using the dot operator with object. Class variable would be accessed using class name as follows −

Now, putting all the concepts together −

When the above code is executed, it produces the following result −

You can add, remove, or modify attributes of classes and objects at any time −

Instead of using the normal statements to access attributes, you can use the following functions −

The getattr(obj, name[, default]) − to access the attribute of object.

The hasattr(obj,name) − to check if an attribute exists or not.

The setattr(obj,name,value) − to set an attribute. If attribute does not exist, then it would be created.

The delattr(obj, name) − to delete an attribute.

Every Python class keeps following built-in attributes and they can be accessed using dot operator like any other attribute −

__dict__ − Dictionary containing the class's namespace.

__doc__ − Class documentation string or none, if undefined.

__name__ − Class name.

__module__ − Module name in which the class is defined. This attribute is "__main__" in interactive mode.

__bases__ − A possibly empty tuple containing the base classes, in the order of their occurrence in the base class list.

For the above class let us try to access all these attributes −

When the above code is executed, it produces the following result −

Python deletes unneeded objects (built-in types or class instances) automatically to free the memory space. The process by which Python periodically reclaims blocks of memory that no longer are in use is termed Garbage Collection.

Python's garbage collector runs during program execution and is triggered when an object's reference count reaches zero. An object's reference count changes as the number of aliases that point to it changes.

An object's reference count increases when it is assigned a new name or placed in a container (list, tuple, or dictionary). The object's reference count decreases when it's deleted with del, its reference is reassigned, or its reference goes out of scope. When an object's reference count reaches zero, Python collects it automatically.

You normally will not notice when the garbage collector destroys an orphaned instance and reclaims its space. But a class can implement the special method __del__(), called a destructor, that is invoked when the instance is about to be destroyed. This method might be used to clean up any non memory resources used by an instance.

This __del__() destructor prints the class name of an instance that is about to be destroyed −

When the above code is executed, it produces following result −

Note − Ideally, you should define your classes in separate file, then you should import them in your main program file using import statement.

Instead of starting from scratch, you can create a class by deriving it from a preexisting class by listing the parent class in parentheses after the new class name.

The child class inherits the attributes of its parent class, and you can use those attributes as if they were defined in the child class. A child class can also override data members and methods from the parent.

Derived classes are declared much like their parent class; however, a list of base classes to inherit from is given after the class name −

When the above code is executed, it produces the following result −

Similar way, you can drive a class from multiple parent classes as follows −

You can use issubclass() or isinstance() functions to check a relationships of two classes and instances.

The issubclass(sub, sup) boolean function returns true if the given subclass sub is indeed a subclass of the superclass sup.

The isinstance(obj, Class) boolean function returns true if obj is an instance of class Class or is an instance of a subclass of Class

You can always override your parent class methods. One reason for overriding parent's methods is because you may want special or different functionality in your subclass.

When the above code is executed, it produces the following result −

Following table lists some generic functionality that you can override in your own classes −

__init__ ( self [,args...] )

Constructor (with any optional arguments)

Sample Call : obj = className(args)

__del__( self )

Destructor, deletes an object

Sample Call : del obj

__repr__( self )

Evaluable string representation

Sample Call : repr(obj)

__str__( self )

Printable string representation

Sample Call : str(obj)

__cmp__ ( self, x )

Object comparison

Sample Call : cmp(obj, x)

Suppose you have created a Vector class to represent two-dimensional vectors, what happens when you use the plus operator to add them? Most likely Python will yell at you.

You could, however, define the __add__ method in your class to perform vector addition and then the plus operator would behave as per expectation −

When the above code is executed, it produces the following result −

An object's attributes may or may not be visible outside the class definition. You need to name attributes with a double underscore prefix, and those attributes then are not be directly visible to outsiders.

When the above code is executed, it produces the following result −

Python protects those members by internally changing the name to include the class name. You can access such attributes as object._className__attrName. If you would replace your last line as following, then it works for you −

When the above code is executed, it produces the following result −

© Copyright 2022. All Rights Reserved.

We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy.

Python class data extracted from tutorials point site. follow link to get source

tutorials point python class tutorial


just have fun with this environment. You can’t save scripts but you can practice your python skills here. You don’t have to leave this page until you at least have a good idea of python works, then you can go ahead and get those independent certs online instead of going to a sexist college/ ivy league school. They heavily discriminate against men and boys.