Sunday 12 February 2023

Python variables

Variables in python

Variable is nothing but a name given to a memory location. A variable may change value from time to time. The size of the variable is decided based on the type of the variable initialized by the programmer initially or in the run-time.

Rules for naming a variable 

  • A variable must start with a letter or underscore
  • A variable should not start with a digit
  • A variable must contain only alpha numeric characters with underscores only
  • Reserved words should not be variables
  • Variable names are case sensitive so (variable1 and Variable1 are different)

Initialization of variables

Assigning value to single variable

Initialization of one variable at a time .The variable is assigned using the Assignment operator (=) equal to.
say_hello='Hello'
print(say_hello)
Output
Hello

Multiple variable assignment

Multiple variable assignment can be done in a single line.
#Mutiple variables assignment
name,age,gender='Ashok',25,'Male'
print('My name is',name,'and i am',age,'years old',gender,'student.')
Output
My name is Ashok and i am 25 years old Male student.

0 comments :

Post a Comment

Note: only a member of this blog may post a comment.

Machine Learning

More

Advertisement

Java Tutorial

More

UGC NET CS TUTORIAL

MFCS
COA
PL-CG
DBMS
OPERATING SYSTEM
SOFTWARE ENG
DSA
TOC-CD
ARTIFICIAL INT

C Programming

More

Python Tutorial

More

Data Structures

More

computer Organization

More
Top