SlideShare une entreprise Scribd logo
1  sur  32
Télécharger pour lire hors ligne
CS3430:Python & Perl
Lecture 01
Department of Computer Science
Utah State University
Outline
●
●

●
●
●
●
●

Course Overview
Python Overview: History, Features, Strengths,
Weaknesses
Installing Python on Windows/Linux/Mac OS
Python 2.X or Python 3.X
Playing with Python through its Interpreter
Comments, Booleans, Variables, Lists, Strings, Tuples
Built-in Functions and Methods
Schedule & Workload
●

Python – 10 weeks

●

Perl – 5 weeks

●

Two exams (dates in the syllabus)
Midterm 1: Python
 Midterm 2: Python & Perl (mostly Perl)
Regular weekly coding assignments


●
●

Final project (last 4 weeks)
Texts
Python Text 1
Python Text 2

Download free PDF version at http://greenteapress.com/thinkpython/thinkpython.html
Perl Text
Logistics
●
●

●

No emails on weekends please
Both exams will be online; you can take them anywhere you
want
Please turn off your cell phones in class
Class Attendance
●
●

●

Class attendance is completely optional
I know students who show up for every class and get C's and
D's; I know students who show up for no class or just a few
classes and ace all assignments, projects, and exams
Do not waste your time showing up for class to do homework
for other classes, read email, browse the web, chat with
friends, play games, etc
Python Overview
History, Features, Strengths, Weaknesses
History
●
●

●
●

●

Python is a general purpose programming language
Python is considered a scripting language but it is possible and practical to develop systems and executables
Python was created by Guido van Rossum in the 1990's.
Guido van Rossum is sometimes referred to as “Python's
Benevolent Dictator for Life” (BDFL).
The name “Python” comes from “Monty Python's Flying
Circus.”
Features
●
●

●
●
●

Dynamic typing
Automatic memory management (aka garbage
collection)
Support for large applications (system programming)
Numerous built-in tools and libraries
Numerous 3rd party tools and libraries
Strengths
●

Free

●

Portable

●

Easy to learn and use

●

Mixable
C/C++ programs can call Python programs
 Python can link to C/C++ libraries
Supports object-oriented programming


●
Weakness
●

●

Python programs can run slower than their C/C++
counterparts
If and when this happens, you have to ask yourselves two
questions:



Do I really need this for my particular application? In
many cases, no!
Can I port the bottleneck to C/C++? In many cases, yes!
Why not C++ for Everything?
Scripting languages represent a different set of tradeoffs
than system programming languages. They give up
execution speed and strength of typing relative to system
programming languages but provide significantly higher
programmer productivity and software reuse.
John K. Ousterhout, Creator of Tcl
“Scripting: Higher Level Programming for the 21st
Century” IEEE Computer magazine, March 1998
Full article: http://www.tcl.tk/doc/scripting.html
Python 2.X or Python 3.X
Python 2 or Python 3?
●

●

●

●

Python 2.X is the status quo, Python 3.x is the shiny new
thing
Python 3.X is the newest branch of Python and the
intended future of the language
However, the broader Python 2.X ecosystem has amassed
a significant amount of quality software over the years
Insightful article on Python 2 vs. Python 3 on
www.python.org
Python 2 or Python 3?
●

●

●

While Python 3.X is the same language, it is not
backward compatible to Python 2.X
The downside of breaking backwards compatibility in
3.X is that a lot of that software does not work on 3.X
yet; this transition will take time
Python 3.X has relatively limited library support; many
Linux distributions and Macs ship with 2.X
Reasons to Prefer Python 2 over Python 3 (For Now)
1. If you are deploying to an environment you do not control.
2. If you use a third party package that does not have a released
Python 3 version.
3. If you want to use a third-party tool such as Python Image
Library (PIL), Twisted (for networking), Django (for building
websites), or py2exe (for packaging your application for Windows
users)
Reasons to Prefer Python 2 over Python 3 (For Now)
4. A lot of documentation (including examples) on the web and in
reference books will be for Python 2 for the near future
5. Most of us are inclined to seek help online. The Python regulars
are typically seasoned developers who rely on legacy software, most
of which has not been ported to Python 3 yet. As a result, they might
not be able to help you with Python issues
6. It is always better to study the tool you are transitioning to and
wait until it becomes accepted by the broader community.
Installing Python on
Windows/Linux/Mac OS
What We Will Use
●
●

