SlideShare a Scribd company logo
Python Programming
UNIT 1 : SYLLABUS
• Conceptual introduction: topics in computer science, algorithms;
• Modern computer systems: hardware architecture, data
representation in computers, software and operating system;
• Installing Python; basic syntax, interactive shell, editing, saving, and
running a script.
• The concept of data types; variables, assignments; immutable
variables; numerical types;
• arithmetic operators and expressions; comments in the program;
understanding error messages;
Variables, Assignments,
immutable variables
Numerical types
The concept of data
types
The concept of data types
• A data type consists of a set of values and a set of operations that
can be performed on those values.
• A literal is the way a value of a data type looks to a programmer.
The concept of data types
The concept of data types
String Literals:
In Python, a string literal is a
sequence of characters
enclosed in single or double
quotation marks.
Empty String
Empty String
The concept of data types
String Literals:
In Python, a string literal is a
sequence of characters
enclosed in single or double
quotation marks.
Single Quote inside the String
The concept of data types
String Literals:
In Python, a string literal is a
sequence of characters
enclosed in single or double
quotation marks.
Three Quotes for
Multiple line string
The concept of data types
String Literals:
In Python, a string literal is a
sequence of characters
enclosed in single or double
quotation marks. n Embedded
The concept of data types
Escape Sequences:
• The newline character n is
called an escape sequence.
• Escape sequences are the
way Python expresses
special characters, such as
the tab, the newline, and the
backspace (delete key), as
literals.
The concept of data types
String Concatenation:
“Hello” + “world”  Hello
world
a = “welcome”
b = “to”
c = “python”
d = a + b + c  “Welcome to
python”
+ is used for
combining
The concept of data types
String Repeating:
“Hi ” * 3  “Hi Hi Hi”
a = “hello ”
b = a*2  “hello hello”
* is used for
combining
Variables, Assignments,
immutable variables
Numerical types
The concept of data
types
if
import
in
is
lambda
nonlocal
with
yield
except
finally
for
from
global
raise
try
while
class
continue
def
del
elif
pass
else
return
and
as
assert
async
await
break
not
or
35
key
words
Started
with
capitals
True
False
None
Variables, Assignments, immutable variables
Variables, Assignments, immutable variables
Variable:
• In Python, a variable is a
reserved memory location
used to store values.
• Python has no command for
declaring a variable. A variable
is created the moment a value
is assigned to it.
• The equal to (=) operator is
used to assign value to a
variable. (Assignment
Operator).
• If we want to store the age of a
person, we should not name
the variable as x, or y or a, or i.
• we should name the variable
as age.
Variables, Assignments, immutable variables
• Use letters
• Use
numbers
with letters
• Use ‘_’ for
long names
a = 5  a variable
A = 6  a variable
(note : A & a are different
variables)
A 1 = 10  a variable
my_name = “Raja”  a
variable
Variables, Assignments, immutable variables
2a = 100  syntax error
a2 = 100  is a variable
if = 5  is a syntax error
If = 5  If is a variable
True = 6  is a syntax error
true = 6  true is a variable
• Don’t start
with
number
• Don’t use
keywords
as variable
names
Variables, Assignments, immutable variables
Multiple Assignment:
• Python allows you to assign a
single value to several
variables simultaneously.
• number1 = number2 = number3 =
100
• This is called chained
assignment.
• We can also assign multiple
objects to multiple variables;
this is called multiple
assignment.
• value1, value2, value3 = 1, 2.5, "Ram“
Variables, Assignments, immutable variables
• Associating a value with a
variable using the assignment
operator (=) is called as
Binding.
Value1 = Value2 =100
Value1 = “Hello”
Print(Value1)  “Hello” not 100
• We cannot use Python variables
without assigning any value.
• If we try to use a variable
without assigning any value
then, Python interpreter shows
error like "name is not defined".
Variables, Assignments, immutable variables
• Most python objects (Booleans,
integers, floats, strings, and tuples)
are immutable.
• This means that after you create the
object and assign some value to it,
you can't modify that value.
• Using the expressions, a = 1 and then
a = 2.
• The object with value 1 still exists in
memory, but you’ve lost the binding
to it. (can’t access it anymore)
Variables, Assignments,
immutable variables
Numerical types
The concept of data
types
Numerical types
Numerical types
Integers:
• This value is represented by int class.
• It contains positive or negative whole
numbers (without fraction or
decimal).
• In Python there is no limit to how
long an integer value can be..
Ex : a = 5, b = 6
type(a)  <class 'int'>
type(b)  <class 'int'>
Numerical types
Float:
• This value is represented by float
class.
• It is a real number with floating point
representation. It is specified by a
decimal point.
• Optionally, the character e or E
followed by a positive or negative
integer may be appended to specify
scientific notation.
Ex : a = 5.5, b = 6.0
type(a)  <class ‘float'>
type(b)  <class ‘float'>
Numerical types
Complex Numbers:
• Complex number is
represented by complex class.
• It is specified as
(real part) + (imaginary part)j.
Ex : a = 2 + 6j, b = - 8 + 2j
type(a)  <class ‘complex'>
type(b)  <class ‘complex'>
Numerical types
Character set:
• All data and instructions in a
program are translated to binary
numbers before being run on a real
computer.
• To support this translation, the
characters in a string each map to an
integer value. This mapping is
defined in character sets, among
them the ASCII set and the
• UNICODE uses between 8 and 32
bits per character, so it can represent
characters from languages from all
around the world.
• ASCII represents lowercase letters (a-
z), uppercase letters (A-Z), digits (0–
9) and symbols
Numerical types
• ASCII Code of Character
“R” is 82
• Row num is 8
• Column num is 2
Numerical types
• Python’s ord and chr functions
convert characters to their
numeric ASCII codes and back
again, respectively.
Variables, Assignments,
immutable variables
Numerical types
The concept of data
types
Boolean types
Boolean:
• Data type with one of the two
built-in values, True or False.
• Boolean objects that are equal
to True or False.
• Note: True and False with
capital ‘T’ and ‘F’ are valid
Booleans.
Ex : a = True , b = False
type(a)  <class ‘bool'>
type(b)  <class ‘bool’>
Ex : a = “true” b = “false”
type(a)  <class ‘str'>
type(b)  <class ‘str’>
UNIT 1 : SYLLABUS
• Conceptual introduction: topics in computer science, algorithms;
• Modern computer systems: hardware architecture, data
representation in computers, software and operating system;
• Installing Python; basic syntax, interactive shell, editing, saving, and
running a script.
• The concept of data types; variables, assignments; immutable
variables; numerical types;
• arithmetic operators and expressions; comments in the program;
understanding error messages;

