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