280 likes | 290 Views
Class 1: What this course is about. Assignment. Read: Chapter 1 Do: Chapter 1 ‘workbook’ pages not finished in class You should know: How to use the command line How to create and save a file if … else while Role of indenting What is a function (e.g., print(), input() )
E N D
Assignment • Read: Chapter 1 • Do: Chapter 1 ‘workbook’ pages not finished in class • You should know: • How to use the command line • How to create and save a file • if … else • while • Role of indenting • What is a function (e.g., print(), input()) • What is a parameter
In a nutshell (Thread 1) • This course is about writing computer programs that solve problems • First step: ‘grok’ the problem. (Look up the meaning and origin of ‘grok’.) • Second step: write the program • Third step: make sure the program correctly solves the problem
In a nutshell (Thread 2) • This course is about some of the high points on the terrain of computing. For example: • What is computing? • How does the Internet work? • How do hardware and software work together? • … and more
What is an algorithm? • An algorithm is an unambiguous, step-by-step procedure for solving a problem • A recipe is an example of an algorithm • An algorithm provides the design for a computer program
What is a computer language? • A computer language is a way of writing down algorithms • ‘High level’ languages are readable, like natural human languages • Computer languages are precise enough to be executed by (unthinking) machines • All computer languages are fundamentally equivalent in their expressive power
What is a program? • A program is a set of instructions written in a computer language • A program implements an algorithm • A program written in a high-level language may be translated into a low level language (the natural language of a computer)
What is a computer? • A computer is a machine which executes programs (unlike a lawn mower) • A computer can execute any program (unlike a CD-player) • Since computers are Universal Machines, they are all fundamentally equivalent in computing power
How do you write a program? • A computer can execute programs that are tools for creating programs • The programmer’s everyday tools might include: • editor • compiler • debugger • A suite of such tools is called an integrated development environment (IDE) • We are using the Python language and IDLE IDE
The editor • An editor is used to write programs • Programs are written in plain text • The file containing the program in a high-level language is called the source file • A Python source file usually has the extension ‘.py’
The interpreter • An interpreter translates from a high-level language to the computer’s language (instruction set) • Interpreters usually translate and execute code line by line • A source file can not be interpreted and executed unless it is syntactically (grammatically) correct
The devlopment environment • We will be working in the Python integrated development environment called IDLE • IDLE contains an interactive environment in which you can write and execute instructions line by line • IDLE also contains an editor to write and store programs and a debugger to help correct programs
The debugger • A debugger allows you to ‘step through’ the program, viewing the changing values • A debugger aids in finding and correcting logical errors. • (The sentence ‘Colorless green ideas sleep furiously’ is grammatically correct, but what does it mean? Look in up on the Web.)
Panic abatement advice • Expect to spend lots of time • Programmer wisdom: it always takes longer than you think • Expect things to go wrong • Murphy’s law of computers: anything that can’t go wrong, will • Don’t panic: every bug has a fix
Tips for success • Start every assignment early • Don’t fall behind • Ask if you don’t know • Do your own work
Getting help • Use the online help system • Every TA and instructor has office hours • There are tutors available (check the course web site) • My contact info: • Barry Cohen • 3503 GITC • barry.cohen@njit.edu • Tues, Thurs 2:30-3:30
Grading • Homework (6) 15% • Projects (2) 15% • Midterm 1 20% • Midterm 2 20% • Final 25% • Participation 5% • All sections have same work and tests • Course is graded on a curve
Attendance • Attendance is mandatory (you are asked to sign in). Five absences will lead to withdrawal • Arriving late or leaving early counts for ½ of an absence
Homework • HW assignments are approximately bi-weekly • HWs are handed in at the start of class • No late HWs will be accepted • Every HW must be in hard copy – code and output, neatly printed and stapled • Every HW must have student name and SS#, date, HW # section #
Honesty • Cheating on an exam will result in failing the course • You may discuss HW problems with each other • You may not take credit for something you did not do
Logging On • Linux/Unix, Mac or Windows • UCID • Password • Password problem? • Unattended Password Reset (UPR) • http://mypassword.njit.edu
Introduction To Python • What is Python? • Very high level language (HLL) • Scripting language • Why use Python? • Powerful and fast • Runs everywhere • Easy to learn • Easy to read • Encourages good programming practices
The Python Interpreter • Linux/Unix • Open a terminal window • Type ‘python’ or ‘idle3’ at a command prompt • Or double click icon • Windows • Go to Start > Programs > Python3 > Idle • Or double click icon • Mac • Open from terminal or double click icon
Python As A Calculator • Python can perform all basic arithmetic operations • How many minutes in a year? • How many seconds since the universe began 13 billion years ago?
The IDLE environment • You can use IDLE to assign values to an identifier (i.e., a name) >>> x = 5 • An IDLE session has a memory >>> x 5 >>> y = x >>> y 5 • You can the change the value assigned to an identifier >>> x = 'five' >>> x 'five'
Your First Python Program • Type print(‘Hello, World!’) and then press the enter key • The Python interpreter prints ‘Hello, World!’ on the screen
More about Hello, World • print() is a function • A function is a named block of code • A function hides how it works from the outside world • ‘Hello, World’ is a parameter • A parameter is ‘handed’ to a function • A parameter is in parens, after the function name • Try print () and (‘‘) • Try print (‘hello‘, ‘and goodbye‘) • Try print
Our textbook • Head First Programming • This book incorporates workbook material that we will do in class • Let’s go through Chapter 1