SlideShare a Scribd company logo
1 of 27
1.1 Introduction to Python
1ARULKUMAR V AP/CSE SECE
Objectives
2
 To write and run a simple Python program.
 To explain the basic syntax of a Python program (§1.5).
 To describe the history of Python (§1.6).
 To explain the importance of, and provide examples of,
proper programming style and documentation (§1.7).
 To explain the differences between syntax errors,
runtime errors, and logic errors (§1.8).
 To create a basic graphics program using Turtle (§1.9).
ARULKUMAR V AP/CSE SECE
What is Python?
General Purpose Interpreted Object-Oriented
3
Python is a general purpose programming language.
That means you can use Python to write code for
any programming tasks. Python are now used in
Google search engine, in mission critical projects in
NASA, in processing financial transactions at New
York Stock Exchange.
ARULKUMAR V AP/CSE SECE
What is Python?
General Purpose Interpreted Object-Oriented
4
Python is interpreted, which means that python
code is translated and executed by an interpreter
one statement at a time. In a compiled language, the
entire source code is compiled and then executed
altogether.
ARULKUMAR V AP/CSE SECE
What is Python?
General Purpose Interpreted Object-Oriented
5
Python is an object-oriented programming
language. Data in Python are objects created from
classes. A class is essentially a type that defines the
objects of the same kind with properties and
methods for manipulating objects. Object-oriented
programming is a powerful tool for developing
reusable software.
ARULKUMAR V AP/CSE SECE
Python’s History
• created by Guido van Rossum in Netherlands in
1990
• Open source
6ARULKUMAR V AP/CSE SECE
Python 2 vs. Python 3
Python 3 is a newer version, but it is not
backward compatible with Python 2. That
means if you write a program using Python
2, it may not work on Python 3.
7ARULKUMAR V AP/CSE SECE
Launch Python
8ARULKUMAR V AP/CSE SECE
Launch Python IDLE
9ARULKUMAR V AP/CSE SECE
Run Python Script
10ARULKUMAR V AP/CSE SECE
A Simple Python Program
# Display two messages
print("Welcome to Python")
print("Python is fun")
11
Run
Welcome
Listing 1.1
IMPORTANT NOTE:
(1) To enable the buttons, you must download the entire slide
file slide.zip and unzip the files into a directory (e.g.,
c:slide). (2) You must have installed Python and set python
bin directory in the environment path. (3) If you are using
Office 2010, check PowerPoint2010.doc located in the
same folder with this ppt file.
ARULKUMAR V AP/CSE SECE
Creating and Editing Using Notepad
To use Notepad, type
notepad Welcome.py
from the DOS prompt.
12ARULKUMAR V AP/CSE SECE
Trace a Program Execution
13
# Display two messages
print("Welcome to Python")
print("Python is fun")
Execute a statement
animation
ARULKUMAR V AP/CSE SECE
Trace a Program Execution
14
# Display two messages
print("Welcome to Python")
print("Python is fun")
Execute a statement
animation
ARULKUMAR V AP/CSE SECE
Two More Simple Examples
15
RunWelcomeWithThreeMessages
RunComputeExpression
ARULKUMAR V AP/CSE SECE
Supplements on the
Companion Website
• See Supplement I.B for installing and
configuring Python
• See Supplement I.C for developing Python
programs from Eclipse
www.cs.armstrong.edu/liang/py
16
Companion
Website
ARULKUMAR V AP/CSE SECE
Anatomy of a Python Program
• Statements
• Comments
• Indentation
17ARULKUMAR V AP/CSE SECE
Statement
A statement represents an action or a sequence of
actions. The statement print("Welcome to Python") in
the program in Listing 1.1 is a statement to display the
greeting "Welcome to Python“.
18
# Display two messages
print("Welcome to Python")
print("Python is fun")
ARULKUMAR V AP/CSE SECE
Indentation
The indentation matters in Python. Note that the
statements are entered from the first column in
the new line. It would cause an error if the
program is typed as follows:
19
# Display two messages
print("Welcome to Python")
print("Python is fun")
ARULKUMAR V AP/CSE SECE
Special Symbols
20
Character Name Description
()
#
" "
''' '''
Opening and closing
parentheses
Pound sign
Opening and closing
quotation marks
Opening and closing
quotation marks
Used with functions.
Precedes a comment line.
Enclosing a string (i.e., sequence of characters).
Enclosing a paragraph comment.
ARULKUMAR V AP/CSE SECE
Programming Style and
Documentation
• Appropriate Comments
• Proper Indentation and Spacing
Lines
21ARULKUMAR V AP/CSE SECE
Appropriate Comments
Include a summary at the beginning of the
program to explain what the program does, its key
features, its supporting data structures, and any
unique techniques it uses.
Include your name, class section, instructor, date,
and a brief description at the beginning of the
program.
22ARULKUMAR V AP/CSE SECE
Proper Indentation and Spacing
• Indentation
– Indent four spaces.
– A consistent spacing style makes programs clear
and easy to read, debug, and maintain.
• Spacing
– Use blank line to separate segments of the
code.
23ARULKUMAR V AP/CSE SECE
Programming Errors
• Syntax Errors
– Error in code construction
• Runtime Errors
– Causes the program to abort
• Logic Errors
– Produces incorrect result
24ARULKUMAR V AP/CSE SECE
Getting Started with GUI Programming
Why GUI? Turtle Tkniter
25
GUI is a great pedagogical tool to motivate studetns
and stimulate student interests in programming.
ARULKUMAR V AP/CSE SECE
Getting Started with GUI Programming
Why GUI? Turtle Tkniter
26
A simple way to start graphics programming is to
use Python built-in Turtle package.
Run
A Turtule Example
ARULKUMAR V AP/CSE SECE
Getting Started with GUI Programming
Why GUI? Turtle Tkniter
27
Later in the book, we will also introduce Tkinter for
developing comprehensive GUI applications.
Run
A Tkinter Example
ARULKUMAR V AP/CSE SECE

