The Scala Experience Safe Programming Can be Fun!
Download
Report
Transcript The Scala Experience Safe Programming Can be Fun!
Computing for
Engineers in
Python
Autumn 2011-12
1
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
Course Objectives
Develop basic computing skills
(programming, algorithms, applications)
3
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!
4
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…
5
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
6
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
7
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
8
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…
9
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
10
Working Environment
• Lab 008
• Home versus labs
VS.
11
Syllabus
Tentative, 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
12
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)
13
Questions?
14
Preface
• We assume no prior knowledge in
programming
• However, we advance fast
• The only way to keep on track is to practice,
a lot!
15
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)
16
Today
• Basic terms
• Python basics: learn by examples
•
•
•
•
•
•
Variables
Lists
Strings
Functions
Branching (if)
Loops
17
Computer
מכונה המעבדת נתונים על פי רצף פקודות נתון
מראש
מחשב = חומרה +תכנה
אמצעי
פלט
מעבד
(מדפסת ,מסך,
דיסק קשיח)
(עכבר ,מקלדת,
דיסק קשיח)
זכרון
18
אמצעי
קלט
Algorithm
סדרת פעולות סופית לביצוע משימה מסויימת
Input
Output
Algorithm
19
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
20
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
21
There are Many Programming
Languages
Over 500 different computer languages
are listed by Wikipedia
22
Language Selection
• Goal
• Runtime vs. Development time
• Operating systems
• Platforms
23
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
24
Last Note Before Starting We Start
“Stolen” from Benny Chor’s slides
25
Hello World!
26
Hands On
27
Functions
Spaces / indentation!!
What are functions good for?
28
Passing Arguments to Functions
29
If/Else
30
Formal Definition
31
Logical Operators
32
Python is Lazy…
33
Handling Mistakes
• Understanding interpreter’s messages (see
previous examples)
• It will take you some time to gain
experience…
34
String Type
http://docs.python.org/tutorial/introduction.html#strings
35
Strings Structure
36
Strings Built In Methods
http://docs.python.org/release/2.5.2/lib/string-methods.html
37
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
38
Lecture 1: Highlights
• Basic terms
• Functions
• Control structures (if/else)
• Strings
39