+ All Categories
Home > Documents > Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning,...

Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning,...

Date post: 11-Jan-2016
Category:
Upload: aileen-lane
View: 219 times
Download: 0 times
Share this document with a friend
Popular Tags:
24
Programming 101 with Programming 101 with Python: an open-source, Python: an open-source, cross-platform, and fun cross-platform, and fun language language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved. If you use all or part of this work, please email or contact me with details.
Transcript
Page 1: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Programming 101 Programming 101 with Python: an open-with Python: an open-

source, cross-source, cross-platform, and fun platform, and fun

languagelanguage

By J. Burton Browning, Ed.D.Copyright © J. Burton Browning

All rights reserved. If you use all or part of this work, please email or contact me with details.

Page 2: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Today we will discuss:

• Overview of my book as course text and history of the language

• A few basic features with Python

• Advanced features of Python—not just an introductory language!

Page 3: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

History

• Developed by Guido van Rossum 1990• Actively maintained by him and others• New features and extensions added all the

time• Many books and websites with information• Name is based on Monty Python and not a

large snake!

Page 4: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Python features• Easy to learn• Great for RAD• Cross-platform and open-source• Compile to *.exe• GUI and other add-ins such as Pygame, Vpython, WX Windows,

etc.• Forces “clean” coding skills• Syntax similar to C/C++ and JAVA – can export to C• Free and commercial tools available• Used everywhere from application development and server

scripting to teaching

Page 5: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Course: Intro to Programming and Logic

• History of computers and programming• Prototype solutions (flowchart and pseudocode)• Program CLI applications• Basic control structures• Debugging• Advanced topics: GUI design, Add-in SDK’s,

COM integration, OOP, etc.

Page 6: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Two modes of operation

• Built-in IDE “IDLE”• “Line-by-line” or

interactive mode• “Multi-line” or script

mode – can save programs for reuse

• Helloi.avi

Page 7: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Variables and Math operators

• Variables are automatically “typed” to best fit. No variable declaration.

• Variables are immutable and not reused.

• Math operators similar to C++, JAVA, VB, etc. * = multiplication, + = addition, % modulus, etc.

Page 8: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Comment statements

• Pound sign ( # ) is used for single line comments.

• Multi-line comments are wrapped in triple quoted strings.

“”” any commentshere…“””

Page 9: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Examples

Page 10: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Single selection structure and Statement blocks

• Handled by indentation

• Forces “clean” code writing

• Format specifiers similar to C++/JAVA

Page 11: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Dual selection structure

• Similar to other languages

• Indentation defines statement blocks

Page 12: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Multiple selection structureSimilar to if, else if, else (could be switch or

select case in other languages).

elif is same as else if

Page 13: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

While

• Similar to loop in other languages

Page 14: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Forfor x in range(10):

print x

name=“Smith”

for letter in name:

print letter

Page 15: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Functions

• def function_name():

any code for function…

Page 16: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Arrays

• Very rich collection of “array-like” structures

• Lists, tuples, and dictionaries

• More powerful than a standard array

• Teach same principles

• Easy to learn and implement

Page 17: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Dictionary example

Page 18: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Class design

• Can declare classes in same file or separate file.• Can focus on class design without other syntax

issues associated with other languages.• Put fun into class design!

Page 19: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Class example

Page 20: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

GUI programming• Free SDK pythoncard.sourceforge.net• Similar to VB/VB.NET• Cross-platform unlike Visual Basic!• No special “dot net” framework needed!• Other GUI SDK’s available as well

Page 21: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Pygame• Free sdk from www.pygame.org for

game/simulation development.

• Many good/free tutorials available.

• Open-source games you can modify.

Page 22: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

3D Graphics/animation• Vpython.org free

3d/animation sdk.

• Use for general

graphics study or

physics classes.

Page 23: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

More information

• www.python.org• www.vpython.org• www.pygame.org• http://pythoncard.sourceforge.net/• http://www.activestate.com/products/komodo_ide/

Page 24: Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.

Questions?Questions?

Thank you and good luck!

Text:Design, Logic, and Programming with

Python by James B. Browning

www.iuniverse.comwww.amazon.comBarnes and Noble


Recommended