SlideShare a Scribd company logo
print("Halt!")
user_input = input("Who goes there? ")
print("You may pass,", user_input)
• input() function was used
• user_input is a variable.
• Variables are like a box that can store some piece of data
a = 123.4
b23 = 'Spam'
first_name = "Bill"
b = 432
c = a + b
print("a + b is",c)
print("first_name
is",first_name)
print("Sorted Parts,
After Midnight or",b23)
• The variables in the
above program are
a, b23,
first_name, b,
and c.
The two basic data
types are strings and
numbers.
Variables that are used
to store a value, do not
use quotation marks ("
and ').
• Strings are a sequence of letters, numbers and other
characters. In this example, b23 and first_name
are variables that are storing strings.
• Spam, Bill, a+ b is, first_name is,
and Sorted Parts, After Midnight or are
the strings in this program.
The characters are surrounded by " or '.
Variables
Variables are containers for storing data
values.
Creating Variables
Python has no command for declaring a
variable.
A variable is created the moment you first
assign a value to it.
Variables do not need to be declared with any
particular type, and can even change type
after they have been set.
x = 5
y = "John"
print(x)
print(y)
x = 4 # x is of type int
x = "Sally" # x is now of type str
print(x)
In Python,
the data type
is set when
you assign a
value to a
variable:
If you want to
specify the data
type, you can
use the
following
constructor
functions:
x = 5
y = "John"
print(x)
print(y)
x = 4 # x is of type int
print(type(x))
x = "Sally" # x is now of type str
print(type(x))
Casting
If you want to specify the data type of a
variable, this can be done with casting.
x = str(3) # x will be '3'
y = int(3) # y will be 3
z = float(3) # z will be 3.0
String variables can be declared either by
using single or double quotes:
Variable names are case-sensitive.
Assignment
While executing the statement c = a + b, The right hand side
of the statement (a + b) is evaluated and the result is stored in the
variable on the left hand side (c).
This is called assignment.
a = 1
print(a)
a = a + 1
print(a)
a = a * 2
print(a)

More Related Content

What's hot

R data types
R   data typesR   data types
R data types
Learnbay Datascience
 
Arrays in c
Arrays in cArrays in c
Arrays in c
Jeeva Nanthini
 
Array in c
Array in cArray in c
Array in c
Ravi Gelani
 
Lecture 16 - Multi dimensional Array
Lecture 16 - Multi dimensional ArrayLecture 16 - Multi dimensional Array
Lecture 16 - Multi dimensional Array
Md. Imran Hossain Showrov
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
Gagan Deep
 
arrays in c
arrays in carrays in c
arrays in c
vidhi mehta
 
Data Wrangling with dplyr and tidyr Cheat Sheet
Data Wrangling with dplyr and tidyr Cheat SheetData Wrangling with dplyr and tidyr Cheat Sheet
Data Wrangling with dplyr and tidyr Cheat Sheet
Dr. Volkan OBAN
 
Datastructures in python
Datastructures in pythonDatastructures in python
Datastructures in python
hydpy
 
Data Types and Structures in R
Data Types and Structures in RData Types and Structures in R
Data Types and Structures in R
Rupak Roy
 
Arrays in c language
Arrays in c languageArrays in c language
Arrays in c language
tanmaymodi4
 
Array in C
Array in CArray in C
Array in C
adityas29
 
Arrays in c
Arrays in cArrays in c
Arrays in c
CHANDAN KUMAR
 
R normal distribution
R   normal distributionR   normal distribution
R normal distribution
Learnbay Datascience
 
Basic data types in python
Basic data types in pythonBasic data types in python
Basic data types in python
sunilchute1
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
eShikshak
 
Array in C
Array in CArray in C
Array in C
Kamal Acharya
 
Python Datatypes by SujithKumar
Python Datatypes by SujithKumarPython Datatypes by SujithKumar
Python Datatypes by SujithKumar
Sujith Kumar
 
6. R data structures
6. R data structures6. R data structures
6. R data structures
ExternalEvents
 

What's hot (20)

R data types
R   data typesR   data types
R data types
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Array in c
Array in cArray in c
Array in c
 
Lecture 16 - Multi dimensional Array
Lecture 16 - Multi dimensional ArrayLecture 16 - Multi dimensional Array
Lecture 16 - Multi dimensional Array
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
 
arrays in c
arrays in carrays in c
arrays in c
 
Data Wrangling with dplyr and tidyr Cheat Sheet
Data Wrangling with dplyr and tidyr Cheat SheetData Wrangling with dplyr and tidyr Cheat Sheet
Data Wrangling with dplyr and tidyr Cheat Sheet
 
Datastructures in python
Datastructures in pythonDatastructures in python
Datastructures in python
 
Data Types and Structures in R
Data Types and Structures in RData Types and Structures in R
Data Types and Structures in R
 
Arrays in c language
Arrays in c languageArrays in c language
Arrays in c language
 
Array in C
Array in CArray in C
Array in C
 
Array
ArrayArray
Array
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Array in c
Array in cArray in c
Array in c
 
R normal distribution
R   normal distributionR   normal distribution
R normal distribution
 
Basic data types in python
Basic data types in pythonBasic data types in python
Basic data types in python
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Array in C
Array in CArray in C
Array in C
 
Python Datatypes by SujithKumar
Python Datatypes by SujithKumarPython Datatypes by SujithKumar
Python Datatypes by SujithKumar
 
6. R data structures
6. R data structures6. R data structures
6. R data structures
 

Similar to python- Variables and data types

Lec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questionsLec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questions
YashJain47002
 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdf
sagar414433
 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdf
sagar414433
 
Python for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.comPython for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.com
ShwetaAggarwal56
 
Python Data Types,numbers.pptx
Python Data Types,numbers.pptxPython Data Types,numbers.pptx
Python Data Types,numbers.pptx
adityakumawat625
 
Python-CH01L04-Presentation.pptx
Python-CH01L04-Presentation.pptxPython-CH01L04-Presentation.pptx
Python-CH01L04-Presentation.pptx
ElijahSantos4
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshop
BAINIDA
 
Introduction to python programming 1
Introduction to python programming   1Introduction to python programming   1
Introduction to python programming 1
Giovanni Della Lunga
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptx
mohitesoham12
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
Utkarsh Sengar
 
Java căn bản - Chapter3
Java căn bản - Chapter3Java căn bản - Chapter3
Java căn bản - Chapter3Vince Vo
 
Data Handling
Data Handling Data Handling
Data Handling
bharath916489
 
Python.pdf
Python.pdfPython.pdf
Python.pdf
Shivakumar B N
 
Monads and Monoids by Oleksiy Dyagilev
Monads and Monoids by Oleksiy DyagilevMonads and Monoids by Oleksiy Dyagilev
Monads and Monoids by Oleksiy Dyagilev
JavaDayUA
 
Mutable data types in python
Mutable data types in pythonMutable data types in python
Mutable data types in python
Learnbay Datascience
 
Introduction to Python , Overview
Introduction to Python , OverviewIntroduction to Python , Overview
Introduction to Python , Overview
NB Veeresh
 
130717666736980000
130717666736980000130717666736980000
130717666736980000
Tanzeel Ahmad
 
Strings.ppt
Strings.pptStrings.ppt
Strings.ppt
kasamamori
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
Golden Julie Jesus
 

Similar to python- Variables and data types (20)

Lec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questionsLec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questions
 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdf
 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdf
 
Python for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.comPython for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.com
 
Python Data Types,numbers.pptx
Python Data Types,numbers.pptxPython Data Types,numbers.pptx
Python Data Types,numbers.pptx
 
Python-CH01L04-Presentation.pptx
Python-CH01L04-Presentation.pptxPython-CH01L04-Presentation.pptx
Python-CH01L04-Presentation.pptx
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshop
 
Introduction to python programming 1
Introduction to python programming   1Introduction to python programming   1
Introduction to python programming 1
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptx
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
 
Java căn bản - Chapter3
Java căn bản - Chapter3Java căn bản - Chapter3
Java căn bản - Chapter3
 
Data Handling
Data Handling Data Handling
Data Handling
 
R교육1
R교육1R교육1
R교육1
 
Python.pdf
Python.pdfPython.pdf
Python.pdf
 
Monads and Monoids by Oleksiy Dyagilev
Monads and Monoids by Oleksiy DyagilevMonads and Monoids by Oleksiy Dyagilev
Monads and Monoids by Oleksiy Dyagilev
 
Mutable data types in python
Mutable data types in pythonMutable data types in python
Mutable data types in python
 
Introduction to Python , Overview
Introduction to Python , OverviewIntroduction to Python , Overview
Introduction to Python , Overview
 
130717666736980000
130717666736980000130717666736980000
130717666736980000
 
Strings.ppt
Strings.pptStrings.ppt
Strings.ppt
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
 

More from SreejaRamesh2

Syllabus for semester 3: complementary course in maths
Syllabus for semester 3: complementary course in mathsSyllabus for semester 3: complementary course in maths
Syllabus for semester 3: complementary course in maths
SreejaRamesh2
 
Pg s2 11.08.2021 d5 filters
Pg s2 11.08.2021 d5 filtersPg s2 11.08.2021 d5 filters
Pg s2 11.08.2021 d5 filters
SreejaRamesh2
 
Pg s2 30.07.2021 _d1
Pg s2 30.07.2021 _d1Pg s2 30.07.2021 _d1
Pg s2 30.07.2021 _d1
SreejaRamesh2
 
questions on matrices part1
 questions on matrices part1 questions on matrices part1
questions on matrices part1
SreejaRamesh2
 
Prove this proposition:
Prove this proposition: Prove this proposition:
Prove this proposition:
SreejaRamesh2
 
Silver-Pohlig-Hellman Algorithm
Silver-Pohlig-Hellman AlgorithmSilver-Pohlig-Hellman Algorithm
Silver-Pohlig-Hellman Algorithm
SreejaRamesh2
 
Closed sets in metric spaces
Closed sets in metric spacesClosed sets in metric spaces
Closed sets in metric spaces
SreejaRamesh2
 
Continuity- solved problems set 1
Continuity- solved problems set 1Continuity- solved problems set 1
Continuity- solved problems set 1
SreejaRamesh2
 
Roots of Unity & Quadratic residues
Roots of Unity & Quadratic residuesRoots of Unity & Quadratic residues
Roots of Unity & Quadratic residues
SreejaRamesh2
 
finite fields of prime power order
finite fields of prime power orderfinite fields of prime power order
finite fields of prime power order
SreejaRamesh2
 
generator of a finite field exists
generator of a finite field existsgenerator of a finite field exists
generator of a finite field exists
SreejaRamesh2
 
probability of generators
probability  of generatorsprobability  of generators
probability of generators
SreejaRamesh2
 
Topologies on the Set of Real Numbers
Topologies on the Set of Real NumbersTopologies on the Set of Real Numbers
Topologies on the Set of Real Numbers
SreejaRamesh2
 
Echelon form of a matrix
Echelon form of a matrixEchelon form of a matrix
Echelon form of a matrix
SreejaRamesh2
 
python- print function and arithmetic expressions
python- print function and arithmetic expressionspython- print function and arithmetic expressions
python- print function and arithmetic expressions
SreejaRamesh2
 
Basic Topology- Syllabus
Basic Topology- SyllabusBasic Topology- Syllabus
Basic Topology- Syllabus
SreejaRamesh2
 
Elementary Transformations of Matrices
Elementary Transformations of MatricesElementary Transformations of Matrices
Elementary Transformations of Matrices
SreejaRamesh2
 
Rank of a matrix:::Definition
Rank of a matrix:::DefinitionRank of a matrix:::Definition
Rank of a matrix:::Definition
SreejaRamesh2
 
Lagrange's Equation:: Solved Problems Set1
Lagrange's Equation:: Solved Problems Set1Lagrange's Equation:: Solved Problems Set1
Lagrange's Equation:: Solved Problems Set1
SreejaRamesh2
 
I dc ch. 13.11.2020
I dc ch. 13.11.2020I dc ch. 13.11.2020
I dc ch. 13.11.2020
SreejaRamesh2
 

More from SreejaRamesh2 (20)

Syllabus for semester 3: complementary course in maths
Syllabus for semester 3: complementary course in mathsSyllabus for semester 3: complementary course in maths
Syllabus for semester 3: complementary course in maths
 
Pg s2 11.08.2021 d5 filters
Pg s2 11.08.2021 d5 filtersPg s2 11.08.2021 d5 filters
Pg s2 11.08.2021 d5 filters
 
Pg s2 30.07.2021 _d1
Pg s2 30.07.2021 _d1Pg s2 30.07.2021 _d1
Pg s2 30.07.2021 _d1
 
questions on matrices part1
 questions on matrices part1 questions on matrices part1
questions on matrices part1
 
Prove this proposition:
Prove this proposition: Prove this proposition:
Prove this proposition:
 
Silver-Pohlig-Hellman Algorithm
Silver-Pohlig-Hellman AlgorithmSilver-Pohlig-Hellman Algorithm
Silver-Pohlig-Hellman Algorithm
 
Closed sets in metric spaces
Closed sets in metric spacesClosed sets in metric spaces
Closed sets in metric spaces
 
Continuity- solved problems set 1
Continuity- solved problems set 1Continuity- solved problems set 1
Continuity- solved problems set 1
 
Roots of Unity & Quadratic residues
Roots of Unity & Quadratic residuesRoots of Unity & Quadratic residues
Roots of Unity & Quadratic residues
 
finite fields of prime power order
finite fields of prime power orderfinite fields of prime power order
finite fields of prime power order
 
generator of a finite field exists
generator of a finite field existsgenerator of a finite field exists
generator of a finite field exists
 
probability of generators
probability  of generatorsprobability  of generators
probability of generators
 
Topologies on the Set of Real Numbers
Topologies on the Set of Real NumbersTopologies on the Set of Real Numbers
Topologies on the Set of Real Numbers
 
Echelon form of a matrix
Echelon form of a matrixEchelon form of a matrix
Echelon form of a matrix
 
python- print function and arithmetic expressions
python- print function and arithmetic expressionspython- print function and arithmetic expressions
python- print function and arithmetic expressions
 
Basic Topology- Syllabus
Basic Topology- SyllabusBasic Topology- Syllabus
Basic Topology- Syllabus
 
Elementary Transformations of Matrices
Elementary Transformations of MatricesElementary Transformations of Matrices
Elementary Transformations of Matrices
 
Rank of a matrix:::Definition
Rank of a matrix:::DefinitionRank of a matrix:::Definition
Rank of a matrix:::Definition
 
Lagrange's Equation:: Solved Problems Set1
Lagrange's Equation:: Solved Problems Set1Lagrange's Equation:: Solved Problems Set1
Lagrange's Equation:: Solved Problems Set1
 
I dc ch. 13.11.2020
I dc ch. 13.11.2020I dc ch. 13.11.2020
I dc ch. 13.11.2020
 

Recently uploaded

The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 

Recently uploaded (20)

The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 

python- Variables and data types

  • 1. print("Halt!") user_input = input("Who goes there? ") print("You may pass,", user_input) • input() function was used • user_input is a variable. • Variables are like a box that can store some piece of data
  • 2. a = 123.4 b23 = 'Spam' first_name = "Bill" b = 432 c = a + b print("a + b is",c) print("first_name is",first_name) print("Sorted Parts, After Midnight or",b23) • The variables in the above program are a, b23, first_name, b, and c. The two basic data types are strings and numbers. Variables that are used to store a value, do not use quotation marks (" and ').
  • 3. • Strings are a sequence of letters, numbers and other characters. In this example, b23 and first_name are variables that are storing strings. • Spam, Bill, a+ b is, first_name is, and Sorted Parts, After Midnight or are the strings in this program. The characters are surrounded by " or '.
  • 4. Variables Variables are containers for storing data values. Creating Variables Python has no command for declaring a variable. A variable is created the moment you first assign a value to it. Variables do not need to be declared with any particular type, and can even change type after they have been set.
  • 5. x = 5 y = "John" print(x) print(y) x = 4 # x is of type int x = "Sally" # x is now of type str print(x)
  • 6.
  • 7. In Python, the data type is set when you assign a value to a variable:
  • 8. If you want to specify the data type, you can use the following constructor functions:
  • 9. x = 5 y = "John" print(x) print(y) x = 4 # x is of type int print(type(x)) x = "Sally" # x is now of type str print(type(x))
  • 10. Casting If you want to specify the data type of a variable, this can be done with casting. x = str(3) # x will be '3' y = int(3) # y will be 3 z = float(3) # z will be 3.0
  • 11. String variables can be declared either by using single or double quotes: Variable names are case-sensitive.
  • 12. Assignment While executing the statement c = a + b, The right hand side of the statement (a + b) is evaluated and the result is stored in the variable on the left hand side (c). This is called assignment.
  • 13. a = 1 print(a) a = a + 1 print(a) a = a * 2 print(a)