More Related Content

What's hot

C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control StructureSokngim Sa
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming LanguageDr.YNM
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on pythonShubham Yadav
 
ML & AI based Cloud Compiler.pptx
ML & AI based Cloud Compiler.pptxML & AI based Cloud Compiler.pptx
ML & AI based Cloud Compiler.pptxViji B
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)sachindane
 
Risk management in software engineering
Risk management in software engineeringRisk management in software engineering
Risk management in software engineeringdeep sharma
 
Looping Statement And Flow Chart
 Looping Statement And Flow Chart Looping Statement And Flow Chart
Looping Statement And Flow ChartRahul Sahu
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1REHAN IJAZ
 
C Structures and Unions
C Structures and UnionsC Structures and Unions
C Structures and UnionsDhrumil Patel
 
Intro to Python for Non-Programmers
Intro to Python for Non-ProgrammersIntro to Python for Non-Programmers
Intro to Python for Non-ProgrammersAhmad Alhour
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#Hawkman Academy
 
Introduction To Programming with Python
Introduction To Programming with PythonIntroduction To Programming with Python
Introduction To Programming with PythonSushant Mane
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python ProgrammingKamal Acharya
 

What's hot (20)

C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 
C programming language
C programming languageC programming language
C programming language
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on python
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
ML & AI based Cloud Compiler.pptx
ML & AI based Cloud Compiler.pptxML & AI based Cloud Compiler.pptx
ML & AI based Cloud Compiler.pptx
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
 
Risk management in software engineering
Risk management in software engineeringRisk management in software engineering
Risk management in software engineering
 
Pascal programming lecture notes
Pascal programming lecture notesPascal programming lecture notes
Pascal programming lecture notes
 
Python basic
Python basicPython basic
Python basic
 
Looping Statement And Flow Chart
 Looping Statement And Flow Chart Looping Statement And Flow Chart