More Related Content

PPTX
python presentation
PDF
Ch-1_5.pdf this is java tutorials for all
PDF
Gestione della memoria in C++
PDF
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
PDF
Data types in c++
PPTX
Array in C
PDF
Object Oriented PHP - PART-1
PPT
Stl Containers
python presentation
Ch-1_5.pdf this is java tutorials for all
Gestione della memoria in C++
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
Data types in c++
Array in C
Object Oriented PHP - PART-1
Stl Containers

What's hot (20)

PPTX
Python basics
PPTX
Object Oriented Programming in Python
DOCX
C++ file
PPT
CONSTANTS, VARIABLES & DATATYPES IN C
PPT
standard template library(STL) in C++
PPTX
Mdi vb.net
PPT
Pointers C programming
PPTX
Programming
PPTX
Python
PPTX
Implementation Of String Functions In C
PDF
Methods in Java
PPTX
Ray tracing
PPTX
C programming - String
PPTX
Operators in C
PPTX
Fixed point scaling
PDF
Intro to Python for Non-Programmers
PPTX
Python Programming Essentials - M8 - String Methods
PPTX
Class template
PPT
16717 functions in C++
 
Python basics
Object Oriented Programming in Python
C++ file
CONSTANTS, VARIABLES & DATATYPES IN C
standard template library(STL) in C++
Mdi vb.net
Pointers C programming
Programming
Python
Implementation Of String Functions In C
Methods in Java
Ray tracing
C programming - String
Operators in C
Fixed point scaling
Intro to Python for Non-Programmers
Python Programming Essentials - M8 - String Methods
Class template
16717 functions in C++
 
