Super Simple Python: The Perfect Introduction

Super Simple Python is a series of Python projects you can do in under 15 minutes. In this episode, we’ll be covering how to build a randomized perfect introduction using the Inigo Montoya method in 25 lines of Python. 

For a video version:

As with many of the Super Simple Python projects, this one uses the random library. Other projects we’ve done that have also used the random library include Rock Paper Scissors, a Dice Roll Simulator, and the Password Generator

Before we get into the code, we should cover what the Inigo Montoya method is. Inigo Montoya is a character from the Princess Bride. He delivers the perfect introduction. “Hello. My name is Inigo Montoya. You killed my father. Prepare to die.” This introduction is easily broken down into four parts: a greeting, his name, a relevant personal link, and expectations.

Inigo Montoya’s Perfect Introduction

Set Up the Inigo Montoya Method

Of course we will begin our program by importing the random library. After importing the library, let’s set up how we’ll execute on the Inigo Montoya method. As covered above, there are four parts to his perfect greeting. We’re going to have a little fun, and create a randomized perfect introduction with these parts. To do this, we’ll create four lists, each corresponding to one part of the introduction.

import random
 
greetings = []
intros = []
links = []
expectations = []

Create Your Possible Introductions

Now that we’ve set up our list containers, let’s set up some ways to introduce ourselves. I picked two possible greetings, two possible name introductions, three possible links, and four expectations. This sets up a possible 2 x 2 x 3 x 4 = 48 possible perfectly structured introductions. If you are a close friend or follow me on Tik Tok, you’ll recognize the second name introduction. Everything else is just about my online blogging and my goal of teaching you how to be a true engineer.

greetings.append("Hello. ")
greetings.append("Yo, what's up. ")
 
intros.append("My name is Yujian Tang. ")
intros.append("It's ya boi Ra. ")
 
links.append("You may know me from Super Simple Python. ")
links.append("I'm the owner of the Social Techies Discord server. ")
links.append("You may have seen my articles on Medium. ")
 
expectations.append("I'm going to teach you how to become a software engineer.")
expectations.append("I create the best software content in the world.")
expectations.append("I will show you how to actually learn engineering skills.")
expectations.append("If you want to truly learn Python in a useable manner, you should follow me.")

Randomize Your Intro

Now that we’ve set up the possible choices for the four parts of our perfect introduction let’s create it. We’ll use the random.choice() function from Python to randomly choose an element from each list. All we need to do is get one random choice from each list and add them up in order. Adding strings in Python concatenates them. 

full_greeting = random.choice(greetings) + random.choice(intros) + random.choice(links) + random.choice(expectations)
 
print(full_greeting)

When we print our greeting it will look something like this:

a perfect introduction

I run this site to help you and others like you find cool projects and practice software skills. If this is helpful for you and you enjoy your ad free site, please help fund this site by donating below! If you can’t donate right now, please think of us next time.

Yujian Tang

One thought on “Super Simple Python: The Perfect Introduction

Leave a Reply

Discover more from PythonAlgos

Subscribe now to keep reading and get access to the full archive.

Continue reading