Looping Statement And Flow Chart
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
 
C Structures and Unions
C Structures and UnionsC Structures and Unions
C Structures and Unions
 
Intro to Python for Non-Programmers
Intro to Python for Non-ProgrammersIntro to Python for Non-Programmers
Intro to Python for Non-Programmers
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
 
Introduction To Programming with Python
Introduction To Programming with PythonIntroduction To Programming with Python
Introduction To Programming with Python
 
Looping in C
Looping in CLooping in C
Looping in C
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 

Similar to 1. introduction to python

Chapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdfChapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdfKirubelWondwoson1
 
Java lab1 manual
Java lab1 manualJava lab1 manual
Java lab1 manualnahalomar
 
(D 15 180770107240)
(D 15 180770107240)(D 15 180770107240)
(D 15 180770107240)RaviModi37
 
Socket programming-in-python
Socket programming-in-pythonSocket programming-in-python
Socket programming-in-pythonYuvaraja Ravi
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting StartedMartin Chapman
 
Python_final_print_vison_academy_9822506209.pdf
Python_final_print_vison_academy_9822506209.pdfPython_final_print_vison_academy_9822506209.pdf
Python_final_print_vison_academy_9822506209.pdfVisionAcademyProfSac
 
ProgFund_Lecture_7_Intro_C_Sequence.pdf
ProgFund_Lecture_7_Intro_C_Sequence.pdfProgFund_Lecture_7_Intro_C_Sequence.pdf
ProgFund_Lecture_7_Intro_C_Sequence.pdflailoesakhan
 
Python Intro For Managers
Python Intro For ManagersPython Intro For Managers
Python Intro For ManagersAtul Shridhar
 
Python_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdfPython_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdfbhagyashri686896
 
Python_final_print_batch_II_vision_academy (1).pdf
Python_final_print_batch_II_vision_academy (1).pdfPython_final_print_batch_II_vision_academy (1).pdf
Python_final_print_batch_II_vision_academy (1).pdfrupaliakhute
 
Python_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdfPython_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdfsannykhopade
 
Python_vision_academy notes
Python_vision_academy notes Python_vision_academy notes
Python_vision_academy notes rajaniraut
 
Module1-Chapter1_ppt.pptx
Module1-Chapter1_ppt.pptxModule1-Chapter1_ppt.pptx
Module1-Chapter1_ppt.pptxSandeepR95
 
Assignment1 B 0
Assignment1 B 0Assignment1 B 0
Assignment1 B 0Mahmoud
 

Similar to 1. introduction to python (20)

Chapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdfChapter 1 - Basic concepts of programming.pdf
Chapter 1 - Basic concepts of programming.pdf
 
Java lab1 manual
Java lab1 manualJava lab1 manual
Java lab1 manual
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
(D 15 180770107240)
(D 15 180770107240)(D 15 180770107240)
(D 15 180770107240)
 
Socket programming-in-python
Socket programming-in-pythonSocket programming-in-python
Socket programming-in-python
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting Started
 
Python_final_print_vison_academy_9822506209.pdf
Python_final_print_vison_academy_9822506209.pdfPython_final_print_vison_academy_9822506209.pdf
Python_final_print_vison_academy_9822506209.pdf
 
Programming
ProgrammingProgramming
Programming
 
Python PPT1.pdf
Python PPT1.pdfPython PPT1.pdf
Python PPT1.pdf
 
ProgFund_Lecture_7_Intro_C_Sequence.pdf
ProgFund_Lecture_7_Intro_C_Sequence.pdfProgFund_Lecture_7_Intro_C_Sequence.pdf
ProgFund_Lecture_7_Intro_C_Sequence.pdf
 
Python Intro For Managers
Python Intro For ManagersPython Intro For Managers
Python Intro For Managers
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
 
Python_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdfPython_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdf
 
