SlideShare a Scribd company logo
1 of 22
PYTHON PROGRAMMING WITH
WEB FRAMEWORKS – CSE304
This presentation contains the
concepts related to work with data
types and variables, numeric data,
string data
Data Types
• When you develop a Python program, you work with
variables that store data.
• A data type defines the type of data for a value.
• 3 types of basic Python data types:
2
3
Data Types
4
Data Types
• How to code literal values (there are two literals)
– String literal (enclose the characters of the string in
single or double quotation marks).
– Numeric literal (code the number without quotation
marks).
• You can assign a value of any data type to a variable.
• An assignment statement uses the equals sign (=) to
assign a value to a variable.
• The value can be a literal value, another variable, or
an expression like the arithmetic expressions.
5
Variables
• A Python variable is a symbolic name that is a
reference or pointer to an object.
• Once an object is assigned to a variable, you can refer
to the object by that name anywhere inside the
program.
• How to name variables ?
– Give meaningful names. That means that it should be
easy to tell and easy to remember.
– Avoid abbreviations.
– Use underscore notation. (example: tax_rate)
– You may use camel case. (example: taxRate)
6
Rules for naming variables
• A variable name must begin with a letter or
underscore.
• A variable name can't contain spaces, punctuation,
or special characters other than the underscore.
• A variable name can't begin with a number, but can
use numbers later in the name.
• A variable name can't be the same as a keyword
that's reserved by Python.
7
Python Keywords
8
Python 3.9.X Keywords List
• 36 keywords
9
Python's arithmetic operators
10
How to work with numeric data
• The order of precedence for arithmetic expressions:
• Examples that show the order of precedence and use
of parentheses
11
How to work with numeric data
• An arithmetic expression consists of one or more
operands that are operated upon by arithmetic
operators.
• No need of spaces before and after the arithmetic
operators.
• When an expression mixes integer and floating-point
numbers, Python converts the integers to floating-
point numbers.
• Use parentheses to clarify the sequence of
operations (when multiple operators are used).
Otherwise, Python applies its order of precedence.
12
How to work with numeric data
• Compound assignment operators provide a
shorthand way to code common assignment
statements.
• Besides the compound operators in the table. Python
offers /=. //=. %=, and **=.
• When working with floating-point numbers, be aware
that they are approximations, not exact values. This
can cause inaccurate results.
13
Other Operators
• Comparison Operators:
!=, ==, <, <=, >, >=
• Unary Operators:
Unary plus (+)
Unary minus (-)
• Bitwise Operators
&(AND), |(OR), ^(XOR), ~(One's Compliment),
<< (Left Shift), >>(Right Shift)
14
Other Operators
• Logical Operators:
and, or, not
• Assignment Operators:
=, +=, -+, *=, /=, //=,...
• Membership Operators:
in, not in
• Identity Operators:
is , is not
15
Operator Precedence
• Parenthesis – ()
• Exponentiation – **
• Compliment, unary plus and minus – ~, +, -
• Multiply, Divide, modulo – *, /, %
• Addition and Subtraction – +, -
• Right and Left Shift – >>, <<
• Bitwise AND – &
• Bitwise OR and XOR – |, ^
• Comparison Operators – ==, !=, >, <, >=, <=
• Assignment Operator- =
16
How to use the interactive shell for testing
numeric operations
• Demo
17
How to work with string data
• You can also create an empty string by coding a set of
quotation marks with nothing between them.
• And you can assign a new value to a string variable.
This works the same way it does with numeric
variables.
18
How to work with string data
19
Common escape sequences
• you can use escape sequences to include certain
types of special characters such as new lines and tabs.
• You can also use escape characters to include special
characters such as quotation marks and backslashes.
20
Common escape sequences
21
Common escape sequences
22

More Related Content

Similar to 1.4 Work with data types and variables, numeric data, string data.pptx

Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptxrohithprabhas1
 
Programming Basics.pptx
Programming Basics.pptxProgramming Basics.pptx
Programming Basics.pptxmahendranaik18
 
Lecture 4 variables data types and operators
Lecture 4  variables data types and operatorsLecture 4  variables data types and operators
Lecture 4 variables data types and operatorsalvin567
 
modul-python-all.pptx
modul-python-all.pptxmodul-python-all.pptx
modul-python-all.pptxYusuf Ayuba
 
1. PGA2.0-Python Programming-Intro to Python.pptx
1. PGA2.0-Python Programming-Intro to Python.pptx1. PGA2.0-Python Programming-Intro to Python.pptx
1. PGA2.0-Python Programming-Intro to Python.pptxRakesh Ahuja
 
5 conceptos progamacion2-tema4
5 conceptos progamacion2-tema45 conceptos progamacion2-tema4
5 conceptos progamacion2-tema4Elba Sepúlveda
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming LanguageAhmad Idrees
 
Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 5Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 5FabMinds
 
Object oriented programming 8 basics of c++ programming
Object oriented programming 8 basics of c++ programmingObject oriented programming 8 basics of c++ programming
Object oriented programming 8 basics of c++ programmingVaibhav Khanna
 
OPERATORS OF C++
OPERATORS OF C++OPERATORS OF C++
OPERATORS OF C++ANANT VYAS
 
Python Basics by Akanksha Bali
Python Basics by Akanksha BaliPython Basics by Akanksha Bali
Python Basics by Akanksha BaliAkanksha Bali
 

Similar to 1.4 Work with data types and variables, numeric data, string data.pptx (20)

Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptx
 
Programming Basics.pptx
Programming Basics.pptxProgramming Basics.pptx
Programming Basics.pptx
 
Lecture 4 variables data types and operators
Lecture 4  variables data types and operatorsLecture 4  variables data types and operators
Lecture 4 variables data types and operators
 
modul-python-all.pptx
modul-python-all.pptxmodul-python-all.pptx
modul-python-all.pptx
 
1. PGA2.0-Python Programming-Intro to Python.pptx
1. PGA2.0-Python Programming-Intro to Python.pptx1. PGA2.0-Python Programming-Intro to Python.pptx
1. PGA2.0-Python Programming-Intro to Python.pptx
 
Python-Basics.pptx
Python-Basics.pptxPython-Basics.pptx
Python-Basics.pptx
 
17575602.ppt
17575602.ppt17575602.ppt
17575602.ppt
 
5 conceptos progamacion2-tema4
5 conceptos progamacion2-tema45 conceptos progamacion2-tema4
5 conceptos progamacion2-tema4
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Python basics
Python basicsPython basics
Python basics
 
Python Operators.pptx
Python Operators.pptxPython Operators.pptx
Python Operators.pptx
 
Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 5Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 5
 
Object oriented programming 8 basics of c++ programming
Object oriented programming 8 basics of c++ programmingObject oriented programming 8 basics of c++ programming
Object oriented programming 8 basics of c++ programming
 
OPERATORS OF C++
OPERATORS OF C++OPERATORS OF C++
OPERATORS OF C++
 
Unit - 2 CAP.pptx
Unit - 2 CAP.pptxUnit - 2 CAP.pptx
Unit - 2 CAP.pptx
 
Python Basics by Akanksha Bali
Python Basics by Akanksha BaliPython Basics by Akanksha Bali
Python Basics by Akanksha Bali
 
Complexity
ComplexityComplexity
Complexity
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Review Python
Review PythonReview Python
Review Python
 
C++.pptx
C++.pptxC++.pptx
C++.pptx
 

More from VGaneshKarthikeyan

Unit III Part I_Opertaor_Overloading.pptx
Unit III Part I_Opertaor_Overloading.pptxUnit III Part I_Opertaor_Overloading.pptx
Unit III Part I_Opertaor_Overloading.pptxVGaneshKarthikeyan
 
Linear_discriminat_analysis_in_Machine_Learning.pptx
Linear_discriminat_analysis_in_Machine_Learning.pptxLinear_discriminat_analysis_in_Machine_Learning.pptx
Linear_discriminat_analysis_in_Machine_Learning.pptxVGaneshKarthikeyan
 
K-Mean clustering_Introduction_Applications.pptx
K-Mean clustering_Introduction_Applications.pptxK-Mean clustering_Introduction_Applications.pptx
K-Mean clustering_Introduction_Applications.pptxVGaneshKarthikeyan
 
Numpy_defintion_description_usage_examples.pptx
Numpy_defintion_description_usage_examples.pptxNumpy_defintion_description_usage_examples.pptx
Numpy_defintion_description_usage_examples.pptxVGaneshKarthikeyan
 
Refined_Lecture-14-Linear Algebra-Review.ppt
Refined_Lecture-14-Linear Algebra-Review.pptRefined_Lecture-14-Linear Algebra-Review.ppt
Refined_Lecture-14-Linear Algebra-Review.pptVGaneshKarthikeyan
 
randomwalks_states_figures_events_happenings.ppt
randomwalks_states_figures_events_happenings.pptrandomwalks_states_figures_events_happenings.ppt
randomwalks_states_figures_events_happenings.pptVGaneshKarthikeyan
 
stochasticmodellinganditsapplications.ppt
stochasticmodellinganditsapplications.pptstochasticmodellinganditsapplications.ppt
stochasticmodellinganditsapplications.pptVGaneshKarthikeyan
 
1.10 Tuples_sets_usage_applications_advantages.pptx
1.10 Tuples_sets_usage_applications_advantages.pptx1.10 Tuples_sets_usage_applications_advantages.pptx
1.10 Tuples_sets_usage_applications_advantages.pptxVGaneshKarthikeyan
 
Neural_Networks_scalability_consntency.ppt
Neural_Networks_scalability_consntency.pptNeural_Networks_scalability_consntency.ppt
Neural_Networks_scalability_consntency.pptVGaneshKarthikeyan
 
Lecture-4-Linear Regression-Gradient Descent Solution.ppt
Lecture-4-Linear Regression-Gradient Descent Solution.pptLecture-4-Linear Regression-Gradient Descent Solution.ppt
Lecture-4-Linear Regression-Gradient Descent Solution.pptVGaneshKarthikeyan
 
1.3 Basic coding skills_tupels_sets_controlloops.ppt
1.3 Basic coding skills_tupels_sets_controlloops.ppt1.3 Basic coding skills_tupels_sets_controlloops.ppt
1.3 Basic coding skills_tupels_sets_controlloops.pptVGaneshKarthikeyan
 
Python_basics_tuples_sets_lists_control_loops.ppt
Python_basics_tuples_sets_lists_control_loops.pptPython_basics_tuples_sets_lists_control_loops.ppt
Python_basics_tuples_sets_lists_control_loops.pptVGaneshKarthikeyan
 
Inheritance_with_its_types_single_multi_hybrid
Inheritance_with_its_types_single_multi_hybridInheritance_with_its_types_single_multi_hybrid
Inheritance_with_its_types_single_multi_hybridVGaneshKarthikeyan
 
Refined_Lecture-8-Probability Review-2.ppt
Refined_Lecture-8-Probability Review-2.pptRefined_Lecture-8-Probability Review-2.ppt
Refined_Lecture-8-Probability Review-2.pptVGaneshKarthikeyan
 
Refined_Lecture-13-Maximum Likelihood Estimators-Part-C.ppt
Refined_Lecture-13-Maximum Likelihood Estimators-Part-C.pptRefined_Lecture-13-Maximum Likelihood Estimators-Part-C.ppt
Refined_Lecture-13-Maximum Likelihood Estimators-Part-C.pptVGaneshKarthikeyan
 
Refined_Lecture-15-Dimensionality Reduction-Uunspervised-PCA.ppt
Refined_Lecture-15-Dimensionality Reduction-Uunspervised-PCA.pptRefined_Lecture-15-Dimensionality Reduction-Uunspervised-PCA.ppt
Refined_Lecture-15-Dimensionality Reduction-Uunspervised-PCA.pptVGaneshKarthikeyan
 
Bias-Variance_relted_to_ML.pdf
Bias-Variance_relted_to_ML.pdfBias-Variance_relted_to_ML.pdf
Bias-Variance_relted_to_ML.pdfVGaneshKarthikeyan
 
Refined_Lecture-1-Motivation & Applications.ppt
Refined_Lecture-1-Motivation & Applications.pptRefined_Lecture-1-Motivation & Applications.ppt
Refined_Lecture-1-Motivation & Applications.pptVGaneshKarthikeyan
 
Lecture-4-Linear Regression-Gradient Descent Solution.PPTX
Lecture-4-Linear Regression-Gradient Descent Solution.PPTXLecture-4-Linear Regression-Gradient Descent Solution.PPTX
Lecture-4-Linear Regression-Gradient Descent Solution.PPTXVGaneshKarthikeyan
 

More from VGaneshKarthikeyan (20)

Unit III Part I_Opertaor_Overloading.pptx
Unit III Part I_Opertaor_Overloading.pptxUnit III Part I_Opertaor_Overloading.pptx
Unit III Part I_Opertaor_Overloading.pptx
 
Linear_discriminat_analysis_in_Machine_Learning.pptx
Linear_discriminat_analysis_in_Machine_Learning.pptxLinear_discriminat_analysis_in_Machine_Learning.pptx
Linear_discriminat_analysis_in_Machine_Learning.pptx
 
K-Mean clustering_Introduction_Applications.pptx
K-Mean clustering_Introduction_Applications.pptxK-Mean clustering_Introduction_Applications.pptx
K-Mean clustering_Introduction_Applications.pptx
 
Numpy_defintion_description_usage_examples.pptx
Numpy_defintion_description_usage_examples.pptxNumpy_defintion_description_usage_examples.pptx
Numpy_defintion_description_usage_examples.pptx
 
Refined_Lecture-14-Linear Algebra-Review.ppt
Refined_Lecture-14-Linear Algebra-Review.pptRefined_Lecture-14-Linear Algebra-Review.ppt
Refined_Lecture-14-Linear Algebra-Review.ppt
 
randomwalks_states_figures_events_happenings.ppt
randomwalks_states_figures_events_happenings.pptrandomwalks_states_figures_events_happenings.ppt
randomwalks_states_figures_events_happenings.ppt
 
stochasticmodellinganditsapplications.ppt
stochasticmodellinganditsapplications.pptstochasticmodellinganditsapplications.ppt
stochasticmodellinganditsapplications.ppt
 
1.10 Tuples_sets_usage_applications_advantages.pptx
1.10 Tuples_sets_usage_applications_advantages.pptx1.10 Tuples_sets_usage_applications_advantages.pptx
1.10 Tuples_sets_usage_applications_advantages.pptx
 
Neural_Networks_scalability_consntency.ppt
Neural_Networks_scalability_consntency.pptNeural_Networks_scalability_consntency.ppt
Neural_Networks_scalability_consntency.ppt
 
Lecture-4-Linear Regression-Gradient Descent Solution.ppt
Lecture-4-Linear Regression-Gradient Descent Solution.pptLecture-4-Linear Regression-Gradient Descent Solution.ppt
Lecture-4-Linear Regression-Gradient Descent Solution.ppt
 
1.3 Basic coding skills_tupels_sets_controlloops.ppt
1.3 Basic coding skills_tupels_sets_controlloops.ppt1.3 Basic coding skills_tupels_sets_controlloops.ppt
1.3 Basic coding skills_tupels_sets_controlloops.ppt
 
Python_basics_tuples_sets_lists_control_loops.ppt
Python_basics_tuples_sets_lists_control_loops.pptPython_basics_tuples_sets_lists_control_loops.ppt
Python_basics_tuples_sets_lists_control_loops.ppt
 
Inheritance_with_its_types_single_multi_hybrid
Inheritance_with_its_types_single_multi_hybridInheritance_with_its_types_single_multi_hybrid
Inheritance_with_its_types_single_multi_hybrid
 
Refined_Lecture-8-Probability Review-2.ppt
Refined_Lecture-8-Probability Review-2.pptRefined_Lecture-8-Probability Review-2.ppt
Refined_Lecture-8-Probability Review-2.ppt
 
Refined_Lecture-13-Maximum Likelihood Estimators-Part-C.ppt
Refined_Lecture-13-Maximum Likelihood Estimators-Part-C.pptRefined_Lecture-13-Maximum Likelihood Estimators-Part-C.ppt
Refined_Lecture-13-Maximum Likelihood Estimators-Part-C.ppt
 
Refined_Lecture-15-Dimensionality Reduction-Uunspervised-PCA.ppt
Refined_Lecture-15-Dimensionality Reduction-Uunspervised-PCA.pptRefined_Lecture-15-Dimensionality Reduction-Uunspervised-PCA.ppt
Refined_Lecture-15-Dimensionality Reduction-Uunspervised-PCA.ppt
 
Bias-Variance_relted_to_ML.pdf
Bias-Variance_relted_to_ML.pdfBias-Variance_relted_to_ML.pdf
Bias-Variance_relted_to_ML.pdf
 
Refined_Lecture-1-Motivation & Applications.ppt
Refined_Lecture-1-Motivation & Applications.pptRefined_Lecture-1-Motivation & Applications.ppt
Refined_Lecture-1-Motivation & Applications.ppt
 
Lecture-4-Linear Regression-Gradient Descent Solution.PPTX
Lecture-4-Linear Regression-Gradient Descent Solution.PPTXLecture-4-Linear Regression-Gradient Descent Solution.PPTX
Lecture-4-Linear Regression-Gradient Descent Solution.PPTX
 
13.Data Conversion.pptx
13.Data Conversion.pptx13.Data Conversion.pptx
13.Data Conversion.pptx
 

Recently uploaded

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
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
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
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
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
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
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 

Recently uploaded (20)

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
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
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
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
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
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
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 

1.4 Work with data types and variables, numeric data, string data.pptx

  • 1. PYTHON PROGRAMMING WITH WEB FRAMEWORKS – CSE304 This presentation contains the concepts related to work with data types and variables, numeric data, string data
  • 2. Data Types • When you develop a Python program, you work with variables that store data. • A data type defines the type of data for a value. • 3 types of basic Python data types: 2
  • 3. 3
  • 5. Data Types • How to code literal values (there are two literals) – String literal (enclose the characters of the string in single or double quotation marks). – Numeric literal (code the number without quotation marks). • You can assign a value of any data type to a variable. • An assignment statement uses the equals sign (=) to assign a value to a variable. • The value can be a literal value, another variable, or an expression like the arithmetic expressions. 5
  • 6. Variables • A Python variable is a symbolic name that is a reference or pointer to an object. • Once an object is assigned to a variable, you can refer to the object by that name anywhere inside the program. • How to name variables ? – Give meaningful names. That means that it should be easy to tell and easy to remember. – Avoid abbreviations. – Use underscore notation. (example: tax_rate) – You may use camel case. (example: taxRate) 6
  • 7. Rules for naming variables • A variable name must begin with a letter or underscore. • A variable name can't contain spaces, punctuation, or special characters other than the underscore. • A variable name can't begin with a number, but can use numbers later in the name. • A variable name can't be the same as a keyword that's reserved by Python. 7
  • 9. Python 3.9.X Keywords List • 36 keywords 9
  • 11. How to work with numeric data • The order of precedence for arithmetic expressions: • Examples that show the order of precedence and use of parentheses 11
  • 12. How to work with numeric data • An arithmetic expression consists of one or more operands that are operated upon by arithmetic operators. • No need of spaces before and after the arithmetic operators. • When an expression mixes integer and floating-point numbers, Python converts the integers to floating- point numbers. • Use parentheses to clarify the sequence of operations (when multiple operators are used). Otherwise, Python applies its order of precedence. 12
  • 13. How to work with numeric data • Compound assignment operators provide a shorthand way to code common assignment statements. • Besides the compound operators in the table. Python offers /=. //=. %=, and **=. • When working with floating-point numbers, be aware that they are approximations, not exact values. This can cause inaccurate results. 13
  • 14. Other Operators • Comparison Operators: !=, ==, <, <=, >, >= • Unary Operators: Unary plus (+) Unary minus (-) • Bitwise Operators &(AND), |(OR), ^(XOR), ~(One's Compliment), << (Left Shift), >>(Right Shift) 14
  • 15. Other Operators • Logical Operators: and, or, not • Assignment Operators: =, +=, -+, *=, /=, //=,... • Membership Operators: in, not in • Identity Operators: is , is not 15
  • 16. Operator Precedence • Parenthesis – () • Exponentiation – ** • Compliment, unary plus and minus – ~, +, - • Multiply, Divide, modulo – *, /, % • Addition and Subtraction – +, - • Right and Left Shift – >>, << • Bitwise AND – & • Bitwise OR and XOR – |, ^ • Comparison Operators – ==, !=, >, <, >=, <= • Assignment Operator- = 16
  • 17. How to use the interactive shell for testing numeric operations • Demo 17
  • 18. How to work with string data • You can also create an empty string by coding a set of quotation marks with nothing between them. • And you can assign a new value to a string variable. This works the same way it does with numeric variables. 18
  • 19. How to work with string data 19
  • 20. Common escape sequences • you can use escape sequences to include certain types of special characters such as new lines and tabs. • You can also use escape characters to include special characters such as quotation marks and backslashes. 20