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

Intro to Python for Non-Programmers
Intro to Python for Non-ProgrammersIntro to Python for Non-Programmers
Intro to Python for Non-Programmers
Ahmad Alhour
 
Python by Rj
Python by RjPython by Rj
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
Nowell Strite
 
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAChapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Maulik Borsaniya
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
TMARAGATHAM
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An Introduction
Swarit Wadhe
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
primeteacher32
 
Functions in python
Functions in pythonFunctions in python
Functions in python
colorsof
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in python
Jothi Thilaga P
 
Presentation on python
Presentation on pythonPresentation on python
Presentation on python
william john
 
Types of Statements in Python Programming Language
Types of Statements in Python Programming LanguageTypes of Statements in Python Programming Language
Types of Statements in Python Programming Language
Explore Skilled
 
Python cheat-sheet
Python cheat-sheetPython cheat-sheet
Python cheat-sheet
srinivasanr281952
 
Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming
KrishnaMildain
 
Python introduction
Python introductionPython introduction
Python introduction
Jignesh Kariya
 
File handling in Python
File handling in PythonFile handling in Python
Python quick guide1
Python quick guide1Python quick guide1
Python quick guide1Kanchilug
 
Python final ppt
Python final pptPython final ppt
Python final ppt
Ripal Ranpara
 
Introduction python
Introduction pythonIntroduction python
Introduction python
Jumbo Techno e_Learning
 
Python ppt
Python pptPython ppt
Python ppt
Mohita Pandey
 
Python
PythonPython
Python
Aashish Jain
 

What's hot (20)

Intro to Python for Non-Programmers
Intro to Python for Non-ProgrammersIntro to Python for Non-Programmers
Intro to Python for Non-Programmers
 
Python by Rj
Python by RjPython by Rj
Python by Rj
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAChapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An Introduction
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Functions in python
Functions in pythonFunctions in python
Functions in python
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in python
 
Presentation on python
Presentation on pythonPresentation on python
Presentation on python
 
Types of Statements in Python Programming Language
Types of Statements in Python Programming LanguageTypes of Statements in Python Programming Language
Types of Statements in Python Programming Language
 
Python cheat-sheet
Python cheat-sheetPython cheat-sheet
Python cheat-sheet
 
Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming
 
Python introduction
Python introductionPython introduction
Python introduction
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
 
Python quick guide1
Python quick guide1Python quick guide1
Python quick guide1
 
Python final ppt
Python final pptPython final ppt
Python final ppt
 
Introduction python
Introduction pythonIntroduction python
Introduction python
 
Python ppt
Python pptPython ppt
Python ppt
 
Python
PythonPython
Python
 

Similar to Python Basics

Python_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. txPython_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. tx
vishwanathgoudapatil1
 
Welcome to python workshop
Welcome to python workshopWelcome to python workshop
Welcome to python workshop
Mukul Kirti Verma
 
Python programming workshop session 1
Python programming workshop session 1Python programming workshop session 1
Python programming workshop session 1
Abdul Haseeb
 
Introduction of Python
Introduction of PythonIntroduction of Python
Introduction of Python
ZENUS INFOTECH INDIA PVT. LTD.
 
Pyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdfPyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdf
Mattupallipardhu
 
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
manikamr074
 
Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
natnaelmamuye
 
python introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptxpython introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptx
ChandraPrakash715640
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
KosmikTech1
 
Python introduction towards data science
Python introduction towards data sciencePython introduction towards data science
Python introduction towards data science
deepak teja
 
Python Programming by Dr. C. Sreedhar.pdf
Python Programming by Dr. C. Sreedhar.pdfPython Programming by Dr. C. Sreedhar.pdf
Python Programming by Dr. C. Sreedhar.pdf
Sreedhar Chowdam
 
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
Nandakumar P
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
Sasidhar Kothuru
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
Sasidhar Kothuru
 
slides1-introduction to python-programming.pptx
slides1-introduction to python-programming.pptxslides1-introduction to python-programming.pptx
slides1-introduction to python-programming.pptx
AkhdanMumtaz
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
DRVaibhavmeshram1
 
Introduction to Python Basics Programming
Introduction to Python Basics ProgrammingIntroduction to Python Basics Programming
Introduction to Python Basics Programming
Collaboration Technologies
 
PYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdfPYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdf
Ramakrishna Reddy Bijjam
 
Introduction to python.pptx
Introduction to python.pptxIntroduction to python.pptx
Introduction to python.pptx
pcjoshi02
 

Similar to Python Basics (20)

Python_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. txPython_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. tx
 
Welcome to python workshop
Welcome to python workshopWelcome to python workshop
Welcome to python workshop
 
Python programming workshop session 1
Python programming workshop session 1Python programming workshop session 1
Python programming workshop session 1
 
Introduction of Python
Introduction of PythonIntroduction of Python
Introduction of Python
 
Pyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdfPyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdf
 
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
 
Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
 
python introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptxpython introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptx
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
 
Python introduction towards data science
Python introduction towards data sciencePython introduction towards data science
Python introduction towards data science
 
Python Programming by Dr. C. Sreedhar.pdf
Python Programming by Dr. C. Sreedhar.pdfPython Programming by Dr. C. Sreedhar.pdf
Python Programming by Dr. C. Sreedhar.pdf
 
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
 
slides1-introduction to python-programming.pptx
slides1-introduction to python-programming.pptxslides1-introduction to python-programming.pptx
slides1-introduction to python-programming.pptx
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
 
Introduction to Python Basics Programming
Introduction to Python Basics ProgrammingIntroduction to Python Basics Programming
Introduction to Python Basics Programming
 
kecs105.pdf
kecs105.pdfkecs105.pdf
kecs105.pdf
 
PYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdfPYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdf
 
Introduction to python.pptx
Introduction to python.pptxIntroduction to python.pptx
Introduction to python.pptx
 

More from Pooja B S

Iteration
IterationIteration
Iteration
Pooja B S
 
String Methods and Files
String Methods and FilesString Methods and Files
String Methods and Files
Pooja B S
 
Lists in Python
Lists in PythonLists in Python
Lists in Python
Pooja B S
 
Dictionary
DictionaryDictionary
Dictionary
Pooja B S
 
String Manipulation in Python
String Manipulation in PythonString Manipulation in Python
String Manipulation in Python
Pooja B S
 
Python Conditionals and Functions
Python Conditionals and FunctionsPython Conditionals and Functions
Python Conditionals and Functions
Pooja B S
 

More from Pooja B S (6)

Iteration
IterationIteration
Iteration
 
String Methods and Files
String Methods and FilesString Methods and Files
String Methods and Files
 
Lists in Python
Lists in PythonLists in Python
Lists in Python
 
Dictionary
DictionaryDictionary
Dictionary
 
String Manipulation in Python
String Manipulation in PythonString Manipulation in Python
String Manipulation in Python
 
Python Conditionals and Functions
Python Conditionals and FunctionsPython Conditionals and Functions
Python Conditionals and Functions
 

Recently uploaded

Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
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
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
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
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
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
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
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
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 

Recently uploaded (20)

Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
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
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
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
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
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...
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
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
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 

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'>