Python Tutorial
About Lesson

In this Python Tutorials we are going to learn Python Creating Variables, so variables are used for storing data values, In some languages, like C++ or Java variables have predetermined types, and a variable can only be used to hold values of that type. In Python, we may reuse the same variable to store values of any type.

 

 

 

So in here we have created four different variables with different data types,

for example we have integer variable, we have floating variable, we have string and also character variables, and you can see that we have not defined the types for these variables.

 

 

And this is the result.

Python Tutorials - Creating Variables
Python Tutorials – Creating Variables

 

 

To define a new variable in Python, we simply assign a value to a label. For example, this is how we create a variable called count, which contains an integer value of 10.

 

 

We can define several variables in one line, but this is usually considered bad style:

Naming Rules 

when you are going to create variables in python, you need to obey some rules for the name of the variable.

  • Variable names can contain only letters, numbers, and underscores.
    They can start with a letter or an underscore, but not with a number.
    For example, you can call a variable count_1 but not 1_count.
  • You can not add spaces in the variable names, it is not allowed to add
    spaces in variable names. but you can use underscore in the variables names.
  • You can not use Python keywords and function names as variable names;
    do not use words that is reserved in Python for example print.
Thank you for visiting my website! If you enjoyed the free courses, please consider supporting my works on Patreon.
Exercise Files
No Attachment Found
No Attachment Found