VARIABLE TYPES IN PYTHON | PYTHON-VARIABLE TYPES

 Types Of Python Variables:


The variable is a container that stores a data value in computer memory. Here we see two types of variables in Python.

1. LOCAL VARIABLE: -

Local variables are the variables that are declared inside the function and have scope within the function. Let's understand the following example.

Python - Variables Types | Variable Types In Python | DiplomaWale.blogspot.com
Local Variable


CLICK HERE TO KNOW ABOUT: WHAT IS VARIABLE IN PYTHON?

2. GLOBAL VARIABLE: -

Global variables can be used throughout the program, and its scope is in the entire program. We can use global variables inside or outside the function.

A variable declared outside the function is the global variable by default. Python provides the global keyword to use a global variable inside the function. If we don't use the global keyword, the function treats it as a local variable. Let's understand the following example.

Python - Variables Types | Variable Types In Python | DiplomaWale.blogspot.com
Global Variable


MULTI WORDS VARIABLE NAME:

Variable names with more than one word can be difficult to read. There are several techniques you can use to make them more readable-

1. CAMEL CASE: In the camel case, each word or abbreviation in the middle begins with a capital letter. There is no intervention of whitespace. For example - nameOfStudent, value Of Variable, etc.

Python - Variables Types | Variable Types In Python | CAMELCASE IN PYTHON | DiplomaWale.blogspot.com
CAMEL CASE


2. PASCAL CASE: It is the same as the Camel Case, but here the first word is also capitalized. For example - NameOfStudent, etc.

Python - Variables Types | Variable Types In Python | PASCAL CASE IN PYTHON | DiplomaWale.blogspot.com
PASCAL CASE

3. SNAKE CASE: In the snake case, Words are separated by the underscore. For example - name_of_student, etc.

Python - Variables Types | Variable Types In Python | SNAKE CASE IN PYTHON | DiplomaWale.blogspot.com
SNAKE CASE

MULTIPLE ASSIGNMENT: 

Python allows us to assign a value to multiple variables in a single statement, which is also known as multiple assignments.

We can apply multiple assignments in two ways, either by assigning a single value to multiple variables or assigning multiple values to multiple variables. Consider the following example.

1. ASSIGN SINGLE VALUE TO MULTIPLE VARIABLES: 

Python - Variables Types | Variable Types In Python | DiplomaWale.blogspot.com
SINGLE VALUE


CLICK HERE TO KNOW ABOUT: WHAT IS VARIABLE IN PYTHON?

2. ASSIGNING TO MULTIPLE VALUES TO MULTIPLE VARIABLES:

Python - Variables Types | Variable Types In Python | DiplomaWale.blogspot.com
MULTIPLE VALUE



Post a Comment

0 Comments