Python — Variables
Introduction to Python
Hi, this is my first post since I know Medium.com as an online publishing platform that helps me find solutions for my code…
Every programming language has a different way to declare its variable. Before we go, what are variables? Variables are used to store information to be referenced or manipulated in a computer program. Variables have various data types like integer, float, double, string, and many more. In the previous post, we have installed Python and PyCharm as our code editor. So, in this post, we will discuss variables in Python.
Rules when declaring variables
- Case sensitive
- Avoid using numbers to declaring variables. Example: not 3age but age3
- Not need semicolon (;) at the end of the statement.
- The existed variable can be re-assigned with a new value.
Python has no specified command to define a new variable. Example:
You can re-assign existed variable with a new value. Example:
You can declare your variable to a specific data type with casting.
If you want to get your variable type, use type() function. Example:
Python provides some data types:
- Complex Number
to better understand, look at the following example.