Variables_and_Comments_in_Python

Variables and Comments in Python?

Variables and Comments in Python

Variables in Python:

Variables in Python
Variables in Python
Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. Based on the data type of a variable, The interpreter allocates memory and decides what can be stored in the reserved memory.

Python Variables do not explicitly declare to reserve memory space The declaration happens automatically when we assign a value to a variable. The Equal ( = ) Sign is used to assign values to variables.

The operand to the left of the equal ( = ) sign operator is the name of the variable and the operand to right of the equal ( = ) sign operator is the Value stored in a Variable.

Example :

a = 1000; # Integer Assignment

b= 1000.0 # Floating Point Assignment

c= “Ram” # String Assignment

Python allows its user to assign a single value to multiple variables .

Example:

a = b = c = d = e = 100 # Integer Assignment

a = b = c = d = e = 100.0 # Floating Point Assignment

a = b = c = d = e = “Ram “ # String Assignment

Python also allow its users to assign multiple value to multiple atom

Example:

a, b, c = 100 , 100.0, “Ram”

Here a is assign to 100 , b is assign to 100.0 and c is assign to “Ram”

This is same as: 

a = 100 # Integer Assignment

b= 100.0 # Floating Point Assignment

c= “Ram” # String Assignment

Comments In Python:

Comments in Python
Comments are very Important while writing a program or developing a complete project . It used to describe the purpose of a particular program. 

Single Line comment in Python:

In python hash( # ) symbol used to start a comment. All the characters after the # and up to the end of the present line are part of the comment. It extends till the new line starts.

Example:

>>># this is a comment

>>>print (“Hello”)  #it is executable program

Multiple Line Comments in Python:

Multi-line comments start with a triple single quote/Double quote ( ‘’’/”"") and ends with a triple single quote/Double quote ( ‘’’/””” ).

Example : 

>>>’’’ i am 

>>>a multiline comment’’’

>>>””” i am 

>>>a multiline comment”””

>>>print(“hello”) #This is executable

Follow us on

Variables and Comments in Python
Variables and Comments in Python

Facebook : Python For You

Instagram: Python For You

Twitter: Python For You

More Blogs:

techengers

Add comment

Leave a Reply

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most popular