SlideShare uma empresa Scribd logo
1 de 33
PYTHON
DATA TYPE AND VARIABLES IN PYTHON
CLASS: XI
COMPUTER SCIENCE(083)
Variable:
Variable is a name that is used to refer to memory location.
Python variable is also known as an identifier and used to hold
value.
A Python variable is a reserved memory location to store
values. In other words, a variable in a python program gives
data to the computer for processing.
How we declare variable.
ch=‘A’ or ch=“A” nm=‘Computer’ or nm=“Computer”
a=10 b=10.89
Identifier Identifier
Methods of declaring and initializing variables:
To assign value to a variable we need to use (= equal)
assignment operator.
Example: If we want to declare a integer variable A and want
to store 10.So we use =(assignment operator) and assign
value 10 to variable A.
A = 10
A is L-value 10 is R-valueAssignment
operator
Components of variable or objects:
Identity Type Value
It refers to the
memory address
which does not
change once it has
been created.
If you want to
determine the data
type of variable ,that
what type of value
does it hold.
It refers to the data
store inside the
variable that we
declared.
Example: A=10 So A is a variable and 10 is the value
store inside it.
Now how you know the memory address and datatype name
of a variable A.
Example: A=10
Identity To know the identity or memory address use id().
A=10
print(id(A))
----OUTPUT---
-
1437714496
Type To know the data type of a variable use type()
A=10
print(type(A))
----OUTPUT---
-
<class 'int'>
Different methods of assignments:
If we want to assign value 10 to A and 20 to B
A=10
B=20
If we want to assign value 10 to A ,B , and C
A=B=C=10
Different methods of assignments:
If we want to assign multiple value in a multiple variables : A
value 10 , B value 20 and C value 30
A=10
B=20
If we want to assign multiple value in a multiple variables using
single line
A ,B , C= 10 , 20 , 30
C=30
Data Type:
Standard Data Types
Data types refer to the type of data used in the
program. The data stored in memory can be of many
types.
In this we discuss :
Python has five standard data types:
Dictionary
Number
String Lis
t
Tuple
Number Data type
It store numerical values. The integer, float, and complex
values belong to a Python Numbers data-type.
Example:
It denotes
whole numbers
without
fractional part
It denotes
floating
values(with
fractional part)
It is made up of pairs real and
imaginary numbers. Where 2 is a real
part and 5j is imaginary(5 is float and
j is square root of an imaginary
number)
How to Declare , Initialize and use a Variable
Example: If we want to store a value 20 in a variable A.
Means we need to declare a variable A and store value 20 as
integer / number(0-9)
Example: If we want to store a value 78.5263 in a variable A
and -5.235 in a variable B
Means we need to declare a variable A
How to declare character variable?
Example: If we want to store a value ‘A’ character in a variable
ch. Means we need to declare a variable ch and store
character ‘A’ in it.
Character , words or paragraph use single quotes
(‘) or double quotes(“)
How to Declare , Initialize and use a Variable
Example: If we want to store a value ‘computer’ word or
string in a variable nm. Means we need to declare a variable
nm and store word ‘computer’ in it.
word=‘computer’
Character , words, string or paragraph use single quotes (‘)
or double quotes(“)
word=“computer”OR
How to store string value:
line=‘Welcome to python’ line=“Welcome to python”OR
How to Display the values inside the Variable?
To join statement with variable use
,(comma) sign
How to Display the values inside the Variable?
Method 1: to initialize variable Method 2: to initialize A,B in a
single line
How to Display the values inside the Variable?
Now if we want to store integer and floating value in a variable
Method 1: to initialize variable Method 2: to initialize variable
How to Display the values inside the Variable?
How to Display the values inside the Variable?
How to Display the values inside the Variable?
Now if we want to store integer,floating, character, and string value in a
variable
Method 1: to initialize variable
Method 2: to initialize variable with mixed values in a single line
If we want that the value of the variable enter through keyboard
at runtime.
In Python, we have the input() function to accept values from the
user at runtime. By default value accept using input is string.
For Example if we want to accept the name of a person and display it.
nm=input(“Enter the name:”)
print(“Name:”,nm)
-----Output----
Enter the name: Max
Name: Max
Example: If we want to accept number using input() function.
no=input(“Enter the value:”)
print(“No=“,no)
-----Output----
Enter the value: 20
No=‘20’
So how we convert the string into integer or float.
Means how we accept the floating or integer value from user at
runtime.
We need to convert the string into float or integer using type
conversation functions provided by python
int() float() eval()
It convert
the string
value into
integer
value only.
It convert
the string
value into
floating
value only.
It is used to evaluate
the value of a string
means if the value is
integer it convert it to
integer and if the value
is floating it convert it
to float.
Example: Accept two numbers in a variable A,B and display sum of
these two number.
A=input(“Enter the value of A:”)
B=input(“Enter the value of B:”)
print(“A+B=“,A+B
)
-----Output----
Enter the value of A: 10
Enter the value of B: 20
A+B= 1020
It join the value because both are string and + works a
concatenation
Example: Accept two numbers in a variable A,B and display sum of
these two number.
A=int(input(“Enter the value of A:”))
B=int(input(“Enter the value of B:”))
print(“A+B=“,A+B
)
-----Output----
Enter the value of A: 10
Enter the value of B: 20
A+B= 30
Example: Accept two floating numbers in a variable A,B and
display sum of these two number.
A=float(input(“Enter the value of A:”))
B=float(input(“Enter the value of
B:”))
print(“A+B=“,A+B
)
-----Output----
Enter the value of A: 1.56
Enter the value of B: 1.23
A+B= 2.79
eval() is the function used to convert the value automatically on
the basis of value input.
Example:
A=‘25’
B=eval(A)
-----Output----
<class ‘string’>
< class ‘int’>
print(type(A))
print(type(B))
If we store string ‘10+20’ in a variable A and need to display the
sum using another variable B
Example:
A=’10+20
’
B=eval(A)
-----Output----
30
print(B)
eval() function convert first the string value
into integer and then read +(plus) sign add
the two values and store in a variable B so B
will be integer type.
If we accept the value from user and convert the variable integer or
floating at runtime , so we use eval().
Example:
A=eval(input(“Enter the value:”))
print(type(A)) -----Output----
Enter the value: 15
‘<class int>’
15
print(A)
-----Output----
Enter the value: 5.26
‘<class float>’
5.26
Question: Accept the value of two variable A,B from user and print
the variable name and value.
----Output------
Enter the value for A: 10
Enter the value for B: 20
A=10 B=20
A=int(input(“Enter the value for
A:”))
B=int(input(“Enter the value for B:”))
print(“A=“,A,”
B=“,B)
Question: Accept the rollno, name and age of a student from user and
display it as shown below:
----Output------
Enter Rollno: 101
Enter name: Amit
Enter Age: 15
Rollno****Name****Age
101 Amit 15
rollno=int(input(“Enter Rollno:”))
nm=input(“Enter Name:”)
print(“Rollno*******Name******Age”)
age=int(input(“Enter Age:”))
print(rollno,”t”,nm,”t”,age)
Question: Program to display the output using t
-------OUTPUT-------
1992 17489
1993 29378
1994 100123
1995 120120
Question: Program to using single print() display the following
variable with values
-------OUTPUT-------
Prog=25
Doc=45
Logic=15
Flow=16
print(1992,17489,sep=‘t’)
print(1993,29378, ,sep=‘t’)
print(1994,100123, ,sep=‘t’)
print(1995,120120, ,sep=‘t’)

