Learning Python
-
Upload
mindy-mcadams -
Category
Technology
-
view
1.888 -
download
2
description
Transcript of Learning Python
![Page 1: Learning Python](https://reader034.fdocuments.net/reader034/viewer/2022052522/5549b944b4c905bc6d8b4d97/html5/thumbnails/1.jpg)
L E A R N I N G T O P R O G RA M
PYTHON
![Page 2: Learning Python](https://reader034.fdocuments.net/reader034/viewer/2022052522/5549b944b4c905bc6d8b4d97/html5/thumbnails/2.jpg)
WHY LEARN TO PROGRAM?
• An important skill in making things for online
media: problem solving
• Process of learning to program: Practice and
improve your problem-solving skills
• Thinking in a structured way
• Learning how to find answers by a combination
of online searching and trial-and-error
![Page 3: Learning Python](https://reader034.fdocuments.net/reader034/viewer/2022052522/5549b944b4c905bc6d8b4d97/html5/thumbnails/3.jpg)
WHY PYTHON?
Python is one
of the most-
used
programming
languages
today.Source:
https://github.com/mjwillson/ProgLangVisualise
![Page 4: Learning Python](https://reader034.fdocuments.net/reader034/viewer/2022052522/5549b944b4c905bc6d8b4d97/html5/thumbnails/4.jpg)
WHY NOT JAVASCRIPT?
• JavaScript is a must for Web development today.
• If you already knew how to program, you could jump
straight into JavaScript and not learn Python.
• As a first programming language, Python is easier to
learn than JavaScript.
• The techniques you learn as you learn Python will
help you understand JavaScript more quickly.
http://www.quora.com/Is-it-better-to-learn-Python-or-J
avaScript-as-a-first-
language
![Page 5: Learning Python](https://reader034.fdocuments.net/reader034/viewer/2022052522/5549b944b4c905bc6d8b4d97/html5/thumbnails/5.jpg)
USING PYTHON
• There are two ways to use Python:
• Interactive mode
• Script mode
• In interactive mode, you type Python programs
and the Python interpreter displays the result
immediately …
Source: Think Python, by Allen B. Downey (O’Reilly Media: 2012), pages 2–3
![Page 6: Learning Python](https://reader034.fdocuments.net/reader034/viewer/2022052522/5549b944b4c905bc6d8b4d97/html5/thumbnails/6.jpg)
I N T E RAC T I V E M O D E
PYTHON
![Page 7: Learning Python](https://reader034.fdocuments.net/reader034/viewer/2022052522/5549b944b4c905bc6d8b4d97/html5/thumbnails/7.jpg)
USING PYTHON
• There are two ways to use Python:
• Interactive mode
• Script mode
• In script mode, you write code in a text file, save
it, and then use the interpreter to execute (or run)
the contents of the file (which is called a script)
• Python scripts have filenames that end with .py
Source: Think Python, by Allen B. Downey (O’Reilly Media: 2012), pages 2–3
![Page 8: Learning Python](https://reader034.fdocuments.net/reader034/viewer/2022052522/5549b944b4c905bc6d8b4d97/html5/thumbnails/8.jpg)
T H I S I S A S C R I P T , S H O W N I N A T E XT E D I T O R
PYTHON
![Page 9: Learning Python](https://reader034.fdocuments.net/reader034/viewer/2022052522/5549b944b4c905bc6d8b4d97/html5/thumbnails/9.jpg)
When you run a Python script (left) in the Python interpreter, the output (but not the stored script) is displayed onscreen (right).
![Page 10: Learning Python](https://reader034.fdocuments.net/reader034/viewer/2022052522/5549b944b4c905bc6d8b4d97/html5/thumbnails/10.jpg)
WHAT A PROGRAM DOES
• Input: Get data from the keyboard, a file, or some other device
• Output: Display data on the screen, or send data to a file or
other device
• Math: Perform basic mathematical operations like addition and
multiplication
• Conditional execution: Check for certain conditions and
execute the appropriate code
• Repetition: Perform some action repeatedly, usually with some
variation
Source: Think Python, by Allen B. Downey (O’Reilly Media: 2012), page 3
![Page 11: Learning Python](https://reader034.fdocuments.net/reader034/viewer/2022052522/5549b944b4c905bc6d8b4d97/html5/thumbnails/11.jpg)
WHAT A PROGRAM DOES (2)
• Input: (1) run a script; (2) raw_input
• Output: (1) print; (2) create and write to text
files
• Math: +, –, /, *, %, >, <, >=, <=, ==
• Conditional execution: if, elif, else
• Repetition: for, whileYou will learn how to do each of these, which is pretty much all there is to programming. (I’m lying a little bit.)
![Page 12: Learning Python](https://reader034.fdocuments.net/reader034/viewer/2022052522/5549b944b4c905bc6d8b4d97/html5/thumbnails/12.jpg)
“Every program you’ve ever used, no
matter how complicated, is made up of
instructions that look pretty much like
these. So you can think of programming
as the process of breaking a large,
complex task into smaller and smaller
subtasks until the subtasks are simple
enough to be performed with one of
these basic instructions.”
Source: Think Python, by Allen B. Downey (O’Reilly Media: 2012), page 4
![Page 13: Learning Python](https://reader034.fdocuments.net/reader034/viewer/2022052522/5549b944b4c905bc6d8b4d97/html5/thumbnails/13.jpg)
DEBUGGING
Errors are bugs. Finding and fixing them is
debugging.
• Syntax errors: Structure and rules, such as:
“Parentheses come in pairs”
• Runtime errors: Appear while the program is
running (these are called exceptions)
• Semantic errors: Your script runs but does not do
what you wanted it to doSource: Think Python, by Allen B. Downey (O’Reilly Media: 2012), pages 4–5
![Page 14: Learning Python](https://reader034.fdocuments.net/reader034/viewer/2022052522/5549b944b4c905bc6d8b4d97/html5/thumbnails/14.jpg)
In the practice of programming—of
writing programs—a lot of the work is in
the debugging.
Each error becomes a puzzle to be
solved.
“Why doesn’t it work the way I want it to
work?”
The process of learning to program is a
process of problem-solving.
![Page 15: Learning Python](https://reader034.fdocuments.net/reader034/viewer/2022052522/5549b944b4c905bc6d8b4d97/html5/thumbnails/15.jpg)
• Think Python, by Allen B. Downey
http://www.greenteapress.com/thinkpython/
• Learn Python the Hard Way, by Zed A. Shaw
http://learnpythonthehardway.org/
• Codecademy: Python
http://www.codecademy.com/tracks/python
RESOURCES
![Page 16: Learning Python](https://reader034.fdocuments.net/reader034/viewer/2022052522/5549b944b4c905bc6d8b4d97/html5/thumbnails/16.jpg)
L E A R N I N G T O P R O G RA M
PYTHON
Presentation by Mindy McAdams, University of Florida[ 2012 ]