0% found this document useful (0 votes)
128 views

Variables and Data Types in Python

The document discusses variables and data types in Python. It explains that variables are names bound to objects and shows examples of assigning values to variables. Different data types in Python are also covered, such as integers, floats, booleans and strings. Rules for naming variables and how variable values are assigned are demonstrated through examples.

Uploaded by

viswa teja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
128 views

Variables and Data Types in Python

The document discusses variables and data types in Python. It explains that variables are names bound to objects and shows examples of assigning values to variables. Different data types in Python are also covered, such as integers, floats, booleans and strings. Rules for naming variables and how variable values are assigned are demonstrated through examples.

Uploaded by

viswa teja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Variables & Data Types

Scenario
Salary List
Scenario
Salary List
₹1M
₹1.5M
₹1.8M
₹0.9M

₹1.6M

₹2M
Scenario
Salary List
₹1M
₹1.5M
₹1.8M
₹0.9M

₹1.6M

₹2M
Scenario
Salary List
Ramesh - 1M

Suresh – 1.5M

Krishna – 0.9M

Rahul – 1.6M

Swati – 1.8M

Sam – 2M
Variables

Ramesh -10L
What are Variables?
Suresh -15L
Variables are names bounded to objects.
Krishna -9L

Rahul -16L

Swati -8L

Sam -20L
Variables

Ramesh -1M
What are Variables?
Suresh -1.5M
Variables are names bounded to objects.
Krishna -0.9M

Rahul -1.6M

Swati -1.8M

Sam -2M
Variables
Variables

Ramesh -1M
What are Variables?
Suresh -1.5M
Variables are names bounded to objects.
Krishna -0.9M

Rahul -1.6M

Swati -1.8M

Sam -2M
Variables in Python

Variable Assignment
Variables in Python

Variable Assignment

● Variable_name = Value

A=5
B = 10
Variables naming rules in Python

● Python is case-sensitive

A=5 is different from a=5


Variables naming rules in Python

● Python is case-sensitive

A=5 is different from a=5

● Variable name cannot start with special character except underscore (_)

_sam=5 is valid
Variables naming rules in Python

● Python is case-sensitive

A=5 is different from a=5

● Variable name cannot start with special character except underscore (_)

_sam=5 is valid

@sam=5 is invalid
Variables naming rules in Python

● Python is case-sensitive

A=5 is different from a=5

● Variable name cannot start with special character except underscore (_)

_sam=5 is valid

@sam=5 is invalid

● Variable name cannot start with a number

9sam =5 is invalid
Variables naming rules in Python

● Python is case-sensitive

A=5 is different from a=5

● Variable name cannot start with special character except underscore (_)

_sam=5 is valid

@sam=5 is invalid

● Variable name cannot start with a number

9sam =5 is invalid sa9m =5 is valid


Data types in Python

int – Integer numbers, bool – Boolean values,


Eg:- 4, -5 etc. Eg:- True and False

float – Decimal numbers, str – Strings,


Eg:- 4.5, -6.7 etc. Eg:- “Python”
How do variables work?

a = 10
b=a
a=6

What is the value of a and b?


How do variables work?

10
a
a = 10
b=a
a=6

What is the value of a and b?


How do variables work?

10
a
a = 10
b=a b
a=6

What is the value of a and b?


How do variables work?

10

a = 10
b=a b
a=6
6
a
What is the value of a and b?

Ans. a is 6 and b is 10

You might also like