Mais conteúdo relacionado

Mais procurados (20)

Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
 
Embedded C - Day 2
Embedded C - Day 2Embedded C - Day 2
Embedded C - Day 2
 
Input processing and output in Python
Input processing and output in PythonInput processing and output in Python
Input processing and output in Python
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
 
Arrays
ArraysArrays
Arrays
 
USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshop
 
Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
Unit ii ppt
Unit ii pptUnit ii ppt
Unit ii ppt
 
Python : Operators
Python : OperatorsPython : Operators
Python : Operators
 
Chap 6 c++
Chap 6 c++Chap 6 c++
Chap 6 c++
 
Chap 6 c++
Chap 6 c++Chap 6 c++
Chap 6 c++
 
C aptitude scribd
C aptitude scribdC aptitude scribd
C aptitude scribd
 
Simple IO Monad in 'Functional Programming in Scala'
Simple IO Monad in 'Functional Programming in Scala'Simple IO Monad in 'Functional Programming in Scala'
Simple IO Monad in 'Functional Programming in Scala'
 
Unit2 input output
Unit2 input outputUnit2 input output
Unit2 input output
 
Python-02| Input, Output & Import
Python-02| Input, Output & ImportPython-02| Input, Output & Import
Python-02| Input, Output & Import
 
CSE240 Pointers
CSE240 PointersCSE240 Pointers
CSE240 Pointers
 

