Buy:
|
What's your superhero name? (Self-guided tutorial)
How it works
Find your superhero name in two short and easy steps. Find the first letter of your first name. For example, if your first name is “Alice”, then your superhero first name is “Captain”. Now find the first letter of your last name. For example, if your last name is “Jones”, then your superhero last name is “Bolt”. That’s it!
Superhero names
First letter of your first name
Find the first letter of your first name. For example, if your first name is “Alice”, then your superhero first name is “Captain”.
Find the first letter of your first name. For example, if your first name is “Alice”, then your superhero first name is “Captain”.
Initial | Name | Initial | Name |
---|---|---|---|
A. | Captain | N. | Atomic |
B. | Turbo | O. | Rock |
C. | Galactic | P. | Omega |
D. | The | Q. | Rocket |
E. | Fire | R. | Shadow |
F. | Fire | S. | Agent |
G. | Iron | T. | Silver |
H. | Super | U. | Wild |
I. | Green | V. | Wolf |
J. | Phantom | W. | Ultra |
K. | Dark | X. | Wonder |
L. | Ghost | Y. | Doctor |
M. | Professor | Z. | Star |
First letter of your last name
Find the first letter of your last name. For example, if your last name is “Jones”, then your superhero last name is “Bolt”.
Find the first letter of your last name. For example, if your last name is “Jones”, then your superhero last name is “Bolt”.
Initial | Name | Initial | Name |
---|---|---|---|
A. | X | N. | Strike |
B. | Shield | O. | Falcon |
C. | Machine | P. | Fang |
D. | Justice | Q. | King |
E. | Beast | R. | Surfer |
F. | Wing | S. | Bot |
G. | Arrow | T. | Guard |
H. | Skull | U. | Thing |
I. | Blade | V. | Claw |
J. | Bolt | W. | Brain |
K. | Cobra | X. | Master |
L. | Blaze | Y. | Power |
M. | Soldier | Z. | Storm |
STEP 1
In this tutorial, you will learn how to code a “Superhero name” generator in Python. The game will work by prompting the player to enter their initials before looking up their corresponding superhero name from the dictionary of names.
Start by inputting the following code:
In this tutorial, you will learn how to code a “Superhero name” generator in Python. The game will work by prompting the player to enter their initials before looking up their corresponding superhero name from the dictionary of names.
Start by inputting the following code:
heroList = {"SPIDERMAN": "Hero", "VENOM": "Villain", "WOLVERINE": "Hero", "MAGNETO": "Villain"}
heroName = input("Enter superhero character name: ") result = heroList[heroName] print("Hero or villain?: " + result) |
Run and test your code.
The code above uses a feature in Python called a dictionary which is a collection of items containing a “key” and a “value”.
Challenge 1:
Modify the code to include some of your own superhero (or villain) the names.
Question:
What happens if you don’t enter a name all in upper case?
We can convert a user’s input to uppercase using .upper(). Try adding the following code after line 2:
The code above uses a feature in Python called a dictionary which is a collection of items containing a “key” and a “value”.
Challenge 1:
Modify the code to include some of your own superhero (or villain) the names.
Question:
What happens if you don’t enter a name all in upper case?
We can convert a user’s input to uppercase using .upper(). Try adding the following code after line 2:
heroName = heroName.upper()
|
Superhero name generator
The game will work by prompting the user to enter their initials before looking up their corresponding superhero name from the dictionary of names.
Challenge 2:
Create your own superhero name generator by filling in the gaps in the code below:
The game will work by prompting the user to enter their initials before looking up their corresponding superhero name from the dictionary of names.
Challenge 2:
Create your own superhero name generator by filling in the gaps in the code below:
Worked example (Containing complete dictionary of names):

superhero_name_worked_example.zip |
Worked example (Containing partially completed dictionary of names):

superhero_name_worked_example_2.zip |
Example solution:

whats_your_superhero_name.zip |
Taking it further
Challenge the students to modify their code so that the user to enters their full name and the program automatically extracts the first letter from the first name and last name. For example:
Challenge the students to modify their code so that the user to enters their full name and the program automatically extracts the first letter from the first name and last name. For example:
firstName = input("What is your first name? ")
firstInitial = firstName[0].upper() |
Bonus Challenge
Challenge students to create their own name generator. For example, elf name or game name generator etc.
Challenge students to create their own name generator. For example, elf name or game name generator etc.