Post tagged: python

My Python script to write content

So I decided to flex my skills with python and make a simple python script that...

Writes my articles for my site! (Well I still need to be around to write them)

This mainly allows me to write up something quickly instead of needing to remember how I do that …

Classes and Objects

Consider this code

class Room():
    def __init__(self, name, rmnum): = name
        self.rmnum = rmnum
        if self.rmnum > 100:
            self.floor = (int(self.rmnum / 100) + 1)
            self.floor = 1

    def __str__(self):
        return "{0} on {1} with room number {2}".format(, self.floor, self.rmnum)

So …


So your wondering each time I run my program it doesn't remember anything... can I make a program remember the previous time it ran?

Lets start off with reading from a file... (I am going to explain don't worry)

my_file = "example.txt"
with open(my_file, "r") as f …


Computers love to do the same/simular task over and over again.

Unlike Humans, Computers will do the exact same thing without making mistakes. (Unless there is another mistake, commonly called a programming error)

So what can we do with a loop?

my_list = [0, 1, 2, 3, 4, 5 …

Storing data with JSON

So what is JSON?

Java Script Object Notation or JSON for short.

Websites like OpenWeather have an Application Programming Interface or API.

API's can return data in some common formats... like XML and JSON.

Python has modules that you can import into your program to use them and do advanced …

String Format

So in this discussion we will have 2 topics:

  • String Format
  • F String

These are at least 2 of the ways you can insert data into a string.

String Format

Given the following code

my_name = "Beanzilla"
print("Hello {0}!".format(my_name))

Hello Beanzilla!

So how does this work …


So what is a variable?

A variable can best be described as a box.

We have a label on the box and that's the variable's name,

Then we have something in the box and that's the variable's data or content.

So when we want to make a new variable we …

Hello World

Python is a vast high-level computer language.

Many who are learning a new computer language use a very simple yet powerful example to begin their learning process...

Print, Displays text or whatever you want to the screen.

print("Hello World!")

Simply outputs to the screen

Hello World!

This can be …