Semelhante a DATA TYPE IN PYTHON

CS-XII Python Fundamentals.pdf
CS-XII Python Fundamentals.pdfCS-XII Python Fundamentals.pdf
CS-XII Python Fundamentals.pdfIda Lumintu
 
IMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptxIMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptxlemonchoos
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptxAkshayAggarwal79
 
23UCACC11 Python Programming (MTNC) (BCA)
23UCACC11 Python Programming (MTNC) (BCA)23UCACC11 Python Programming (MTNC) (BCA)
23UCACC11 Python Programming (MTNC) (BCA)ssuser7f90ae
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxKoteswari Kasireddy
 
PE1 Module 2.ppt
PE1 Module 2.pptPE1 Module 2.ppt
PE1 Module 2.pptbalewayalew
 
009 Data Handling .pptx
009 Data Handling .pptx009 Data Handling .pptx
009 Data Handling .pptxssuser6c66f3
 
Ap Power Point Chpt2
Ap Power Point Chpt2Ap Power Point Chpt2
Ap Power Point Chpt2dplunkett
 
Java căn bản - Chapter3
Java căn bản - Chapter3Java căn bản - Chapter3
Java căn bản - Chapter3Vince Vo
 
The Input Statement in Core Python .pptx
The Input Statement in Core Python .pptxThe Input Statement in Core Python .pptx
The Input Statement in Core Python .pptxKavitha713564
 
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxCS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxfaithxdunce63732
 

Semelhante a DATA TYPE IN PYTHON (20)

CS-XII Python Fundamentals.pdf
CS-XII Python Fundamentals.pdfCS-XII Python Fundamentals.pdf
CS-XII Python Fundamentals.pdf
 
IMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptxIMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptx
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
 
23UCACC11 Python Programming (MTNC) (BCA)
23UCACC11 Python Programming (MTNC) (BCA)23UCACC11 Python Programming (MTNC) (BCA)
23UCACC11 Python Programming (MTNC) (BCA)
 
unit 1.docx
unit 1.docxunit 1.docx
unit 1.docx
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptx
 
MODULE. .pptx
MODULE.                              .pptxMODULE.                              .pptx
MODULE. .pptx
 
types.pdf
types.pdftypes.pdf
types.pdf
 
PE1 Module 2.ppt
PE1 Module 2.pptPE1 Module 2.ppt
PE1 Module 2.ppt
 
009 Data Handling .pptx
009 Data Handling .pptx009 Data Handling .pptx
009 Data Handling .pptx
 
Ap Power Point Chpt2
Ap Power Point Chpt2Ap Power Point Chpt2
Ap Power Point Chpt2
 
Python
PythonPython
Python
 
Python PPT2
Python PPT2Python PPT2
Python PPT2
 
python
pythonpython
python
 
Java căn bản - Chapter3
Java căn bản - Chapter3Java căn bản - Chapter3
Java căn bản - Chapter3
 
C Programming Unit-4
C Programming Unit-4C Programming Unit-4
C Programming Unit-4
 
The Input Statement in Core Python .pptx
The Input Statement in Core Python .pptxThe Input Statement in Core Python .pptx
The Input Statement in Core Python .pptx
 
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxCS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
 
C pointers and references
C pointers and referencesC pointers and references
C pointers and references
 
