Variables
Variables are used to store information in Python, and that information can be anything—a line of text, the name of a person, or a number. Several data types can be stored in a variable, which we will talk about later in this course.
Examples of variables:
In this code, age is the variable, and the equal sign shows it has been assigned the value of 22, so anytime we mention age in our code or print the variable age, we know it is going to output the value it has stored, which is 22. Print the variable age and run your code to see the results below in the Python interpreter.
We can also do some more coding in Python Interpreter.
As you can see above, if you want to change the value of the variable from 22 to 33, just assign the variable to your preferred value and print it. The red syntax you see with the # sign is a comment.
Let's look at some feasible rules before we end this tutorial.
- In our next toturial we are going to do some exercises on variables good luck!
No comments:
Post a Comment