●

We will use Python 2.7 in this class
If you are a Linux user, note that many versions of
Linux ship with 2.6.X
If you are a Mac user, note that most Macs still ship
with 2.6.X; check for the Mac distribution of 2.7
Installing Python
●
●

●

●

www.python.org is the site for everything that is Python.
On Windows, I use IDLE for execution and debugging and
IDLE or Emacs for editing
On Linux (Ubuntu), I use command line interpreters for
execution and debugging and Emacs for editing.
You may want to play with several choices and choose what
you like best. It does not really matter which IDE you use.
You will submit only the Python source files (.py) in your
assignments
Playing with Python
Python Interpreter
●

●

●

Python Interpreter is an interactive program that allows you to
work with Python source code without having to create, edit,
save, and compile source files
As you read online materials or test, I suggest that you keep
the Python interpreter window running and try code snippets
right away
Most Python IDEs make the Python interpreter easily
available
Python Interpreter
>>> print 'Hello, Python!'
Hello, Python!
>>> “Hello, Python!”
Hello, Python!
>>> 5
5
>>> 5 + 10
15
Comments
●
●

The hash mark character (#) introduces comments
# can appear at the beginning of a line or in the middle of a
line

●

The characters after # and upto n are part of a comment

●

Examples:



# This is a comment
x + y # add x and y
Variables
●

●
●

●

Since Python is a dynamically typed language, the types of
variables are not explicitly declared
A variable can refer to an object of any legal Python type
The type of a variable is determined at run time through the
operations that are applied to the variable's value
Examples:





>>> x = 1 # the value of x is integer 1
>>> x + 1 # is OK
>>> x + 'bar' # is ERROR
●

●

Python has two Boolean values: True and False

Booleans

All Python values can be represented as Booleans: all numbers except
0 are True; all non-empty containers are True; all empty containers
are False; For example:


>>> file_ready = False



>>> bool(file_ready)
False



>>> bool(1)
True



>>> bool([])



False
Factory Functions
●

Numeric types have factory functions that convert from one type to
another; For example:


>>> int('12')
12



>>> int(12.5)
12



>>> int('12.1')
ERROR



>>> float('12.1')
12.1
Lists, Strings, Tuples, Iterables
●

Lists: [1, 2, 'a']

●

Strings: 'Python', “Python”, “Djangon”

●

Tuples: ('a', 1), (1, 2)

●

Lists are mutable (support assignment)

●

Strings and tuples are immutable

●

Iterables are any objects that can be iterated through one item
at a time
Reading & References
●
●

●

www.python.org.
Ch. 01, M. L. HetLand. Beginning Python From Novice to
nd
Professional, ,2 Ed., APRESS.
H. Abelson and J. Sussman. Structure and Interpretation of
Computer Programs, 2nd Ed., MIT Press.

Contenu connexe

Tendances

Python course syllabus
Python course syllabusPython course syllabus
Python course syllabusSugantha T
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An IntroductionSwarit Wadhe
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonAgung Wahyudi
 
Anton Kasyanov, Introduction to Python, Lecture1
Anton Kasyanov, Introduction to Python, Lecture1Anton Kasyanov, Introduction to Python, Lecture1
Anton Kasyanov, Introduction to Python, Lecture1Anton Kasyanov
 
Learning Python with PyCharm EDU
Learning Python with PyCharm EDU Learning Python with PyCharm EDU
Learning Python with PyCharm EDU Sergey Aganezov
 
Introduction about Python by JanBask Training
Introduction about Python by JanBask TrainingIntroduction about Python by JanBask Training
Introduction about Python by JanBask TrainingJanBask Training
 
Introduction to phython programming
Introduction to phython programmingIntroduction to phython programming
Introduction to phython programmingASIT Education
 
Why Python?
Why Python?Why Python?
Why Python?Adam Pah
 
Python 101 For The Net Developer
Python 101 For The Net DeveloperPython 101 For The Net Developer
Python 101 For The Net DeveloperSarah Dutkiewicz
 
Seminar report On Python
Seminar report On PythonSeminar report On Python
Seminar report On PythonShivam Gupta
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythoneShikshak
 
IHTM Python PCEP Introduction to Python
IHTM Python PCEP Introduction to PythonIHTM Python PCEP Introduction to Python
IHTM Python PCEP Introduction to PythonIHTMINSTITUTE
 
Python for the C# developer
Python for the C# developerPython for the C# developer
Python for the C# developerMichael Kennedy
 
Introduction to Python Basics Programming
Introduction to Python Basics ProgrammingIntroduction to Python Basics Programming
Introduction to Python Basics ProgrammingRaveendra R
 

Tendances (20)

Python course syllabus
Python course syllabusPython course syllabus
Python course syllabus
 
Why learn python in 2017?
Why learn python in 2017?Why learn python in 2017?
Why learn python in 2017?
 
Python for All
Python for All Python for All
Python for All
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An Introduction
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Anton Kasyanov, Introduction to Python, Lecture1
Anton Kasyanov, Introduction to Python, Lecture1Anton Kasyanov, Introduction to Python, Lecture1
Anton Kasyanov, Introduction to Python, Lecture1
 
Learning Python with PyCharm EDU
Learning Python with PyCharm EDU Learning Python with PyCharm EDU
Learning Python with PyCharm EDU
 
Introduction about Python by JanBask Training
Introduction about Python by JanBask TrainingIntroduction about Python by JanBask Training
Introduction about Python by JanBask Training
 
Introduction to phython programming
Introduction to phython programmingIntroduction to phython programming
Introduction to phython programming
 
Python
PythonPython
Python
 
Why Python?
Why Python?Why Python?
Why Python?
 
Lets learn Python !
Lets learn Python !Lets learn Python !
Lets learn Python !
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Python 101 For The Net Developer
Python 101 For The Net DeveloperPython 101 For The Net Developer
Python 101 For The Net Developer
 
Seminar report On Python
Seminar report On PythonSeminar report On Python
Seminar report On Python
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
IHTM Python PCEP Introduction to Python
IHTM Python PCEP Introduction to PythonIHTM Python PCEP Introduction to Python
IHTM Python PCEP Introduction to Python
 
Python for the C# developer
Python for the C# developerPython for the C# developer
Python for the C# developer
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Introduction to Python Basics Programming
Introduction to Python Basics ProgrammingIntroduction to Python Basics Programming
Introduction to Python Basics Programming
 

Similaire à Python lecture 01

Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.Niraj Bharambe
 
Python final presentation kirti ppt1
Python final presentation kirti ppt1Python final presentation kirti ppt1
Python final presentation kirti ppt1Kirti Verma
 
Python for students step by step guidance
Python for students step by step guidancePython for students step by step guidance
Python for students step by step guidanceMantoshKumar79
 
Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1Ahmet Bulut
 
Introduction to python updated
Introduction to python   updatedIntroduction to python   updated
Introduction to python updatedchakrib5
 
Python Training in Pune - Ethans Tech Pune
Python Training in Pune - Ethans Tech PunePython Training in Pune - Ethans Tech Pune
Python Training in Pune - Ethans Tech PuneEthan's Tech
 
Introduction to Python Unit -1 Part .pdf
Introduction to Python Unit -1 Part .pdfIntroduction to Python Unit -1 Part .pdf
Introduction to Python Unit -1 Part .pdfVaibhavKumarSinghkal
 
Session-1_Introduction to Python.pptx
Session-1_Introduction to Python.pptxSession-1_Introduction to Python.pptx
Session-1_Introduction to Python.pptxWajidAliHashmi2
 
Lecture 2 introduction to python
Lecture 2  introduction to pythonLecture 2  introduction to python
Lecture 2 introduction to pythonalvin567
 
IRJET- Python: Simple though an Important Programming Language
IRJET- Python: Simple though an Important Programming LanguageIRJET- Python: Simple though an Important Programming Language
IRJET- Python: Simple though an Important Programming LanguageIRJET Journal
 

Similaire à Python lecture 01 (20)

python-ppt.ppt
python-ppt.pptpython-ppt.ppt
python-ppt.ppt
 
python-ppt.ppt
python-ppt.pptpython-ppt.ppt
python-ppt.ppt
 
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
Python Book/Notes For Python Book/Notes For S.Y.B.Sc. I.T.
 
python-handbook.pdf
python-handbook.pdfpython-handbook.pdf
python-handbook.pdf
 
Python final presentation kirti ppt1
Python final presentation kirti ppt1Python final presentation kirti ppt1
Python final presentation kirti ppt1
 
01 python introduction
01 python introduction 01 python introduction
01 python introduction
 
Python for students step by step guidance
Python for students step by step guidancePython for students step by step guidance
Python for students step by step guidance
 
Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1
 
Research paper on python by Rj
Research paper on python by RjResearch paper on python by Rj
Research paper on python by Rj
 
Chapter - 1.pptx
Chapter - 1.pptxChapter - 1.pptx
Chapter - 1.pptx
 
Introduction to python updated
Introduction to python   updatedIntroduction to python   updated
Introduction to python updated
 
MODULE 1.pptx
MODULE 1.pptxMODULE 1.pptx
MODULE 1.pptx
 
Python Training in Pune - Ethans Tech Pune
Python Training in Pune - Ethans Tech PunePython Training in Pune - Ethans Tech Pune
Python Training in Pune - Ethans Tech Pune
 
Welcome_to_Python.pptx
Welcome_to_Python.pptxWelcome_to_Python.pptx
Welcome_to_Python.pptx
 
Introduction to Python Unit -1 Part .pdf
Introduction to Python Unit -1 Part .pdfIntroduction to Python Unit -1 Part .pdf
Introduction to Python Unit -1 Part .pdf
 
Session-1_Introduction to Python.pptx
Session-1_Introduction to Python.pptxSession-1_Introduction to Python.pptx
Session-1_Introduction to Python.pptx
 
Lecture 2 introduction to python
Lecture 2  introduction to pythonLecture 2  introduction to python
Lecture 2 introduction to python
 
IRJET- Python: Simple though an Important Programming Language
IRJET- Python: Simple though an Important Programming LanguageIRJET- Python: Simple though an Important Programming Language
IRJET- Python: Simple though an Important Programming Language
 
python unit2.pptx
python unit2.pptxpython unit2.pptx
python unit2.pptx
 
1-ppt-python.ppt
1-ppt-python.ppt1-ppt-python.ppt
1-ppt-python.ppt
 

Plus de Tanwir Zaman

Plus de Tanwir Zaman (16)

Cs3430 lecture 17
Cs3430 lecture 17Cs3430 lecture 17
Cs3430 lecture 17
 
Cs3430 lecture 15
Cs3430 lecture 15Cs3430 lecture 15
Cs3430 lecture 15
 
Cs3430 lecture 14
Cs3430 lecture 14Cs3430 lecture 14
Cs3430 lecture 14
 
Cs3430 lecture 13
Cs3430 lecture 13Cs3430 lecture 13
Cs3430 lecture 13
 
Cs3430 lecture 16
Cs3430 lecture 16Cs3430 lecture 16
Cs3430 lecture 16
 
Python lecture 12
Python lecture 12Python lecture 12
Python lecture 12
 
Python lecture 10
Python lecture 10Python lecture 10
Python lecture 10
 
Python lecture 09
Python lecture 09Python lecture 09
Python lecture 09
 
Python lecture 8
Python lecture 8Python lecture 8
Python lecture 8
 
Python lecture 07
Python lecture 07Python lecture 07
Python lecture 07
 
Python lecture 06
Python lecture 06Python lecture 06
Python lecture 06
 
Python lecture 05
Python lecture 05Python lecture 05
Python lecture 05
 
Python lecture 04
Python lecture 04Python lecture 04
Python lecture 04
 
Python lecture 03
Python lecture 03Python lecture 03
Python lecture 03
 
Python lecture 02
Python lecture 02Python lecture 02
Python lecture 02
 
Python lecture 11
Python lecture 11Python lecture 11
Python lecture 11
 

Dernier

Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxruthvilladarez
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxElton John Embodo
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 

Dernier (20)

Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 

Python lecture 01

  • 1. CS3430:Python & Perl Lecture 01 Department of Computer Science Utah State University
  • 2. Outline ● ● ● ● ● ● ● Course Overview Python Overview: History, Features, Strengths, Weaknesses Installing Python on Windows/Linux/Mac OS Python 2.X or Python 3.X Playing with Python through its Interpreter Comments, Booleans, Variables, Lists, Strings, Tuples Built-in Functions and Methods
  • 3. Schedule & Workload ● Python – 10 weeks ● Perl – 5 weeks ● Two exams (dates in the syllabus) Midterm 1: Python  Midterm 2: Python & Perl (mostly Perl) Regular weekly coding assignments  ● ● Final project (last 4 weeks)
  • 6. Python Text 2 Download free PDF version at http://greenteapress.com/thinkpython/thinkpython.html
  • 8. Logistics ● ● ● No emails on weekends please Both exams will be online; you can take them anywhere you want Please turn off your cell phones in class
  • 9. Class Attendance ● ● ● Class attendance is completely optional I know students who show up for every class and get C's and D's; I know students who show up for no class or just a few classes and ace all assignments, projects, and exams Do not waste your time showing up for class to do homework for other classes, read email, browse the web, chat with friends, play games, etc
  • 10. Python Overview History, Features, Strengths, Weaknesses
  • 11. History ● ● ● ● ● Python is a general purpose programming language Python is considered a scripting language but it is possible and practical to develop systems and executables Python was created by Guido van Rossum in the 1990's. Guido van Rossum is sometimes referred to as “Python's Benevolent Dictator for Life” (BDFL). The name “Python” comes from “Monty Python's Flying Circus.”
  • 12. Features ● ● ● ● ● Dynamic typing Automatic memory management (aka garbage collection) Support for large applications (system programming) Numerous built-in tools and libraries Numerous 3rd party tools and libraries
  • 13. Strengths ● Free ● Portable ● Easy to learn and use ● Mixable C/C++ programs can call Python programs  Python can link to C/C++ libraries Supports object-oriented programming  ●
  • 14. Weakness ● ● Python programs can run slower than their C/C++ counterparts If and when this happens, you have to ask yourselves two questions:   Do I really need this for my particular application? In many cases, no! Can I port the bottleneck to C/C++? In many cases, yes!
  • 15. Why not C++ for Everything? Scripting languages represent a different set of tradeoffs than system programming languages. They give up execution speed and strength of typing relative to system programming languages but provide significantly higher programmer productivity and software reuse. John K. Ousterhout, Creator of Tcl “Scripting: Higher Level Programming for the 21st Century” IEEE Computer magazine, March 1998 Full article: http://www.tcl.tk/doc/scripting.html
  • 16. Python 2.X or Python 3.X
  • 17. Python 2 or Python 3? ● ● ● ● Python 2.X is the status quo, Python 3.x is the shiny new thing Python 3.X is the newest branch of Python and the intended future of the language However, the broader Python 2.X ecosystem has amassed a significant amount of quality software over the years Insightful article on Python 2 vs. Python 3 on www.python.org
  • 18. Python 2 or Python 3? ● ● ● While Python 3.X is the same language, it is not backward compatible to Python 2.X The downside of breaking backwards compatibility in 3.X is that a lot of that software does not work on 3.X yet; this transition will take time Python 3.X has relatively limited library support; many Linux distributions and Macs ship with 2.X
  • 19. Reasons to Prefer Python 2 over Python 3 (For Now) 1. If you are deploying to an environment you do not control. 2. If you use a third party package that does not have a released Python 3 version. 3. If you want to use a third-party tool such as Python Image Library (PIL), Twisted (for networking), Django (for building websites), or py2exe (for packaging your application for Windows users)
  • 20. Reasons to Prefer Python 2 over Python 3 (For Now) 4. A lot of documentation (including examples) on the web and in reference books will be for Python 2 for the near future 5. Most of us are inclined to seek help online. The Python regulars are typically seasoned developers who rely on legacy software, most of which has not been ported to Python 3 yet. As a result, they might not be able to help you with Python issues 6. It is always better to study the tool you are transitioning to and wait until it becomes accepted by the broader community.
  • 22. What We Will Use ● ● ● We will use Python 2.7 in this class If you are a Linux user, note that many versions of Linux ship with 2.6.X If you are a Mac user, note that most Macs still ship with 2.6.X; check for the Mac distribution of 2.7
  • 23. Installing Python ● ● ● ● www.python.org is the site for everything that is Python. On Windows, I use IDLE for execution and debugging and IDLE or Emacs for editing On Linux (Ubuntu), I use command line interpreters for execution and debugging and Emacs for editing. You may want to play with several choices and choose what you like best. It does not really matter which IDE you use. You will submit only the Python source files (.py) in your assignments
  • 25. Python Interpreter ● ● ● Python Interpreter is an interactive program that allows you to work with Python source code without having to create, edit, save, and compile source files As you read online materials or test, I suggest that you keep the Python interpreter window running and try code snippets right away Most Python IDEs make the Python interpreter easily available
  • 26. Python Interpreter >>> print 'Hello, Python!' Hello, Python! >>> “Hello, Python!” Hello, Python! >>> 5 5 >>> 5 + 10 15
  • 27. Comments ● ● The hash mark character (#) introduces comments # can appear at the beginning of a line or in the middle of a line ● The characters after # and upto n are part of a comment ● Examples:   # This is a comment x + y # add x and y
  • 28. Variables ● ● ● ● Since Python is a dynamically typed language, the types of variables are not explicitly declared A variable can refer to an object of any legal Python type The type of a variable is determined at run time through the operations that are applied to the variable's value Examples:     >>> x = 1 # the value of x is integer 1 >>> x + 1 # is OK >>> x + 'bar' # is ERROR
  • 29. ● ● Python has two Boolean values: True and False Booleans All Python values can be represented as Booleans: all numbers except 0 are True; all non-empty containers are True; all empty containers are False; For example:  >>> file_ready = False  >>> bool(file_ready) False  >>> bool(1) True  >>> bool([])  False
  • 30. Factory Functions ● Numeric types have factory functions that convert from one type to another; For example:  >>> int('12') 12  >>> int(12.5) 12  >>> int('12.1') ERROR  >>> float('12.1') 12.1
  • 31. Lists, Strings, Tuples, Iterables ● Lists: [1, 2, 'a'] ● Strings: 'Python', “Python”, “Djangon” ● Tuples: ('a', 1), (1, 2) ● Lists are mutable (support assignment) ● Strings and tuples are immutable ● Iterables are any objects that can be iterated through one item at a time
  • 32. Reading & References ● ● ● www.python.org. Ch. 01, M. L. HetLand. Beginning Python From Novice to nd Professional, ,2 Ed., APRESS. H. Abelson and J. Sussman. Structure and Interpretation of Computer Programs, 2nd Ed., MIT Press.