Python_final_print_batch_II_vision_academy (1).pdf
Python_final_print_batch_II_vision_academy (1).pdfPython_final_print_batch_II_vision_academy (1).pdf
Python_final_print_batch_II_vision_academy (1).pdf
 
Python_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdfPython_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdf
 
Python_vision_academy notes
Python_vision_academy notes Python_vision_academy notes
Python_vision_academy notes
 
Core python programming tutorial
Core python programming tutorialCore python programming tutorial
Core python programming tutorial
 
C tutorials
C tutorialsC tutorials
C tutorials
 
Module1-Chapter1_ppt.pptx
Module1-Chapter1_ppt.pptxModule1-Chapter1_ppt.pptx
Module1-Chapter1_ppt.pptx
 
Assignment1 B 0
Assignment1 B 0Assignment1 B 0
Assignment1 B 0
 

More from PhD Research Scholar (20)

Ajax
AjaxAjax
Ajax
 
Quiz servlet
Quiz servletQuiz servlet
Quiz servlet
 
Quiz
QuizQuiz
Quiz
 
servlet db connectivity
servlet db connectivityservlet db connectivity
servlet db connectivity
 
2.java script dom
2.java script  dom2.java script  dom
2.java script dom
 
1.java script
1.java script1.java script
1.java script
 
Quiz javascript
Quiz javascriptQuiz javascript
Quiz javascript
 
Thread&multithread
Thread&multithreadThread&multithread
Thread&multithread
 
String
StringString
String
 
Streams&io
Streams&ioStreams&io
Streams&io
 
Packages
PackagesPackages
Packages
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Inner classes in java
Inner classes in javaInner classes in java
Inner classes in java
 
Inheritance
InheritanceInheritance
Inheritance
 
Exception handling
Exception handlingException handling
Exception handling
 
Applets
AppletsApplets
Applets
 
Abstract class
Abstract classAbstract class
Abstract class
 
7. tuples, set & dictionary
7. tuples, set & dictionary7. tuples, set & dictionary
7. tuples, set & dictionary
 
6. list
6. list6. list
6. list
 
5. string
5. string5. string
5. string
 

Recently uploaded

Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 

Recently uploaded (20)

ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 

