Overview of Python Variables

In C programming, I used to end with semi-colon otherwise it will lead to error. In the case of Python, I feel it is like essay-writing (Just kidding). Isn't this the greatest happiness knowing 'no semi-colon' language does exist?? 

Variables 

Variable is a storage location (identified by memory location) paired with an associated symbolic name (an identifier), which contains some known or unknown quantity of information 

Python is totally object-oriented but not statically typed.                                                                

What does it mean? 

  1. No need to declare the variable before using them.
  2. No need to have the data type of the variable. 

Ground Rules:

1) Variable names can't be started with a number, but they can be started with a letter or underscore. They can be a combination of letters, numbers, and underscore(_). No other special symbols are allowed. It is case sensitive. 


 
2) As stated earlier, no datatype is required in python.

3) Reserved words can't be used. what are those reserved words?

Eg: 
and del for is use 
assert elif from lambda return 
break else global not try 
class except if or while 
continue exec import pass yield 
def ?nally in print 

4) Complex numbers can be defined. 

4) Strings can be declared with double/single qoutes " " or ' '



5) Reassignment is possible as per the above screenshot. 

6) Typecasting is also possible. The below screenshot also tells that we can know the type of the variable. I was wondering how python can work without knowing the data type. I will update the later posts in detail. Stay tuned. 


To find the type of the variable, use the below command. 

type (variable-name)                                                         



In this post, I used IDLE IDE terminal. 

Comments