- Create a variable called
name
and assign your first name to that variable. - Print
"Welcome to the Dungeon, xxx!"
. Use name inside of your printing. Do not forget about f at the beginning You can use double or single quotes. Both will work!
Note: xxx has to be replaced by your name! Do not forget the space behind Dungeon,.
If your name is Jane, then the output will look like this:
"Welcome to the Dungeon, Jane!"
This is the way how you write comments in Python:
# Hi! I'm Anna and I am living in coding.py.
# I'm an expert Python coder.
# I'm 51 years old and and I can teach myself Python.
Comments are useful for additional explanation of your code.
1. Someone has introduced themselves to you using comments in coding.py. (It is just a joke, you do not have to create a file coding.py, of course ;) )
Read the comments and then create a variable called age_is_7
and set it to be True
or False
depending on if this person's age is 7.
2.
Create a variable called name_is_anna
and set it to be True
or False
depending on if this person's name is Anna.
Of course, you can create more variables with True
or False
.
If you want, you can compare them with and, or, !=, ==.
Imagine that you are a teacher in school and you would like to automatize the calculation of grades.
- Create a new variable
student_points
and give it a number between100
and0
. - Write first
if
condition that will saystudent_points > 90
. If the condition isTrue
, this will printA
. - The second condition will start with the new word
elif
(= else if). This condition will saystudent_points >= 80
. If the condition isTrue
, this will printB
. Ask coaches for a help. - And write
else
condition at the end that will printC
.
Note: do not forget the 4 spaces after semicolon :
, otherwise you will get IndentationError
.
Example: The student Nicole got 82 point in the school test.
You can expect this result:
B
Note: there can be more grades, of course ;)