Lecture 1 — Introduction¶
People¶
- Professor Sibel Adali
- TAs
- Programming mentors
Learning Outcomes¶
- Demonstrate proficiency in the purpose and behavior of basic programming constructs.
- Design algorithms and programs to solve small-scale computational programs.
- Write, test and debug small-scale programs
- Demonstrate an understanding of the wide-spread application of computational thinking to real-world problems.
Textbook¶
- Practical Programming: An Introduction to Computer Science Using
Python by Campbell, Gries, Montojo and Wilson
- Available in e-book form
- We also like Think Python available on-line at http://www.greenteapress.com/thinkpython/.
Website and On-Line Resources¶
This site for course notes
Course website
You need to sign up with your rpi.edu account. We will use this site extensively.
Another server for submitting homeworks and recording of grades. Still being set up.
We will also record lectures and post on Youtube starting with next lecture.
Other items from the syllabus¶
- Prof. Adali’s office hours; others will be posted on-line
- Lab sections are held Tuesdays and Wednesdays
- Lab assignments to be adjusted this week. Please fill out the following survey.
- Requirements and grading: labs, homeworks, tests; letter grades
- Appealing grades
- Class attendance and participation; lecture notes
- Homework late policy: 3 LATE DAYS FOR THE WHOLE SEMESTER
- Academic integriy
- Other exceptions: report to me right now or as soon as you know
- Notes on schedule:
- Labs start this week!
- No labs during the weeks of October 13-17 (monday schedule on tuesday), and November 24-28 (Thanksgiving).
- Test dates are September 28, October 26, and November 23.
- Final exam on finals week. Do not buy your ticket.
The Magic of Programming¶
- Cold, harsh logic, and
- Seemingly primitive syntax...
- Leading to soaring creativity!
Types of Problems We Will Study¶
- Tools used to help you win at Words with Friends
- Image processing and manipulation
- Web searching and crawling
- Programs that work with data from Twitter and Flicker
- Numerical examples, including games and physical simulations
Jumping In Quickly with Our First Program — Hello World¶
We create a text file called
hello.py
containing just the two lines of Python code:print 'Hello, World!' print 'This is Python'
This is done by launching the Wing IDE, which is specific to creating and running Python programs
- IDE stands for ’Integrated Development Environment’
- Two windows will appear — the top being the editor and the bottom being the Python interpreter
Load the
hello.py
programRun it using the interpreter
We can also type Python code directly into the interpreter.
For this class only, we can try this using a browser based Python interpreter:
Something a Bit More Interesting¶
We are going to emphasize computational thinking throughout the semester, so let’s look at a fun little problem and get started.
This problem is posed in Think Python and taken from the NPR show Car Talk. If you know the answer, do NOT say it!
Find the one word in the English language that contains three consecutive double letters.
We will talk through the steps needed to develop and test a Python program to solve this problem.
- The file containing this program will be posted on the course website after class.
We do not intend that you will understand the details of the program at this time. Rather, this is just a fun exercise that illustrates the steps of solving a fun problem computationally.
On the other hand, it does introduce some elements that will be seeing repeatedly throughout the semester:
- Files
- Functions
- Loops
- Logic
- Counting
- Output
- Libraries
In about six weeks, you will understand all parts of this program!
You can see the code in
three_doubles
Looking Back: What Steps Did We Follow?¶
- Developing an understanding of what the problem is really asking. This usually involves playing around with small examples.
- Developing and describing a recipe (an “algorithm”) for solving the
problem
- Most recipes will involve multiple parts — multiple functional steps
- Turning this recipe in a program in the formal language of Python,
one of many different programming languages.
- English is too imprecise for specification of programs.
- Running this program using the Python interpreter.
Programs, Compilers, Interpreters, Abstractions¶
- Python is an interpreted language — run immediately and interactively by the Python interpreter, which is itself another (very complex) program
- Programs in some other (non-interpreted) languages like C, C++ and Java must be compiled (by a “compiler” — another program) into a new program in machine assembly language and then executed.
- In both cases, we write programs that require other programs to run.
- And, we don’t just need just the compiler or interpreter — we need the file system, the operating system, and the command-line interpreter, each of them complicated, multi-part programs themselves.
- We don’t really think about the details of these programs; we just
think of what they do for us.
- This is called an “abstraction”.
- It allows us to think about a problem we are trying to solve without thinking about all the details of all the other systems we are depending on.
- Thinking in terms of abstractions is fundamental to computer science.
Why Python¶
- Python has a very simple syntax
- The roles of indentation and blank lines cause the most confusion.
- Intepreted languages provide immediate, useful feedback
- Python has a powerful set of tools — abstractions
- Python is widely used in science, engineering and industry.
- Python is good for rapid prototyping
- Sometimes, after a Python program is written and working, the most time-consuming steps are rewritten in C or C++ and integrated with the Python code.
Two Types of Errors in Our Python Programs¶
- A syntax error is a mistake in the form of the Python code that will not allow it to run.
- A semantic error is a mistake in the “meaning” of the program, causing it to produce incorrect output, even if it runs.
- We will demonstrate both types of errors by deliberately introducing errors in our triple double example program.
Python Versions¶
- Python, like all programming languages, is continually under development.
- While the most recent version is 3.3, it has not been fully adopted, so we will use 2.7 (2.7.5 is the latest), pointing out differences with 3.3 on occasion.
Lab 1 — Tuesday and Wednesday!¶
By the end of Lab 1, each student will
Sign up at the course Pizza web site
Go to the course page
and follow the instructions to install the Python environment on their computer.
- There are installers for “native” versions of the environment for Windows, Mac OS X and Linux machines. This is the recommended route.
- There is also a Linux virtual machine that can be installed in any environment.
Create a Dropbox account to store back-up copies “in the cloud” of homework and lab solutions and lab for the course.
- Other cloud-based back-up copies are acceptable.
Students are strongly encouraged to get started before lab, especially downloading the environment.