But, it will be important to do similar readings from the Gaddis book since it
provides more explanations about ... python-second-edition/tony-gaddis/dp/.
•
Course Description • What material will we cover? • What am I getting myself into?
•
Administrative Issues • Course Web Page, Text Book, Exams, Office Hours, Homework, Grading, Cheating Policy, etc.
• •
Syllabus Intro. to Programming Languages and Python
2
•
Prerequisites: • This course in intended for students who have no previous experience in programming • (No prior programming experience required (Really) • The focus of the course is to provide you with an elementary introduction to programming in Python. • It’s open to all students who are interested in programming from any field or background (such as Film, journalism, economics, education, math, biology and so on.)
•
Who should be taking this course: • Students who are interested in programming • Students who want to take a computer science minors or Web Applications and Programming minor (http://cs.nyu.edu/web/Academic/Undergrad/minors.html) • Students who want to switch to a computer science major • You must get a c or better in this class to take further computer science classes. Who should NOT be taking this course • Students trying to get out of taking a math requirement. This class may be more difficult than the math you are trying to avoid.
•
3
•
In this course, we will study the fundamentals of computer programming ... one of the towering intellectual achievements of the 20th century. We will design, code, and debug programs using Python as we explore these concepts.
•
Python is a popular programming language, widely used in business, entertainments, science, arts, games, mobile apps.
•
Famous companies that use Python are Google, Pixar, Disney, NASA, and Yahoo!
4
5
•
•
The purpose of this course is to teach you about computing, but particularly, programming in Python (a powerful, widely-used programming language). Why care about computers and programming? • • • • •
Growing field with great opportunity (read: $) Creative Challenging Fun (Developing Games for example) Enabling/Empowering, creative and innovative technology
6
Course Objectives: 1. We will learn to program in Python. • This includes all the rules (SYNTAX) that are specific to Python. 2. We will cover the fundamentals of programming (shared concepts in all high level programming languages): • Variables and data types • Control Structure • Repetition: loops • Functions, Modules and Methods • Data Structure: List and Dictionaries • Input and output (Reading and writing to files)
7
Book Chapters to be covered in this class: Most readings will be assigned from the Visual Quick start book since it is using the current python version 3. But, it will be important to do similar readings from the Gaddis book since it provides more explanations about programming concepts covered in this class.
• Chapter 1 Introduction to Computers and Programming • Chapters 2 Arithmetic, variables and data types (Strings) • Chapters 3 Writing Programs • Chapter 4 Control Structure and Repetition • Chapter 5 Functions • Chapter 6: Strings • Chapter 7: Data Structures (lists, Dictionaries) • Chapter 8:Input and output (File I/O) Additional topics, depending on time
8
•
There are many programming languages available: • C++, C, Python, Ada, Perl, Ruby, Python.
• •
•
•
All of these languages share core concepts. By focusing on these concepts, you are better able to learn any programming language. Note: Python is an object oriented programming language. However, we will not touch upon the concepts which categorize it as one. Python is easy to learn and also easy to develop programs with graphics, sound capabilities for games, animation for Arts and sciences and output programs for the web (CGI). 9
// Hello Program in Python public class welcome1 { public static void main( String args[] ) { System.out.println(“Hello students and welcome to programming " ); } // end method main } // end class Welcome1
# Hello program in Python
print (“Hello students and welcome to programming ”)
10
has a construct called a while loop that enables a program to repeat actions over and over. • Most other languages also have a for loop. • Hence, by learning about for loops in Python, you can easily learn while loops in C, C++, Python, PythonScript, Perl. • Python
11
# Sample Program in Python Guess the secret word """ This program will ask the user to guess the secret word repeat until the user gets the correct answer """ repeat= True secret= "Python" tries = 3 while repeat: guess = input("Guess the secret word to win $100: Please enter your guess here : ") tries = tries - 1 if guess == secret: print () print ("Congratulations! You won $100!") repeat = False
This program will try to guess the secret word in 3 tries to win $100. In a few weeks, it will all make sense (I promise!)
else: print ("Wrong guess!") if tries == 0: print () print ("Game is over. You only have three tries") repeat = False else: print () print ("Keep trying: You have %d tries remaining" % tries)
12
13
Course web site is available at: http://cs.nyu.edu/~odeh/python0002fall13/index.html •
Web site contains the following information: • • • • • • • •
Administrative information Course Syllabus Homework assignments Class notes Class programs Sample exams Software instructions Tutoring information 14
Required BOOK: 1) Python: Visual QuickStart Guide, 2nd Edition By Toby Donaldson Copyright 2009 o ISBN-10: 0-321-58544-5 o ISBN-13: 978-0-321-58544-8
2) How to Think Like a Computer Scientist Learning with Python 2nd Edition -- free • by Jeffrey Elkner, Allen B. Downey, and Chris Meyers • Chapters and examples are posted online: • http://openbookproject.net/thinkcs/python/ english2e/index.html
15
Required BOOK: 3) Starting Out with Python - Second Edition by Tony Gaddis http://www.pearsonhighered.com/product? ISBN=0132576376 This book is also available as an e-book on CourseSmart: http://www.coursesmart.com/starting-out-withpython-second-edition/tony-gaddis/dp/ 9780132656191 eText: ISBN-10 0-13-265619-1, ISBN-13 978-0-13-265619-1 Print: ISBN-10 0-13-257637-6, ISBN-13 978-0-13-257637-6
16
For the course, we will be using Python and Idle
•
•
• •
•
I will also be recommending more software to use such as Text Wrangler and NotePad ++
•
We will discuss installation and how to use software in class
These programs are free and you can download and use them for your home computer.
Install the latest version of Python (we will go over this during our next class) (Instructions will posted on the course website)
17
•
Your grade will be determined as follows: • Grades are weighted as follows: • Midterm #1 - 20% of the final grade • Midterm #2 - 20 % of the final grade • Homework - 20% of the final grade • Final Exam - 40% of the final grade • Class participation will help your grade!
18
• Ten points will be deducted for each class day late, with a possible maximum of 30 points being deducted. • Home works will not be accepted after the third class following its due date. • For each assignment that you do not hand in within the time limit, your final grade will be lowered by one letter grade ( i.e., if you are averaging a B+, but you have missed 2 home works, your final grade will be B-). • Students who spend little time on the homework invariably do poorly on exams and end up with a poor final grade.
• Very Important • For your own good you must save all programs on back-up (USB or flash drives). Make and keep copies of all your programs at all times. • Lost programs or crashed systems do not provide adequate excuses for missing or late homework.
19
For the purposes of this class, cheating is defined as: • Discussing homework concepts is fine, but you must submit your own work. • Copying all or part of another student's homework, project or exam. • Allowing another student to copy all or part of your homework, project, or exam. • Please note that If you are caught cheating, you will receive an immediate FAILURE for the course. • Copying ideas, text or a line of code (segment) from an outside resources is NOT allowed “without prior attribution”: • Make sure to read the CS department statements on Academic Integrity for more details.
If you are caught cheating, you will receive an immediate FAILURE for the course. 20
•
In an effort to make this class enjoyable for everybody… • Please be on time to class! • Please do not talk to your friends and neighbors in class! It disturbs everyone, and makes it hard to concentrate. If you have a question, just ask me! • Don’t be distracted by passing notes to your neighbors during class. • Don’t use laptops to read emails and browse the web during class • Please turn your pagers and cell-phones off! • If you are sick and can’t make it to class, make sure to check the website for class work and also and try to get notes from your classmate • Class buddy: Let’s do this now: Please turn to your neighbor and get her/his contact info so you can contact when you need to get notes or other class related info
21
* Help: Whenever you have a question about the course material, please feel free to drop by during my office hours or write me an email message. If at any time you feel that you are falling behind or are overwhelmed by the material, let me know: I will be very happy to help you. •
Option 1: Come to my Office Hours
• Office Hours: Mondays: 12:30 pm – 1:30 pm in room 321 in WWH, or at other times by appointment • Location: Room 321 Warren Weaver Hall • I get bored when nobody visits! • If you cannot make my office hours, I will be happy to make an appointment with you. Please try to give me advance warning when you need an appointment.
22
•
Help is always available!
•
Option 2: See tutors. • Two lab tutors will devote 10 hours each week to be help you with your homework.
•
Option 3: Email the class e-tutor, should respond within 24 hours. • For more information on tutoring, please go to the “Tutoring/Help” page on the course website:
23
•
Computer • Performs computations and makes logical decisions • Millions / billions times faster than human beings
•
Computer programs / software • Sets of instructions that tells the computer what to do
•
Hardware • Physical devices of computer system
24
•
Six logical units of computer system • Input unit • Mouse, keyboard • Output unit • Printer, monitor, audio speakers • Memory unit • Retains input and processed information • Arithmetic and logic unit (ALU) • Performs calculations • Central processing unit (CPU) • Supervises operation of other devices • Secondary storage unit • Hard drives, floppy drives 25
•
Batch processing • One job (task) at a time • Operating systems developed • Programs to make computers more convenient to use • Switch jobs easier
•
Multiprogramming • “Simultaneous” jobs • Timesharing operating systems
26
•
Personal computers • Economical enough for individual • Popularized by Steve Jobs and Steve Wozniak with the introduction of the Apple in 1977. • In 1981 IBM introduced the IBM personal computer using “off the shelf” components.
27
•
Three types of programming languages • Machine languages • Strings of numbers giving machine specific instructions • Example: +1300042774 (these would really be in binary) +1400593419 +1200274027 • Assembly languages • English-like abbreviations representing elementary computer operations (translated via assemblers) • Example: LOAD BASEPAY ADD OVERPAY STORE GROSSPAY 28
• High-level languages • Instructions closer to everyday English • English is a natural language. Although high level programming languages are closer to natural languages, it is difficult to get too close due to the ambiguities in natural languages (a statement in English can mean different things to different people – obviously that is unacceptable for computer programming). However, this is a big research area of computer science. • Use mathematical notations (translated via compilers) • Example: grossPay = basePay + overTimePay • Interpreter – Executes high level language programs without compilation.
29
•
Other high-level languages • FORTRAN • Used for scientific and engineering applications • COBOL • Used to manipulate large amounts of data • Pascal • Intended for academic use
30
•
Objects • Reusable software components that model items in the real world • Meaningful software units • Date objects, time objects, paycheck objects, invoice objects, audio objects, video objects, file objects, record objects, etc. • Any noun can be represented as an object • Very reusable • More understandable, better organized, and easier to maintain than procedural programming • Favor modularity
31
Characteristics of Python Python
is simple
Python
is object-oriented
Python
is interpreted
Python
is robust
Python
is architecture-neutral
Python
is portable
Python
is multithreaded
Can
be applied in all fields (arts and sciences)
Python
was created by Guido Van Rossum in the 1990’s he named it after Monty Python's Flying Circus comedy program.
32
1.
Edit •
Programmer writes program (called source code) and stores program on disk (.py file)
2. Run/Execute • Interpreter translates your source code into bytecodes into machine language (interpret will generate a file with .pyc) and then execute the instruction producing the result
33
•
Debugging • Check program execution and output to ensure program compiles and runs as expected • If it doesn’t, make corrections in the edit phase and repeat the remaining steps
34