computing for engineers in python

39
1 Computing for Engineers in Python Autumn 2011- 12

Upload: emmet

Post on 11-Jan-2016

67 views

Category:

Documents


0 download

DESCRIPTION

Computing for Engineers in Python. Autumn 2011-12. Welcome!. You are about to take a new programming course in Python This is the first run ever of this course The idea is to enable you to use programming as a tool to solve “real world” problems Hard work is required!. 2. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Computing for Engineers in Python

1

Computing for Engineers in

Python

Autumn 2011-12

Page 2: Computing for Engineers in Python

2

Welcome!

• You are about to take a new programming course in Python

• This is the first run ever of this course

• The idea is to enable you to use programming as a tool to solve “real world” problems

• Hard work is required!

Page 3: Computing for Engineers in Python

3

Course Objectives

Develop basic computing skills (programming, algorithms, applications)

Page 4: Computing for Engineers in Python

4

Administration• Instructor: Assaf Zaritksy

• assafzar AT tau.post.ac.il• Office hours: by e-appointement (also TAs)• Shenkar building 405a

• Teaching Assistants: Noga Levy, Yoav Ram• Web via Moodle: http://moodle.tau.ac.il/

• Everything is there!• Course material (lectures, practical sessions, hw, code

examples from the site: http://www.cs.tau.ac.il/courses/pyProg/1112a/), forum, homework submission and grading

• Your responsibility to be updated!

Page 5: Computing for Engineers in Python

5

Practical Sessions

• In a standard classroom

• Purposes:• Practice topics that were presented in class• “Preparations” for next week’s class• Background for homework assignments• Learn practical tools

• Lectures will be harder to understand, and it is ok…

Page 6: Computing for Engineers in Python

6

Homework 1

• N = 11-13 assignments

• Some assignments will contain a set of short technical tasks, the rest will be “interesting”

• Each assignment is worth 1-3 points of the final grade for a total of 15-20 points

• Each assignment is graded to one of four grades (0,60,80,100), no bargaining!

• In order to pass the course you must pass the final exam and at least N-2 assignments

Page 7: Computing for Engineers in Python

7

Homework 2• Submission in singles via Moodle

• It is allowed (and encouraged) to talk, share ideas, and help friends. No code-sharing!

• TAs will answer hw-related questions in the forum (make sure no one have asked the same question before)• Staff emails are to be used only for personal matters• No code in the forum! Do not send code to the staff! • We try to answers emails within 48 hours

Page 8: Computing for Engineers in Python

8

Homework 3

• Each student has 5 grace days for late submission throughout this course

• If you submit late for a valid reason, attach a “late submission” note with your submission – no need to mail anyone!

• Approach the grader directly with homework submission/grading problems [email protected]

• Miluim, long illness periods – you decide whether to get a PTOR or submit late

Page 9: Computing for Engineers in Python

9

A Personal Note on HW

• It will take you a lot of time and frustration

• It is an engineering difficulty: figuring out what's wrong with a system and how to fix it

• You're engineers: make it work!

• There is no other way to learn how to program

• Believe me…

Page 10: Computing for Engineers in Python

10

Exam

• Exam on 27.2 (Moed B on 4.4)

• Final grade is composed out of homework and final exam

• You must pass the exam to pass the course

• Written exam

• No references

• Includes all course material: class, practical sessions and hw

Page 11: Computing for Engineers in Python

11

Working Environment

• Lab 008

• Home versus labs

VS.

Page 12: Computing for Engineers in Python

12

SyllabusTentative, not in order, probably too ambitious

• Python programming basics• Using packages• Recursion• Sort & search algorithms,

runtime analysis• Dynamic programming• Error handling• Input/output• Graphical user interface (GUI)

• Simulation• Optimization• Data analysis• Control• Signal processing

Page 13: Computing for Engineers in Python

13

Resources

• Course slides and pointers to relevant bibliography• Many Python references, but many of them are in fact

manuals for the language• Recommended book and manual:

• Think Python, by Allen B. Downey, which is available online (basic)

• Python 2.7 documentation, http://docs.python.org/, is the official language manual, and a very useful resource

• Dive Into Python by Mark Pilgrim, available online (more advanced)

Page 14: Computing for Engineers in Python

14

Questions?

Page 15: Computing for Engineers in Python

15

Preface

• We assume no prior knowledge in programming

• However, we advance fast

• The only way to keep on track is to practice, a lot!

Page 16: Computing for Engineers in Python

16

Plan for Upcoming Weeks

• Week 1: quick overview of Python, in a more “organized” manner in tirgul

• Week 2: more basics (class + tirgul)

• Week 3: simulation (class), more basics (tirgul)

Page 17: Computing for Engineers in Python

17

Today

• Basic terms

• Python basics: learn by examples• Variables• Lists• Strings• Functions• Branching (if)• Loops

Page 18: Computing for Engineers in Python

18

Computer

מכונה המעבדת נתונים על פי רצף פקודות נתון מראש

מחשב = חומרה + תכנה

מעבד אמצעי פלט

אמצעי קלט

זכרון

)עכבר, מקלדת, דיסק קשיח(

)מדפסת, מסך, דיסק קשיח(

Page 19: Computing for Engineers in Python

19

Algorithm

סדרת פעולות סופית לביצוע משימה מסויימת

Algorithm

Input Output

Page 20: Computing for Engineers in Python

20

Machine Code (Language)

• Computers understand only machine language• Basically looks like a sequence of 1’s and 0’s• Very inconvenient to work with and non intuitive

• All other computer languages were created for human convenience• The computer does not understand C/C#/Java/Scala• Must be “translated” into machine language

Page 21: Computing for Engineers in Python

21

Programming Languages Basics

• A computer program is a sequence of instructions (texts) that can be “understood" by a computer and executed by it

• A programming language is a machine-readable artificial language designed to express computations that can be performed by a computer

Page 22: Computing for Engineers in Python

22

There are Many Programming Languages

Over 500 different computer languages are listed by Wikipedia

Page 23: Computing for Engineers in Python

23

Language Selection

• Goal• Runtime vs. Development time• Operating systems• Platforms

Page 24: Computing for Engineers in Python

24

Python• Python is a general-purpose, high-level

programming language • Conceived in the late 1980’s by Guido van

Rossum at CWI in the Netherlands• Numerous users in many domains• Used as a first programming language in many

universities (MIT, TAU CS)• the origin of the name is based on the television

series Monty Python's Flying Circus

Page 25: Computing for Engineers in Python

25

Last Note Before Starting We Start

“Stolen” from Benny Chor’s slides

Page 26: Computing for Engineers in Python

26

Hello World!

Page 27: Computing for Engineers in Python

27

Hands On

Page 28: Computing for Engineers in Python

28

Functions

Spaces / indentation!!

What are functions good for?

Page 29: Computing for Engineers in Python

29

Passing Arguments to Functions

Page 30: Computing for Engineers in Python

30

If/Else

Page 31: Computing for Engineers in Python

31

Formal Definition

Page 32: Computing for Engineers in Python

32

Logical Operators

Page 33: Computing for Engineers in Python

33

Python is Lazy…

Page 34: Computing for Engineers in Python

34

Handling Mistakes

• Understanding interpreter’s messages (see previous examples)

• It will take you some time to gain experience…

Page 35: Computing for Engineers in Python

35

String Type

http://docs.python.org/tutorial/introduction.html#strings

Page 36: Computing for Engineers in Python

36

Strings Structure

Page 37: Computing for Engineers in Python

37

Strings Built In Methodshttp://docs.python.org/release/2.5.2/lib/string-methods.html

Page 38: Computing for Engineers in Python

38

How Would I Know?

• Built-in help (not very clear at all times)• Python documentation http://docs.python.org/• Your favorite search engine• The course’s forum

Page 39: Computing for Engineers in Python

39

Lecture 1: Highlights

• Basic terms

• Functions

• Control structures (if/else)

• Strings