Python - variable types
Python - variable typesPython - variable types
Python - variable types
 

Mais de vikram mahendra

Python Project On Cosmetic Shop system
Python Project On Cosmetic Shop systemPython Project On Cosmetic Shop system
Python Project On Cosmetic Shop systemvikram mahendra
 
Python Project on Computer Shop
Python Project on Computer ShopPython Project on Computer Shop
Python Project on Computer Shopvikram mahendra
 
PYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEMPYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEMvikram mahendra
 
BOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in PythonBOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in Pythonvikram mahendra
 
FLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHONFLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHONvikram mahendra
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONvikram mahendra
 
LIST IN PYTHON[SELECTION SORT]
LIST IN PYTHON[SELECTION SORT]LIST IN PYTHON[SELECTION SORT]
LIST IN PYTHON[SELECTION SORT]vikram mahendra
 
DATA REPRESENTATION-NUMBER SYSTEM-PART-5
DATA REPRESENTATION-NUMBER SYSTEM-PART-5DATA REPRESENTATION-NUMBER SYSTEM-PART-5
DATA REPRESENTATION-NUMBER SYSTEM-PART-5vikram mahendra
 
DATA REPRESENTATION-NUMBER SYSTEM
DATA REPRESENTATION-NUMBER SYSTEMDATA REPRESENTATION-NUMBER SYSTEM
DATA REPRESENTATION-NUMBER SYSTEMvikram mahendra
 
LIST IN PYTHON[BUBBLE SORT]
LIST IN PYTHON[BUBBLE SORT]LIST IN PYTHON[BUBBLE SORT]
LIST IN PYTHON[BUBBLE SORT]vikram mahendra
 
Internet,its applications and services
Internet,its applications and servicesInternet,its applications and services
Internet,its applications and servicesvikram mahendra
 
DATA REPRESENTATION [NUMBER SYSTEM]
DATA REPRESENTATION [NUMBER SYSTEM]DATA REPRESENTATION [NUMBER SYSTEM]
DATA REPRESENTATION [NUMBER SYSTEM]vikram mahendra
 

Mais de vikram mahendra (20)

Communication skill
Communication skillCommunication skill
Communication skill
 
Python Project On Cosmetic Shop system
Python Project On Cosmetic Shop systemPython Project On Cosmetic Shop system
Python Project On Cosmetic Shop system
 
Python Project on Computer Shop
Python Project on Computer ShopPython Project on Computer Shop
Python Project on Computer Shop
 
PYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEMPYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEM
 
BOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in PythonBOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in Python
 
FLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHONFLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHON
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHON
 
Python Introduction
Python IntroductionPython Introduction
Python Introduction
 
GREEN SKILL[PART-2]
GREEN SKILL[PART-2]GREEN SKILL[PART-2]
GREEN SKILL[PART-2]
 
GREEN SKILLS[PART-1]
GREEN SKILLS[PART-1]GREEN SKILLS[PART-1]
GREEN SKILLS[PART-1]
 
Dictionary in python
Dictionary in pythonDictionary in python
Dictionary in python
 
Entrepreneurial skills
Entrepreneurial skillsEntrepreneurial skills
Entrepreneurial skills
 
Boolean logic
Boolean logicBoolean logic
Boolean logic
 
Tuple in python
Tuple in pythonTuple in python
Tuple in python
 
LIST IN PYTHON[SELECTION SORT]
LIST IN PYTHON[SELECTION SORT]LIST IN PYTHON[SELECTION SORT]
LIST IN PYTHON[SELECTION SORT]
 
DATA REPRESENTATION-NUMBER SYSTEM-PART-5
DATA REPRESENTATION-NUMBER SYSTEM-PART-5DATA REPRESENTATION-NUMBER SYSTEM-PART-5
DATA REPRESENTATION-NUMBER SYSTEM-PART-5
 
DATA REPRESENTATION-NUMBER SYSTEM
DATA REPRESENTATION-NUMBER SYSTEMDATA REPRESENTATION-NUMBER SYSTEM
DATA REPRESENTATION-NUMBER SYSTEM
 
