Variables for String
What is a variable? In simple words, a variable is a data store. It is very easy to create a variable in Python - you need to assign a value to a certain identifier using the "=" assignment operator. Let's look at the example of how to create a variable.
flower = 'Rose'
If you display this variable on the screen, you will get such an output: Rose
Now the variable flower refers to the next line "Rose". But if you want to change the value of this variable you can do it very easily. Look at the example.
flower = 'Lily'
You have changed the variable. And if you display the variable flower
on the screen, you will get: Lily
.
Note that we have assigned string values to variables. And when we work with strings, we have to enclose them in quotes, if you don't, you will get an error.
It's time to practice!
Swipe to start coding
In this task, you need to implement 2 steps, namely:
- Create a variable named
country
. Assign the string"France"
to this variable. - Display this variable to the screen using print keyword.
Oplossing
Bedankt voor je feedback!
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Awesome!
Completion rate improved to 5.88
Variables for String
Veeg om het menu te tonen
What is a variable? In simple words, a variable is a data store. It is very easy to create a variable in Python - you need to assign a value to a certain identifier using the "=" assignment operator. Let's look at the example of how to create a variable.
flower = 'Rose'
If you display this variable on the screen, you will get such an output: Rose
Now the variable flower refers to the next line "Rose". But if you want to change the value of this variable you can do it very easily. Look at the example.
flower = 'Lily'
You have changed the variable. And if you display the variable flower
on the screen, you will get: Lily
.
Note that we have assigned string values to variables. And when we work with strings, we have to enclose them in quotes, if you don't, you will get an error.
It's time to practice!
Swipe to start coding
In this task, you need to implement 2 steps, namely:
- Create a variable named
country
. Assign the string"France"
to this variable. - Display this variable to the screen using print keyword.
Oplossing
Bedankt voor je feedback!
Awesome!
Completion rate improved to 5.88single