Ad

Similar to Python Programming | JNTUK | UNIT 1 | Lecture 4 (20)

PDF
2nd PUC Computer science chapter 5 review of c++
PPTX
introduction to python,datatypes,operators
PPTX
Literals, primitive datatypes, variables, expressions, identifiers
PPTX
Chapter 1 Python Revision (1).pptx the royal ac acemy
PPTX
Introduction to python
PPTX
Variables&DataTypes.pptx
PPT
chapter 5.ppt
PPTX
BASICS OF PYTHON usefull for the student who would like to learn on their own
PPTX
2. Values and Data types in Python.pptx
PDF
THE C++ LECTURE 2 ON DATA STRUCTURES OF C++
PDF
Python Programminng…………………………………………………..
PPTX
Python Data-Types
PDF
4. Data Handling computer shcience pdf s
PPTX
Python unit 2 is added. Has python related programming content
PDF
Programming in Civil Engineering_UNIT 2_NOTES
PPTX
Introduction to Python Programming for beginners
PPTX
Java Datatypes
PPTX
java Basic Programming Needs
PPTX
python
PPTX
introduction to python
2nd PUC Computer science chapter 5 review of c++
introduction to python,datatypes,operators
Literals, primitive datatypes, variables, expressions, identifiers
Chapter 1 Python Revision (1).pptx the royal ac acemy
Introduction to python
Variables&DataTypes.pptx
chapter 5.ppt
BASICS OF PYTHON usefull for the student who would like to learn on their own
2. Values and Data types in Python.pptx
THE C++ LECTURE 2 ON DATA STRUCTURES OF C++
Python Programminng…………………………………………………..
Python Data-Types
4. Data Handling computer shcience pdf s
Python unit 2 is added. Has python related programming content
Programming in Civil Engineering_UNIT 2_NOTES
Introduction to Python Programming for beginners
Java Datatypes
java Basic Programming Needs
python
introduction to python
Ad

More from FabMinds (20)

PPTX
Python Programming | JNTUA | UNIT 3 | Lists |
PPTX
Python Programming | JNTUA | UNIT 3 | Strings |
PPTX
Python Programming | JNTUA | UNIT 3 | Updating Variables & Iteration |
PPTX
Python Programming | JNTUA | UNIT 2 | Case Study |
PPTX
Python Programming | JNTUA | UNIT 2 | Fruitful Functions |
PPTX
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
PPTX
Application layer protocols
PPTX
Internet connectivity
PPTX
Introduction for internet connectivity (IoT)
PPTX
web connectivity in IoT
PPTX
message communication protocols in IoT
PPTX
web communication protocols in IoT
PPTX
introduction for web connectivity (IoT)
PPTX
Python Introduction | JNTUA | R19 | UNIT 1 | Functions
PPTX
Python Introduction | JNTUA | R19 | UNIT 1 | Functions
PPTX
Python Programming | JNTUK | UNIT 2 | Lecture 6 & 7 | Conditional & Control S...
PPTX
Data enrichment
PPTX
Communication technologies
PPTX
M2M systems layers and designs standardizations
PPTX
Business models for business processes on IoT
Python Programming | JNTUA | UNIT 3 | Lists |
Python Programming | JNTUA | UNIT 3 | Strings |
Python Programming | JNTUA | UNIT 3 | Updating Variables & Iteration |
Python Programming | JNTUA | UNIT 2 | Case Study |
Python Programming | JNTUA | UNIT 2 | Fruitful Functions |
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
Application layer protocols
Internet connectivity
Introduction for internet connectivity (IoT)
web connectivity in IoT
message communication protocols in IoT
web communication protocols in IoT
introduction for web connectivity (IoT)
Python Introduction | JNTUA | R19 | UNIT 1 | Functions
Python Introduction | JNTUA | R19 | UNIT 1 | Functions
Python Programming | JNTUK | UNIT 2 | Lecture 6 & 7 | Conditional & Control S...
Data enrichment
Communication technologies
M2M systems layers and designs standardizations
Business models for business processes on IoT

Recently uploaded (20)

PDF
Anesthesia in Laparoscopic Surgery in India
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Pharma ospi slides which help in ospi learning
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Business Ethics Teaching Materials for college
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PPTX
Cell Structure & Organelles in detailed.
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Cell Types and Its function , kingdom of life
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Anesthesia in Laparoscopic Surgery in India
01-Introduction-to-Information-Management.pdf
Microbial diseases, their pathogenesis and prophylaxis
Pharma ospi slides which help in ospi learning
102 student loan defaulters named and shamed – Is someone you know on the list?
VCE English Exam - Section C Student Revision Booklet
Microbial disease of the cardiovascular and lymphatic systems
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Business Ethics Teaching Materials for college
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Week 4 Term 3 Study Techniques revisited.pptx
Cell Structure & Organelles in detailed.
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Renaissance Architecture: A Journey from Faith to Humanism
Final Presentation General Medicine 03-08-2024.pptx
Cell Types and Its function , kingdom of life
TR - Agricultural Crops Production NC III.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student

Python Programming | JNTUK | UNIT 1 | Lecture 4

  • 2. UNIT 1 : SYLLABUS • Conceptual introduction: topics in computer science, algorithms; • Modern computer systems: hardware architecture, data representation in computers, software and operating system; • Installing Python; basic syntax, interactive shell, editing, saving, and running a script. • The concept of data types; variables, assignments; immutable variables; numerical types; • arithmetic operators and expressions; comments in the program; understanding error messages;
  • 4. The concept of data types • A data type consists of a set of values and a set of operations that can be performed on those values. • A literal is the way a value of a data type looks to a programmer.
  • 5. The concept of data types
  • 6. The concept of data types String Literals: In Python, a string literal is a sequence of characters enclosed in single or double quotation marks. Empty String Empty String
  • 7. The concept of data types String Literals: In Python, a string literal is a sequence of characters enclosed in single or double quotation marks. Single Quote inside the String
  • 8. The concept of data types String Literals: In Python, a string literal is a sequence of characters enclosed in single or double quotation marks. Three Quotes for Multiple line string
  • 9. The concept of data types String Literals: In Python, a string literal is a sequence of characters enclosed in single or double quotation marks. n Embedded
  • 10. The concept of data types Escape Sequences: • The newline character n is called an escape sequence. • Escape sequences are the way Python expresses special characters, such as the tab, the newline, and the backspace (delete key), as literals.
  • 11. The concept of data types String Concatenation: “Hello” + “world”  Hello world a = “welcome” b = “to” c = “python” d = a + b + c  “Welcome to python” + is used for combining
  • 12. The concept of data types String Repeating: “Hi ” * 3  “Hi Hi Hi” a = “hello ” b = a*2  “hello hello” * is used for combining
  • 13. Variables, Assignments, immutable variables Numerical types The concept of data types
  • 15. Variables, Assignments, immutable variables Variable: • In Python, a variable is a reserved memory location used to store values. • Python has no command for declaring a variable. A variable is created the moment a value is assigned to it. • The equal to (=) operator is used to assign value to a variable. (Assignment Operator). • If we want to store the age of a person, we should not name the variable as x, or y or a, or i. • we should name the variable as age.
  • 16. Variables, Assignments, immutable variables • Use letters • Use numbers with letters • Use ‘_’ for long names a = 5  a variable A = 6  a variable (note : A & a are different variables) A 1 = 10  a variable my_name = “Raja”  a variable
  • 17. Variables, Assignments, immutable variables 2a = 100  syntax error a2 = 100  is a variable if = 5  is a syntax error If = 5  If is a variable True = 6  is a syntax error true = 6  true is a variable • Don’t start with number • Don’t use keywords as variable names
  • 18. Variables, Assignments, immutable variables Multiple Assignment: • Python allows you to assign a single value to several variables simultaneously. • number1 = number2 = number3 = 100 • This is called chained assignment. • We can also assign multiple objects to multiple variables; this is called multiple assignment. • value1, value2, value3 = 1, 2.5, "Ram“
  • 19. Variables, Assignments, immutable variables • Associating a value with a variable using the assignment operator (=) is called as Binding. Value1 = Value2 =100 Value1 = “Hello” Print(Value1)  “Hello” not 100 • We cannot use Python variables without assigning any value. • If we try to use a variable without assigning any value then, Python interpreter shows error like "name is not defined".
  • 20. Variables, Assignments, immutable variables • Most python objects (Booleans, integers, floats, strings, and tuples) are immutable. • This means that after you create the object and assign some value to it, you can't modify that value. • Using the expressions, a = 1 and then a = 2. • The object with value 1 still exists in memory, but you’ve lost the binding to it. (can’t access it anymore)
  • 21. Variables, Assignments, immutable variables Numerical types The concept of data types
  • 23. Numerical types Integers: • This value is represented by int class. • It contains positive or negative whole numbers (without fraction or decimal). • In Python there is no limit to how long an integer value can be.. Ex : a = 5, b = 6 type(a)  <class 'int'> type(b)  <class 'int'>
  • 24. Numerical types Float: • This value is represented by float class. • It is a real number with floating point representation. It is specified by a decimal point. • Optionally, the character e or E followed by a positive or negative integer may be appended to specify scientific notation. Ex : a = 5.5, b = 6.0 type(a)  <class ‘float'> type(b)  <class ‘float'>
  • 25. Numerical types Complex Numbers: • Complex number is represented by complex class. • It is specified as (real part) + (imaginary part)j. Ex : a = 2 + 6j, b = - 8 + 2j type(a)  <class ‘complex'> type(b)  <class ‘complex'>
  • 26. Numerical types Character set: • All data and instructions in a program are translated to binary numbers before being run on a real computer. • To support this translation, the characters in a string each map to an integer value. This mapping is defined in character sets, among them the ASCII set and the • UNICODE uses between 8 and 32 bits per character, so it can represent characters from languages from all around the world. • ASCII represents lowercase letters (a- z), uppercase letters (A-Z), digits (0– 9) and symbols
  • 27. Numerical types • ASCII Code of Character “R” is 82 • Row num is 8 • Column num is 2
  • 28. Numerical types • Python’s ord and chr functions convert characters to their numeric ASCII codes and back again, respectively.
  • 29. Variables, Assignments, immutable variables Numerical types The concept of data types
  • 30. Boolean types Boolean: • Data type with one of the two built-in values, True or False. • Boolean objects that are equal to True or False. • Note: True and False with capital ‘T’ and ‘F’ are valid Booleans. Ex : a = True , b = False type(a)  <class ‘bool'> type(b)  <class ‘bool’> Ex : a = “true” b = “false” type(a)  <class ‘str'> type(b)  <class ‘str’>
  • 31. UNIT 1 : SYLLABUS • Conceptual introduction: topics in computer science, algorithms; • Modern computer systems: hardware architecture, data representation in computers, software and operating system; • Installing Python; basic syntax, interactive shell, editing, saving, and running a script. • The concept of data types; variables, assignments; immutable variables; numerical types; • arithmetic operators and expressions; comments in the program; understanding error messages;