Programming a Brand Name Generator in Python

In my previous article, I used an Ubuntu server on EC2 to host a virtual Python environment. This time we will do a bit more with Python.

Homebrew

/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Image 1

Then, I confirmed that Homebrew was installed (Image 2).

Image 2

Python3

python3 --version

Image 3

For fun and to confirm everything was working, I then ran Python3 with the command python3, played with a few lines, made a “Hello World,” added 2+6, etcetera (Image 4).

Image 4

I then wanted to stop working in interactive mode, so I entered quit() as seen in Image 5.

Image 5

The Python interactive session that I was just in allows me to write lines of code, but when the session is closed, I lose everything that was written. Therefore it is common to write Python programs by using plain text files. As you see in Image 6, I used vim and wrote .py at the end of a file named brandnamegenerator to make a Python file rather than a standard text file.

Image 6

This then brought me into text editing. I proceeded to write the following in Image 7, and saved it with :w

Image 7

Now the script was ready. I ran it with the command:

python3 brandgeneratorname.py

First the question about my city came up, to which I responded “Philly.”

Then the question about my family dog came up, to which I responded “Nitro.”

Then the consequent output was: Your band name could be Philly Nitro

Image 8 shows this final, success outcome (except a typo, “band name” instead of “brand name”)

Image 8

I amended the typo by re-opening brandnamegenerator.py in vim, and adding the r (Image 9).

Image 9

I re-ran the script (Image 10). No more typo :)

Image 10

Thanks for reading.

Credit: This exercise is inspired by Paul Zhao’s ‘Python 100 projects in 100 days — Learning Journal.’

Cloud, DevOps, Blockchain.