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

XII Python Revision tour-II

Data types represent the type of values that variables can hold in Python, such as integers, floats, strings, lists, tuples, and more. Python is dynamically typed, meaning variables can hold values of different types without explicitly declaring the type. There are built-in functions like type() and id() that return the data type and memory address of a value. Variables are labels that refer to memory locations used to store and access values during a program's execution. Variables in Python can hold values of any type and reuse the same variable name.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views

XII Python Revision tour-II

Data types represent the type of values that variables can hold in Python, such as integers, floats, strings, lists, tuples, and more. Python is dynamically typed, meaning variables can hold values of different types without explicitly declaring the type. There are built-in functions like type() and id() that return the data type and memory address of a value. Variables are labels that refer to memory locations used to store and access values during a program's execution. Variables in Python can hold values of any type and reuse the same variable name.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Data Types in Python

 Data Type represent types of data or values , a variables can hold.


for Example:- a=10 # represents int
f=10.0 # represents float
 In python, we are not required to mention any type explicitly, based on your provided valued automatically
type will considered, such type is called dynamically typed programming language.
 Data types are used to stored the data temporarily in our computer through program.
 We have following types of data types in python.
int
float
complex
bool
str
list
tuple
set
frozenset
dict
bytes
bytearray
range
None
 In python, everything will be object, for example:-integer, decimal value, and Boolean value all are object
Example
a=10
type(a)# type is an python inbuild function
id(a)# id is python build function

type():- returns the type of variable or object a variable nhold.


a=10
print(type(a),a)#int,10

id():- returns the address of those values. If you are supposed to change the value, address will also changed

a=10
print(id(a))
print(a)
a=20
print(b)
print(id(b))
Variable:
A variable is a label for a location in memory. It can be used to hold a value.
In statically typed languages, variables have predetermined types, and a variable can only
be used to hold values of that type. In Python, we may reuse the same variable to store
values of any type.

Defining variables

To define a new variable in Python, we simply assign a value to a label. For example, this
is how we create a variable called COUNT, which contains an integer value of zero
count = 0

LValues : These are the objects to which you can assign a value or expression. LValues can come on
lhs or rhs of an assignment statement.
RValues : These are the literals and expressions that are assigned to LValues.
e.g. a = 20
b = 10
a and b are LValues , whereas 20 and 10 are RValues.

MULTIPLE ASSIGMENT
1. Assigning same value to multiple variables
You can assign same value to multiple variables in a single statement, e.g.
a = b = c = 10
It will assign value 10 to all three variables a, b, c.

2. Assigning multiple values to multiple variables


You can even assign multiple values to multiple variables in single statement, e.g.
x, y , z = 10 , 20 , 30
It will assign the values order wise, i.e., first variable is given first value, second variable the
second value and so on. That means, above statement will assign value 10 to x , 20 to y and 30 to
z.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy