SlideShare a Scribd company logo
7
Most read
10
Most read
14
Most read
BASICS ON PYTHON
PROGRAMMING
PROF. POOJA B S
 About the Course
 Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Python is
simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program
maintenance. Python supports modules and packages, which encourages program modularity and code reuse
 Course Objectives
 Learn Syntax and Semantics and create Functions in Python.
 Handle Strings and Files in Python.
 Understand Lists, Dictionaries and Regular expressions in Python.
 Implement Object Oriented Programming concepts in Python
 Introduction to Network Programming in Python
 Course Outcomes
 Explain basic principles of Python programming language
 Interpret the fundamentals of Python and usage of various support libraries
 Problem Solving and Programming Capability
 To learn how to design and program Python applications
Introduction to Python: Basics of Python, Variables,
Expressions, Statements
 Guido Van Rossum in 1991
 Open Source
 General purpose programming language.
 Applications:
 GUI Applications
 Website Applications
 Mobile Applications
 Artificial Intelligence
 Machine Learning Algorithms
Where Python is Used?
 Google
 Netflix
 Dropbox
 National Security Agency (USA)
 BitTorrent
 NASA
Python Development Environments
 PyDev on Eclipse
 Notepad++
 Komodo IDE
 PC (PyCharm)
 Bluefish
 Vim
 LiClipse
 IDLE (Integrated Development and Learning Environment)
How can I download Python?
 The python can be downloaded from the link given below:
https://www.python.org/downloads/
Basics of Python Programming
 >>> Chevron
 Comments in Python:
 #
 ‘’’……………..’’’ or “””……………”””
 Interactive Mode and Scripting Mode
 Keyboard Interrupt:
 Ctrl+c
 Quit the program:
 quit()
 Interpreter v/s Compiler
 Types of Errors in a Program:
 Syntax Errors
 Logical Errors
 Semantic Errors
Simple Programs
1. print(“Hello! Welcome to Python World”) # Hello! Welcome to Python World
2. print(Hello) #Error
3. print(‘Hello’) # Hello
4. print(‘’‘Hello’’’) # Hello
5. X=10 #30
Y=20
print(x+y)
6. num1 = 1.5 #The sum of 1.5 and 6.3 is 7.8
num2 = 6.3
sum = num1 + num2
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
Variables
 Variable is a named literal to store a value.
 Need not be declared before usage in python
 Use “=” to assign value
 Rules for naming a variable:
 Variable name should not be a keyword
 Should not start with a number or special character
 Can only contain special characters “_”
 Eg:
1. 3a=5 #invalid
2. A$=10 #valid
3. if=15 #invalid
Values and Types
 The type of a value can be checked using “type” function
 Eg:
1. type(‘Hello’)
2. type(3)
3. type(100.4)
4. type(2/3)
5. type(325%6)
6. type(2==3)
7. type(‘500’)
8. type(“500”)
9. x=10
y=‘Hi’
print(x)
print(y)
type(x)
type(y)
Operators and Operands
 Arithmetic Operators:
 Relational or Comparison Operators:
+ Addition [a+b]
- Subtraction [a-b]
* Multiplication [a*b]
/ Quotient [a/b] eg: 5/3=1.66667
% Remainder [a%b] eg: 5%3=2
// Floor Division [a//b] eg: 5//3=1
** Exponent [a**b] is equal to a^b eg: 2**3=2^3=8
< Less Than [a<b]
> Greater Than [a>b]
== Comparison [a==b]
 Bitwise Operators
 Assignment Operators
 Used to assign values to variables
 Compound Assignment Operator is: =+
 Eg: x=3
y=5
x+=y #Same as x=x+y
print(x) #8
& AND
| OR
~ NOT
^ XOR
>> Right Shift
<< Left Shift
 Assign different types to variables in a single statement
 Eg:
x, y, str = 3, 4.2, “Hello”
print(“x=”,x, “y=”,y,”str=”,str) #x=3 y=4.2 str=Hello
 Expressions
Combination of values, variables and operators is known as an expression.
Eg: x=5
y=x+10
z=x+y-3
Order of Operations
 Evaluation of Expressions follows on PEMDAS rule
P Parenthesis ()
E Exponent **
M Multiplication *
D Division / and %
A Addition +
S Subtraction -
Eg: print(2**3) #8
print(2**3**2) #512
print(5*2/4) #2.5
print(5/4*2) #2.5
 String Operations
 Use + operator for string concatenation
 Eg: x=“32”
y=“40”
print(x+y) #3240
 User Input
 Built in function: input()
 Eg: 1] str1= input()
print(“Entered String is:”, str1) #Entered String is Hello Python!
2] x= input(“Enter a number”)
type(x) #<class 'str'>
3] x= int(input(“Enter a number”))
type(x) #<class ‘int'>

More Related Content

What's hot (20)

PDF
Python basic
Saifuddin Kaijar
 
PDF
Python - the basics
University of Technology
 
PPTX
Python variables and data types.pptx
AkshayAggarwal79
 
PPTX
Python Tutorial Part 1
Haitham El-Ghareeb
 
PPTX
Python - An Introduction
Swarit Wadhe
 
PPTX
introduction to Python (for beginners)
guobichrng
 
PDF
Python Basics | Python Tutorial | Edureka
Edureka!
 
PPTX
Presentation on python
william john
 
PPTX
Python presentation by Monu Sharma
Mayank Sharma
 
PPTX
Beginning Python Programming
St. Petersburg College
 
PPTX
Python basics
ssuser4e32df
 
PPTX
Fundamentals of Python Programming
Kamal Acharya
 
PDF
Python final ppt
Ripal Ranpara
 
PDF
Python Intro
Tim Penhey
 
PPTX
Python
Aashish Jain
 
PDF
Python Programming Language | Python Classes | Python Tutorial | Python Train...
Edureka!
 
PPTX
Python 101: Python for Absolute Beginners (PyTexas 2014)
Paige Bailey
 
PPTX
Introduction to the Python
BMS Institute of Technology and Management
 
PPTX
Programming
monishagoyal4
 
Python basic
Saifuddin Kaijar
 
Python - the basics
University of Technology
 
Python variables and data types.pptx
AkshayAggarwal79
 
Python Tutorial Part 1
Haitham El-Ghareeb
 
Python - An Introduction
Swarit Wadhe
 
introduction to Python (for beginners)
guobichrng
 
Python Basics | Python Tutorial | Edureka
Edureka!
 
Presentation on python
william john
 
Python presentation by Monu Sharma
Mayank Sharma
 
Beginning Python Programming
St. Petersburg College
 
Python basics
ssuser4e32df
 
Fundamentals of Python Programming
Kamal Acharya
 
Python final ppt
Ripal Ranpara
 
Python Intro
Tim Penhey
 
Python
Aashish Jain
 
Python Programming Language | Python Classes | Python Tutorial | Python Train...
Edureka!
 
Python 101: Python for Absolute Beginners (PyTexas 2014)
Paige Bailey
 
Introduction to the Python
BMS Institute of Technology and Management
 
Programming
monishagoyal4
 

Similar to Python Basics (20)

DOCX
A Introduction Book of python For Beginners.docx
kumarrabinderkumar77
 
PDF
Python Programming by Dr. C. Sreedhar.pdf
Sreedhar Chowdam
 
PPTX
lecture 2.pptx
Anonymous9etQKwW
 
PPT
Python programming
saroja20
 
PPTX
Introduction To Python.pptx
Anum Zehra
 
PPTX
Lecture 1 .
SwatiHans10
 
PPTX
Introduction to python programming ( part-1)
Ziyauddin Shaik
 
PPTX
python_module_.................................................................
VaibhavSrivastav52
 
PPTX
Module-1.pptx
Manohar Nelli
 
PPTX
Welcome to python workshop
Mukul Kirti Verma
 
PPT
Spsl iv unit final
Sasidhar Kothuru
 
PPT
Spsl iv unit final
Sasidhar Kothuru
 
PDF
pythonQuick.pdf
PhanMinhLinhAnxM0190
 
PDF
python 34💭.pdf
AkashdeepBhattacharj1
 
PDF
python notes.pdf
RohitSindhu10
 
PPTX
Basic concept of Python.pptx includes design tool, identifier, variables.
supriyasarkar38
 
PPTX
modul-python-all.pptx
Yusuf Ayuba
 
PPTX
Learn about Python power point presentation
omsumukh85
 
PPTX
Introduction to Python and Basic Syntax.pptx
GevitaChinnaiah
 
PPTX
Bikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa Thapa
 
A Introduction Book of python For Beginners.docx
kumarrabinderkumar77
 
Python Programming by Dr. C. Sreedhar.pdf
Sreedhar Chowdam
 
lecture 2.pptx
Anonymous9etQKwW
 
Python programming
saroja20
 
Introduction To Python.pptx
Anum Zehra
 
Lecture 1 .
SwatiHans10
 
Introduction to python programming ( part-1)
Ziyauddin Shaik
 
python_module_.................................................................
VaibhavSrivastav52
 
Module-1.pptx
Manohar Nelli
 
Welcome to python workshop
Mukul Kirti Verma
 
Spsl iv unit final
Sasidhar Kothuru
 
Spsl iv unit final
Sasidhar Kothuru
 
pythonQuick.pdf
PhanMinhLinhAnxM0190
 
python 34💭.pdf
AkashdeepBhattacharj1
 
python notes.pdf
RohitSindhu10
 
Basic concept of Python.pptx includes design tool, identifier, variables.
supriyasarkar38
 
modul-python-all.pptx
Yusuf Ayuba
 
Learn about Python power point presentation
omsumukh85
 
Introduction to Python and Basic Syntax.pptx
GevitaChinnaiah
 
Bikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa Thapa
 
Ad

More from Pooja B S (6)

PPTX
Iteration
Pooja B S
 
PPTX
String Methods and Files
Pooja B S
 
PPTX
Lists in Python
Pooja B S
 
PPTX
Dictionary
Pooja B S
 
PPTX
String Manipulation in Python
Pooja B S
 
PPTX
Python Conditionals and Functions
Pooja B S
 
Iteration
Pooja B S
 
String Methods and Files
Pooja B S
 
Lists in Python
Pooja B S
 
Dictionary
Pooja B S
 
String Manipulation in Python
Pooja B S
 
Python Conditionals and Functions
Pooja B S
 
Ad

Recently uploaded (20)

PDF
I3PM Case study smart parking 2025 with uptoIP® and ABP
MIPLM
 
PPTX
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
 
PDF
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
PPTX
MATH 8 QUARTER 1 WEEK 1 LESSON 2 PRESENTATION
JohnGuillerNestalBah1
 
PDF
AI-assisted IP-Design lecture from the MIPLM 2025
MIPLM
 
PPTX
How to Add a Custom Button in Odoo 18 POS Screen
Celine George
 
PDF
I3PM Industry Case Study Siemens on Strategic and Value-Oriented IP Management
MIPLM
 
PPTX
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PPTX
Parsing HTML read and write operations and OS Module.pptx
Ramakrishna Reddy Bijjam
 
PDF
Lesson 1 - Nature of Inquiry and Research.pdf
marvinnbustamante1
 
PDF
Lean IP - Lecture by Dr Oliver Baldus at the MIPLM 2025
MIPLM
 
PPTX
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
 
PDF
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
 
PDF
Quiz Night Live May 2025 - Intra Pragya Online General Quiz
Pragya - UEM Kolkata Quiz Club
 
PPTX
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
 
PPTX
ENGLISH 8 REVISED K-12 CURRICULUM QUARTER 1 WEEK 1
LeomarrYsraelArzadon
 
PPTX
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
 
PPTX
PLANNING A HOSPITAL AND NURSING UNIT.pptx
PRADEEP ABOTHU
 
PPTX
Exploring Linear and Angular Quantities and Ergonomic Design.pptx
AngeliqueTolentinoDe
 
I3PM Case study smart parking 2025 with uptoIP® and ABP
MIPLM
 
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
 
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
MATH 8 QUARTER 1 WEEK 1 LESSON 2 PRESENTATION
JohnGuillerNestalBah1
 
AI-assisted IP-Design lecture from the MIPLM 2025
MIPLM
 
How to Add a Custom Button in Odoo 18 POS Screen
Celine George
 
I3PM Industry Case Study Siemens on Strategic and Value-Oriented IP Management
MIPLM
 
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
Parsing HTML read and write operations and OS Module.pptx
Ramakrishna Reddy Bijjam
 
Lesson 1 - Nature of Inquiry and Research.pdf
marvinnbustamante1
 
Lean IP - Lecture by Dr Oliver Baldus at the MIPLM 2025
MIPLM
 
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
 
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
 
Quiz Night Live May 2025 - Intra Pragya Online General Quiz
Pragya - UEM Kolkata Quiz Club
 
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
 
ENGLISH 8 REVISED K-12 CURRICULUM QUARTER 1 WEEK 1
LeomarrYsraelArzadon
 
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
 
PLANNING A HOSPITAL AND NURSING UNIT.pptx
PRADEEP ABOTHU
 
Exploring Linear and Angular Quantities and Ergonomic Design.pptx
AngeliqueTolentinoDe
 

Python Basics

  • 2.  About the Course  Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Python is simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse  Course Objectives  Learn Syntax and Semantics and create Functions in Python.  Handle Strings and Files in Python.  Understand Lists, Dictionaries and Regular expressions in Python.  Implement Object Oriented Programming concepts in Python  Introduction to Network Programming in Python  Course Outcomes  Explain basic principles of Python programming language  Interpret the fundamentals of Python and usage of various support libraries  Problem Solving and Programming Capability  To learn how to design and program Python applications
  • 3. Introduction to Python: Basics of Python, Variables, Expressions, Statements  Guido Van Rossum in 1991  Open Source  General purpose programming language.  Applications:  GUI Applications  Website Applications  Mobile Applications  Artificial Intelligence  Machine Learning Algorithms
  • 4. Where Python is Used?  Google  Netflix  Dropbox  National Security Agency (USA)  BitTorrent  NASA Python Development Environments  PyDev on Eclipse  Notepad++  Komodo IDE  PC (PyCharm)  Bluefish  Vim  LiClipse  IDLE (Integrated Development and Learning Environment)
  • 5. How can I download Python?  The python can be downloaded from the link given below: https://www.python.org/downloads/
  • 6. Basics of Python Programming  >>> Chevron  Comments in Python:  #  ‘’’……………..’’’ or “””……………”””  Interactive Mode and Scripting Mode  Keyboard Interrupt:  Ctrl+c  Quit the program:  quit()  Interpreter v/s Compiler  Types of Errors in a Program:  Syntax Errors  Logical Errors  Semantic Errors
  • 7. Simple Programs 1. print(“Hello! Welcome to Python World”) # Hello! Welcome to Python World 2. print(Hello) #Error 3. print(‘Hello’) # Hello 4. print(‘’‘Hello’’’) # Hello 5. X=10 #30 Y=20 print(x+y) 6. num1 = 1.5 #The sum of 1.5 and 6.3 is 7.8 num2 = 6.3 sum = num1 + num2 print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
  • 8. Variables  Variable is a named literal to store a value.  Need not be declared before usage in python  Use “=” to assign value  Rules for naming a variable:  Variable name should not be a keyword  Should not start with a number or special character  Can only contain special characters “_”  Eg: 1. 3a=5 #invalid 2. A$=10 #valid 3. if=15 #invalid
  • 9. Values and Types  The type of a value can be checked using “type” function  Eg: 1. type(‘Hello’) 2. type(3) 3. type(100.4) 4. type(2/3) 5. type(325%6) 6. type(2==3) 7. type(‘500’) 8. type(“500”) 9. x=10 y=‘Hi’ print(x) print(y) type(x) type(y)
  • 10. Operators and Operands  Arithmetic Operators:  Relational or Comparison Operators: + Addition [a+b] - Subtraction [a-b] * Multiplication [a*b] / Quotient [a/b] eg: 5/3=1.66667 % Remainder [a%b] eg: 5%3=2 // Floor Division [a//b] eg: 5//3=1 ** Exponent [a**b] is equal to a^b eg: 2**3=2^3=8 < Less Than [a<b] > Greater Than [a>b] == Comparison [a==b]
  • 11.  Bitwise Operators  Assignment Operators  Used to assign values to variables  Compound Assignment Operator is: =+  Eg: x=3 y=5 x+=y #Same as x=x+y print(x) #8 & AND | OR ~ NOT ^ XOR >> Right Shift << Left Shift
  • 12.  Assign different types to variables in a single statement  Eg: x, y, str = 3, 4.2, “Hello” print(“x=”,x, “y=”,y,”str=”,str) #x=3 y=4.2 str=Hello  Expressions Combination of values, variables and operators is known as an expression. Eg: x=5 y=x+10 z=x+y-3
  • 13. Order of Operations  Evaluation of Expressions follows on PEMDAS rule P Parenthesis () E Exponent ** M Multiplication * D Division / and % A Addition + S Subtraction - Eg: print(2**3) #8 print(2**3**2) #512 print(5*2/4) #2.5 print(5/4*2) #2.5
  • 14.  String Operations  Use + operator for string concatenation  Eg: x=“32” y=“40” print(x+y) #3240  User Input  Built in function: input()  Eg: 1] str1= input() print(“Entered String is:”, str1) #Entered String is Hello Python! 2] x= input(“Enter a number”) type(x) #<class 'str'> 3] x= int(input(“Enter a number”)) type(x) #<class ‘int'>