Learning Objectives
In this challenge we are learning how to use variables to store the properties of a superhero. Some of our variables will be used to store text (string) such as the name of our super hero. Some variables will be used to store numbers, either whole numbers (integers) or numbers with a decimal place (reals/floats).
Once we have stored all our properties of our superhero we will use the print command in Python to print a full description of our superhero.
Using variables
Look at the example below to see how text (string) and numbers (integers or reals) are stored using variables.
name = "Baymax" strength = 9 height = 1.85
Have you noticed the use of “speech marks” when storing a string?
Step #1
Use the trinket below to store the name, location, gender, name of the enemy, super powers of your superhero. Dont forget the use of “speech marks”.
name = "..." location = "..." gender = "..." enemy = "..." powers = "..., ..., ..."
Step #2
Now save the speed, age and strength of your superhero using numerical values. You will not need to use speech marks.
speed = strength = age =
Step #3
We will now use the print command to display a description of our superhero on screen.
We will combine statements such as “My superhero is called ” and variables (such as name) to create a clear description of our superhero. To do this we will use the + operator.
Tip:
When combining two strings or a statement and a string variable we use the + operator. For instance:
print("Hello, my name is " + name + " and I live in " + location + ".")
When combining a string or a statement with a numerical variable (integer or real) we have to cast (convert) this number into a string using the str() function. For instance:
print("My strength score is " + str(strength) + " out of 10.")
Your Challenge
Complete your code to create a complete description of your superhero. For instance:
Extension:
Can you think of additional properties to describe your superhero? For instance the colours of their costume, their height, their weight, etc.
Create more variables to store these new properties and complete your description of your superhero.
Solution...
The solution for this challenge is available to full members!Find out how to become a member:
➤ Members' Area