SlideShare une entreprise Scribd logo
1  sur  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’)

Contenu connexe

Tendances (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
 

Similaire à 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
 

Similaire à 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
 

Plus 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
 

Plus 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]
 

Dernier

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 

Dernier (20)

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 

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’)