SlideShare a Scribd company logo
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

PPTX
unit1 python.pptx
PPTX
MODULE hdsfsf gefegsfs wfefwfwfg etegeg.pptx
PDF
Python Operators.pdf
PPTX
Basic concept of Python.pptx includes design tool, identifier, variables.
PDF
Python Basics | Python Tutorial | Edureka
PPT
Unit-I-PPT-1.ppt
PPTX
Lhahahhahahhahhhahahhajjsaaecture 6.pptx
PPTX
Operators in Python Arithmetic Operators
unit1 python.pptx
MODULE hdsfsf gefegsfs wfefwfwfg etegeg.pptx
Python Operators.pdf
Basic concept of Python.pptx includes design tool, identifier, variables.
Python Basics | Python Tutorial | Edureka
Unit-I-PPT-1.ppt
Lhahahhahahhahhhahahhajjsaaecture 6.pptx
Operators in Python Arithmetic Operators

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

PPTX
Lecture 1 .
PPTX
chapter-3-engdata-handling1_1585929972520 by EasePDF.pptx
PPTX
python presentation.pptx
PPT
lecture2 (1).ppt variable s and operators
PPTX
Python For Data Science.pptx
PPTX
Grade XI - Computer science Data Handling in Python
PPTX
Programming Basics.pptx
PDF
Lecture 4 variables data types and operators
PPTX
modul-python-all.pptx
PPTX
1. PGA2.0-Python Programming-Intro to Python.pptx
PPTX
Python-Basics.pptx
PPT
17575602.ppt
PDF
5 conceptos progamacion2-tema4
PPT
Basics of c++ Programming Language
PPTX
Python basics
PPTX
Python Operators.pptx
PPTX
Python Programming | JNTUK | UNIT 1 | Lecture 5
PPTX
Object oriented programming 8 basics of c++ programming
PPTX
Python_Operations - types of the operators
Lecture 1 .
chapter-3-engdata-handling1_1585929972520 by EasePDF.pptx
python presentation.pptx
lecture2 (1).ppt variable s and operators
Python For Data Science.pptx
Grade XI - Computer science Data Handling in Python
Programming Basics.pptx
Lecture 4 variables data types and operators
modul-python-all.pptx
1. PGA2.0-Python Programming-Intro to Python.pptx
Python-Basics.pptx
17575602.ppt
5 conceptos progamacion2-tema4
Basics of c++ Programming Language
Python basics
Python Operators.pptx
Python Programming | JNTUK | UNIT 1 | Lecture 5
Object oriented programming 8 basics of c++ programming
Python_Operations - types of the operators
Ad

More from VGaneshKarthikeyan (20)

PPT
1.3 Basic coding skills_fundamentals .ppt
PPT
5_Model for Predictions_Machine_Learning.ppt
PPT
2_Errors in Experimental Observations_ML.ppt
PDF
FINAL_DAY11_INTERFACES_Roles_and_Responsibility.pdf
PPTX
FINAL_DAY10_INTERFACES_roles and benefits.pptx
PPTX
FINAL_DAY8_VISIBILITY_LABELS_Roles and.pptx
PPTX
FINAL_DAY9_METHOD_OVERRIDING_Role and benefits .pptx
PPT
JAVA_BASICS_Data_abstraction_encapsulation.ppt
PPT
Java ppt-class_Introduction_class_Objects.ppt
PPT
INT104 DBMS - Introduction_Atomicity.ppt
PDF
6. Implementation of classes_and_its_advantages.pdf
PPT
Operators_in_C++_advantages_applications.ppt
PPT
1_Standard error Experimental Data_ML.ppt
PPTX
Unit III Part I_Opertaor_Overloading.pptx
PPTX
Linear_discriminat_analysis_in_Machine_Learning.pptx
PPTX
K-Mean clustering_Introduction_Applications.pptx
PPTX
Numpy_defintion_description_usage_examples.pptx
PPT
Refined_Lecture-14-Linear Algebra-Review.ppt
PPT
randomwalks_states_figures_events_happenings.ppt
PPT
stochasticmodellinganditsapplications.ppt
1.3 Basic coding skills_fundamentals .ppt
5_Model for Predictions_Machine_Learning.ppt
2_Errors in Experimental Observations_ML.ppt
FINAL_DAY11_INTERFACES_Roles_and_Responsibility.pdf
FINAL_DAY10_INTERFACES_roles and benefits.pptx
FINAL_DAY8_VISIBILITY_LABELS_Roles and.pptx
FINAL_DAY9_METHOD_OVERRIDING_Role and benefits .pptx
JAVA_BASICS_Data_abstraction_encapsulation.ppt
Java ppt-class_Introduction_class_Objects.ppt
INT104 DBMS - Introduction_Atomicity.ppt
6. Implementation of classes_and_its_advantages.pdf
Operators_in_C++_advantages_applications.ppt
1_Standard error Experimental Data_ML.ppt
Unit III Part I_Opertaor_Overloading.pptx
Linear_discriminat_analysis_in_Machine_Learning.pptx
K-Mean clustering_Introduction_Applications.pptx
Numpy_defintion_description_usage_examples.pptx
Refined_Lecture-14-Linear Algebra-Review.ppt
randomwalks_states_figures_events_happenings.ppt
stochasticmodellinganditsapplications.ppt
Ad

Recently uploaded (20)

PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Computing-Curriculum for Schools in Ghana
PPTX
master seminar digital applications in india
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Cell Structure & Organelles in detailed.
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Presentation on HIE in infants and its manifestations
PDF
Complications of Minimal Access Surgery at WLH
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
O7-L3 Supply Chain Operations - ICLT Program
Supply Chain Operations Speaking Notes -ICLT Program
GDM (1) (1).pptx small presentation for students
Computing-Curriculum for Schools in Ghana
master seminar digital applications in india
01-Introduction-to-Information-Management.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Cell Structure & Organelles in detailed.
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Final Presentation General Medicine 03-08-2024.pptx
Presentation on HIE in infants and its manifestations
Complications of Minimal Access Surgery at WLH
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Module 4: Burden of Disease Tutorial Slides S2 2025
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
human mycosis Human fungal infections are called human mycosis..pptx
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf

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