1 / 10

Python – May 11

Python – May 11. Briefing Course overview Introduction to the language Lab. Python. Why computer programming? Computer is a general-purpose machine, born to be programmed We want to solve many types of problems Our goals Become multi-lingual Practice with design & implementation

Télécharger la présentation

Python – May 11

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Python – May 11 • Briefing • Course overview • Introduction to the language • Lab

  2. Python • Why computer programming? • Computer is a general-purpose machine, born to be programmed • We want to solve many types of problems • Our goals • Become multi-lingual • Practice with design & implementation • Learn by doing: start simple • Help available • Textbook, python.org, tutorials

  3. Background • First released, 1991 • Guido van Rossum, CWI, Netherlands • Dissatisfaction with existing languages • High-level, multi-purpose language • Relatively easy to learn & use (we hope!) • Procedural, object oriented or functional • Interpreted • Interface to OS, file system, Web • Some data structures built into language • Standard library • (More details in sections 1.3 and 1.5)

  4. Initial To-Do Essential skills; special features of language • Routine stuff • Source file name ends in .py • How to run interpreter (command line or IDE) • Program structure • I/O • Interactive, file; formatting • Variables, identifiers • Doing math • Comments, tokens, whitespace, style conventions

  5. continued • Control structures • Asking questions, repeating stuff • nesting • How to make comparisons • Boolean operations: and/or/not • Functions/procedures: parameters, returns • Data structures • String, dynamically-sized list, etc. • Standard (i.e. run-time) library • Random numbers, etc.

  6. In the end… • How can you tell if you’ve mastered a language? • Write a game • Given a spec or algorithm, can you implement it? • You may prefer to do something in Python! • You never need to know everything. Know where to find stuff quickly • This course lies between first 2 prog. courses • You’ll see more operations & applications than in the 1st course. Not as theoretical as 2nd course.

  7. Beginning • Versions 2.x and 3.x • Lab: let’s use IDE such as ActivePython • Free, simple, includes debugger  • Code can by entered: • directly in shell (good for experimenting!) • in a file, which we can save and reuse later

  8. Initial nuts & bolts • Comments begin with #, go to end of line • Statements don’t end in semicolon • Don’t arbitrarily indent code • Put \ at end of line to continue statement • Variables are not declared • Interactive output • Version 2.6: print statement print name • Version 3.0: print function print (name)

  9. continued • Examples print “Hello, world” print 7+4*3 • Interactive input • input( ) for getting a number • raw_input( ) for getting a string name = raw_input(“What is your name”)

  10. What’s next? • Lab • Please read chapter 2 • Practice with • Basic I/O • Mathematical operations • Strings • Simple if statement • Simple loop

More Related