1. introduction to python

  • 1. 1.1 Introduction to Python 1ARULKUMAR V AP/CSE SECE
  • 2. Objectives 2  To write and run a simple Python program.  To explain the basic syntax of a Python program (§1.5).  To describe the history of Python (§1.6).  To explain the importance of, and provide examples of, proper programming style and documentation (§1.7).  To explain the differences between syntax errors, runtime errors, and logic errors (§1.8).  To create a basic graphics program using Turtle (§1.9). ARULKUMAR V AP/CSE SECE
  • 3. What is Python? General Purpose Interpreted Object-Oriented 3 Python is a general purpose programming language. That means you can use Python to write code for any programming tasks. Python are now used in Google search engine, in mission critical projects in NASA, in processing financial transactions at New York Stock Exchange. ARULKUMAR V AP/CSE SECE
  • 4. What is Python? General Purpose Interpreted Object-Oriented 4 Python is interpreted, which means that python code is translated and executed by an interpreter one statement at a time. In a compiled language, the entire source code is compiled and then executed altogether. ARULKUMAR V AP/CSE SECE
  • 5. What is Python? General Purpose Interpreted Object-Oriented 5 Python is an object-oriented programming language. Data in Python are objects created from classes. A class is essentially a type that defines the objects of the same kind with properties and methods for manipulating objects. Object-oriented programming is a powerful tool for developing reusable software. ARULKUMAR V AP/CSE SECE
  • 6. Python’s History • created by Guido van Rossum in Netherlands in 1990 • Open source 6ARULKUMAR V AP/CSE SECE
  • 7. Python 2 vs. Python 3 Python 3 is a newer version, but it is not backward compatible with Python 2. That means if you write a program using Python 2, it may not work on Python 3. 7ARULKUMAR V AP/CSE SECE
  • 11. A Simple Python Program # Display two messages print("Welcome to Python") print("Python is fun") 11 Run Welcome Listing 1.1 IMPORTANT NOTE: (1) To enable the buttons, you must download the entire slide file slide.zip and unzip the files into a directory (e.g., c:slide). (2) You must have installed Python and set python bin directory in the environment path. (3) If you are using Office 2010, check PowerPoint2010.doc located in the same folder with this ppt file. ARULKUMAR V AP/CSE SECE
  • 12. Creating and Editing Using Notepad To use Notepad, type notepad Welcome.py from the DOS prompt. 12ARULKUMAR V AP/CSE SECE
  • 13. Trace a Program Execution 13 # Display two messages print("Welcome to Python") print("Python is fun") Execute a statement animation ARULKUMAR V AP/CSE SECE
  • 14. Trace a Program Execution 14 # Display two messages print("Welcome to Python") print("Python is fun") Execute a statement animation ARULKUMAR V AP/CSE SECE
  • 15. Two More Simple Examples 15 RunWelcomeWithThreeMessages RunComputeExpression ARULKUMAR V AP/CSE SECE
  • 16. Supplements on the Companion Website • See Supplement I.B for installing and configuring Python • See Supplement I.C for developing Python programs from Eclipse www.cs.armstrong.edu/liang/py 16 Companion Website ARULKUMAR V AP/CSE SECE
  • 17. Anatomy of a Python Program • Statements • Comments • Indentation 17ARULKUMAR V AP/CSE SECE
  • 18. Statement A statement represents an action or a sequence of actions. The statement print("Welcome to Python") in the program in Listing 1.1 is a statement to display the greeting "Welcome to Python“. 18 # Display two messages print("Welcome to Python") print("Python is fun") ARULKUMAR V AP/CSE SECE
  • 19. Indentation The indentation matters in Python. Note that the statements are entered from the first column in the new line. It would cause an error if the program is typed as follows: 19 # Display two messages print("Welcome to Python") print("Python is fun") ARULKUMAR V AP/CSE SECE
  • 20. Special Symbols 20 Character Name Description () # " " ''' ''' Opening and closing parentheses Pound sign Opening and closing quotation marks Opening and closing quotation marks Used with functions. Precedes a comment line. Enclosing a string (i.e., sequence of characters). Enclosing a paragraph comment. ARULKUMAR V AP/CSE SECE
  • 21. Programming Style and Documentation • Appropriate Comments • Proper Indentation and Spacing Lines 21ARULKUMAR V AP/CSE SECE
  • 22. Appropriate Comments Include a summary at the beginning of the program to explain what the program does, its key features, its supporting data structures, and any unique techniques it uses. Include your name, class section, instructor, date, and a brief description at the beginning of the program. 22ARULKUMAR V AP/CSE SECE
  • 23. Proper Indentation and Spacing • Indentation – Indent four spaces. – A consistent spacing style makes programs clear and easy to read, debug, and maintain. • Spacing – Use blank line to separate segments of the code. 23ARULKUMAR V AP/CSE SECE
  • 24. Programming Errors • Syntax Errors – Error in code construction • Runtime Errors – Causes the program to abort • Logic Errors – Produces incorrect result 24ARULKUMAR V AP/CSE SECE
  • 25. Getting Started with GUI Programming Why GUI? Turtle Tkniter 25 GUI is a great pedagogical tool to motivate studetns and stimulate student interests in programming. ARULKUMAR V AP/CSE SECE
  • 26. Getting Started with GUI Programming Why GUI? Turtle Tkniter 26 A simple way to start graphics programming is to use Python built-in Turtle package. Run A Turtule Example ARULKUMAR V AP/CSE SECE
  • 27. Getting Started with GUI Programming Why GUI? Turtle Tkniter 27 Later in the book, we will also introduce Tkinter for developing comprehensive GUI applications. Run A Tkinter Example ARULKUMAR V AP/CSE SECE