Updating Variable Value
It's important to realize that a program executes sequentially. This means that one statement is executed, and after it finishes, the next statement is executed. Let's explain with an example:
artist = "Edgar Allan Poe"
print("The best artist is " + artist)
artist = "William Shakespeare"
print("The best artist is " + artist)
This will print:
The best artist is Edgar Allan Poe
The best artist is William Shakespeare
First, we assigned the value “Edgar Allan Poe”
to the variable artist
. Then it printed The best artist is Edgar Allan Poe
because at that moment, the value of the artist
variable is “Edgar Allan Poe”
. Next, we changed the value of the artist
variable to “William Shakespeare”
. Now it printed The best artist is William Shakespeare
because the value of the artist
variable was changed.
Instructions
On line 4, change the value of the first_name
variable to "Mike"
.
On line 5, insert the statement from line 3:
print(first_name + " " + last_name)
Start programming for free
7/10