LIST IN PYTHON[BUBBLE SORT]
LIST IN PYTHON[BUBBLE SORT]LIST IN PYTHON[BUBBLE SORT]
LIST IN PYTHON[BUBBLE SORT]
 
Internet,its applications and services
Internet,its applications and servicesInternet,its applications and services
Internet,its applications and services
 
DATA REPRESENTATION [NUMBER SYSTEM]
DATA REPRESENTATION [NUMBER SYSTEM]DATA REPRESENTATION [NUMBER SYSTEM]
DATA REPRESENTATION [NUMBER SYSTEM]
 

Último

ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsManeerUddin
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 

Último (20)

ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture hons
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 

DATA TYPE IN PYTHON

  • 1. PYTHON DATA TYPE AND VARIABLES IN PYTHON CLASS: XI COMPUTER SCIENCE(083)
  • 2. Variable: Variable is a name that is used to refer to memory location. Python variable is also known as an identifier and used to hold value. A Python variable is a reserved memory location to store values. In other words, a variable in a python program gives data to the computer for processing. How we declare variable. ch=‘A’ or ch=“A” nm=‘Computer’ or nm=“Computer” a=10 b=10.89 Identifier Identifier
  • 3. Methods of declaring and initializing variables: To assign value to a variable we need to use (= equal) assignment operator. Example: If we want to declare a integer variable A and want to store 10.So we use =(assignment operator) and assign value 10 to variable A. A = 10 A is L-value 10 is R-valueAssignment operator
  • 4. Components of variable or objects: Identity Type Value It refers to the memory address which does not change once it has been created. If you want to determine the data type of variable ,that what type of value does it hold. It refers to the data store inside the variable that we declared. Example: A=10 So A is a variable and 10 is the value store inside it. Now how you know the memory address and datatype name of a variable A.
  • 5. Example: A=10 Identity To know the identity or memory address use id(). A=10 print(id(A)) ----OUTPUT--- - 1437714496 Type To know the data type of a variable use type() A=10 print(type(A)) ----OUTPUT--- - <class 'int'>
  • 6. Different methods of assignments: If we want to assign value 10 to A and 20 to B A=10 B=20 If we want to assign value 10 to A ,B , and C A=B=C=10
  • 7. Different methods of assignments: If we want to assign multiple value in a multiple variables : A value 10 , B value 20 and C value 30 A=10 B=20 If we want to assign multiple value in a multiple variables using single line A ,B , C= 10 , 20 , 30 C=30
  • 8. Data Type: Standard Data Types Data types refer to the type of data used in the program. The data stored in memory can be of many types. In this we discuss : Python has five standard data types: Dictionary Number String Lis t Tuple
  • 9. Number Data type It store numerical values. The integer, float, and complex values belong to a Python Numbers data-type. Example: It denotes whole numbers without fractional part It denotes floating values(with fractional part) It is made up of pairs real and imaginary numbers. Where 2 is a real part and 5j is imaginary(5 is float and j is square root of an imaginary number)
  • 10. How to Declare , Initialize and use a Variable Example: If we want to store a value 20 in a variable A. Means we need to declare a variable A and store value 20 as integer / number(0-9) Example: If we want to store a value 78.5263 in a variable A and -5.235 in a variable B Means we need to declare a variable A
  • 11. How to declare character variable? Example: If we want to store a value ‘A’ character in a variable ch. Means we need to declare a variable ch and store character ‘A’ in it. Character , words or paragraph use single quotes (‘) or double quotes(“)
  • 12. How to Declare , Initialize and use a Variable Example: If we want to store a value ‘computer’ word or string in a variable nm. Means we need to declare a variable nm and store word ‘computer’ in it. word=‘computer’ Character , words, string or paragraph use single quotes (‘) or double quotes(“) word=“computer”OR How to store string value: line=‘Welcome to python’ line=“Welcome to python”OR
  • 13. How to Display the values inside the Variable? To join statement with variable use ,(comma) sign
  • 14. How to Display the values inside the Variable? Method 1: to initialize variable Method 2: to initialize A,B in a single line
  • 15. How to Display the values inside the Variable?
  • 16. Now if we want to store integer and floating value in a variable Method 1: to initialize variable Method 2: to initialize variable
  • 17. How to Display the values inside the Variable?
  • 18. How to Display the values inside the Variable?
  • 19. How to Display the values inside the Variable?
  • 20. Now if we want to store integer,floating, character, and string value in a variable Method 1: to initialize variable
  • 21. Method 2: to initialize variable with mixed values in a single line
  • 22. If we want that the value of the variable enter through keyboard at runtime. In Python, we have the input() function to accept values from the user at runtime. By default value accept using input is string. For Example if we want to accept the name of a person and display it. nm=input(“Enter the name:”) print(“Name:”,nm) -----Output---- Enter the name: Max Name: Max
  • 23. Example: If we want to accept number using input() function. no=input(“Enter the value:”) print(“No=“,no) -----Output---- Enter the value: 20 No=‘20’ So how we convert the string into integer or float. Means how we accept the floating or integer value from user at runtime. We need to convert the string into float or integer using type conversation functions provided by python
  • 24. int() float() eval() It convert the string value into integer value only. It convert the string value into floating value only. It is used to evaluate the value of a string means if the value is integer it convert it to integer and if the value is floating it convert it to float.
  • 25. Example: Accept two numbers in a variable A,B and display sum of these two number. A=input(“Enter the value of A:”) B=input(“Enter the value of B:”) print(“A+B=“,A+B ) -----Output---- Enter the value of A: 10 Enter the value of B: 20 A+B= 1020 It join the value because both are string and + works a concatenation
  • 26. Example: Accept two numbers in a variable A,B and display sum of these two number. A=int(input(“Enter the value of A:”)) B=int(input(“Enter the value of B:”)) print(“A+B=“,A+B ) -----Output---- Enter the value of A: 10 Enter the value of B: 20 A+B= 30
  • 27. Example: Accept two floating numbers in a variable A,B and display sum of these two number. A=float(input(“Enter the value of A:”)) B=float(input(“Enter the value of B:”)) print(“A+B=“,A+B ) -----Output---- Enter the value of A: 1.56 Enter the value of B: 1.23 A+B= 2.79
  • 28. eval() is the function used to convert the value automatically on the basis of value input. Example: A=‘25’ B=eval(A) -----Output---- <class ‘string’> < class ‘int’> print(type(A)) print(type(B))
  • 29. If we store string ‘10+20’ in a variable A and need to display the sum using another variable B Example: A=’10+20 ’ B=eval(A) -----Output---- 30 print(B) eval() function convert first the string value into integer and then read +(plus) sign add the two values and store in a variable B so B will be integer type.
  • 30. If we accept the value from user and convert the variable integer or floating at runtime , so we use eval(). Example: A=eval(input(“Enter the value:”)) print(type(A)) -----Output---- Enter the value: 15 ‘<class int>’ 15 print(A) -----Output---- Enter the value: 5.26 ‘<class float>’ 5.26
  • 31. Question: Accept the value of two variable A,B from user and print the variable name and value. ----Output------ Enter the value for A: 10 Enter the value for B: 20 A=10 B=20 A=int(input(“Enter the value for A:”)) B=int(input(“Enter the value for B:”)) print(“A=“,A,” B=“,B)
  • 32. Question: Accept the rollno, name and age of a student from user and display it as shown below: ----Output------ Enter Rollno: 101 Enter name: Amit Enter Age: 15 Rollno****Name****Age 101 Amit 15 rollno=int(input(“Enter Rollno:”)) nm=input(“Enter Name:”) print(“Rollno*******Name******Age”) age=int(input(“Enter Age:”)) print(rollno,”t”,nm,”t”,age)
  • 33. Question: Program to display the output using t -------OUTPUT------- 1992 17489 1993 29378 1994 100123 1995 120120 Question: Program to using single print() display the following variable with values -------OUTPUT------- Prog=25 Doc=45 Logic=15 Flow=16 print(1992,17489,sep=‘t’) print(1993,29378, ,sep=‘t’) print(1994,100123, ,sep=‘t’) print(1995,120120, ,sep=‘t’)