Chapter: Problem Solving and Python Programming : Data, Expressions, Statements

Variables - Python

A variable allows us to store a value by assigning it to a name, which can be used later.

VARIABLES:

 

v   A variable allows us to store a value by assigning it to a name, which can be used later.

v   Named memory locations to store values.

v   Programmers generally choose names for their variables that are meaningful.

v   It can be of any length. No space is allowed.

v   We don't need to declare a variable before using it. In Python, we simply assign a value to a variable and it will exist.

 

Assigning value to variable:

 

Value should be given on the right side of assignment operator(=) and variable on left side.

>>>counter =45

print(counter)

Assigning a single value to several variables simultaneously:

>>> a=b=c=100

Assigning multiple values to multiple variables:

>>> a,b,c=2,4,"ram"

 

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Problem Solving and Python Programming : Data, Expressions, Statements : Variables - Python |

Related Topics

Problem Solving and Python Programming : Data, Expressions, Statements


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.