Python

Types of Variables, Assigning, declaring and deleting variables.

Types of variables

There are two types of variables in python  local and global variables.

•     In Python, global variable is a variable declared outside of the function or in global scope.

•    global variable can be accessed inside or outside of the scope  function

Local variables

Local variables are the variables that are used with in a function or method.

Global variables

Global variables are used when we use the variable in the entire program.

Assigning values to variables

•  Python allows us to assign values to the variables.

• Lets assume the value 5 is assigned to the variable ‘a’

Multiple assignment

• In multiple assignment , multiple variables are assigned with multiple values.

Example

Declaring and re-declaring the variables.

•  Lets first see how to declare a variable. Its that simple that assigning variable a value to hold.

Example

>>> a=9

>>> print(a)

9

Now we re declare the variable.

   a=9

print(a)

a= 33

print(a)

output:

33

Here the output gives the re assigned value instead of first value. This means that the first value is replaced by second  value.

Deleting the variable

• In python you can delete the variable that you  previously assigned  the value using del command.

Example

a=7

print(a)

del a

print(a)

Lakshmi Durga

Share
Published by
Lakshmi Durga

Recent Posts

Google Spam Update 2025: Impact, Recovery Guide & SpamBrain Explained

Google released a spam update on 26th of August 2025 and this is affecting a…

2 weeks ago

Google Experiments with Black Sitelink Colors instead of Blue

Google keeps on testing google search display all the time and this time we are…

1 year ago

What are Template Tags in WordPress? How to Use Template Tags

In wordpress if you are developing new or custom wordpress theme or wordpress plugin then…

2 years ago

Google Search Indexing Issues Started on 31st January to February 2024

If you are experiencing indexing issues of your website then you are not alone and…

2 years ago

Create QR Code for Pages & Post using Plugin in WordPress

On your wordpress website if you want to generate qr code for pages and posts…

2 years ago

Add Google Search Console HTML File Upload on WordPress

If you are trying to verify your WordPress website with google search console with html…

2 years ago