CSC 1010 Lecture 1 Course Overview Web site Syllabus CSC 1010 Programming for All Schedule Lecture slides Reading Assignments & Textbook Handouts Lecture 1 Welcome & Getting Started 2 1 2 Why Program? Why Program? Make computers helpful… Programmers solve problems… What Computers are built for one iPhone Applications are a Next? purpose - to do things for us market But we need to speak their iPhone Applications have language to describe what we over 3 Billion downloads want done Programmers have left their What What What Users have it easy - someone jobs to be full-time iPhone Pick Pick Pick Next? Next? Next? already put many different developers Me! Me! Me! What What What Pick Pick Pay programs (instructions) into Programmers know the ways Next? Next? Next? Me! Me! Me! the computer and users just of the program pick the ones we want to use 3 4 3 4 User or Programmer? User or Programmer? You’re a user if see the computer as a You’re a user if see the computer as a tool to get things done tool to get things done You’re a programmer if you see the You’re a programmer if you see the computer as a tool to solve problems for computer as a tool to solve problems for users users 5 6 5 6 1
CSC 1010 Lecture 1 Why be a Programmer? What is a Program? To get something done A program is a sequence of instructions that can be interpreted and executed by a computer. Clean up survey data for processing – A program is expressed in a Design a spreadsheet that automates things – particular programming language , like Python. Understand how the team you manages – There are 100s of programming languages, like: uses coding to solve problems Java, C++, Php, SQL, and more To solve problems for others Writing a program is also an act of creativity , Fix a performance issue in software – which many view as both an art and a science Add a guestbook to a web site – Make a mobile app that everybody loves – 7 8 7 8 The Python Programming Language The Python Programming Language Created by Guido van Rossum in 1989 One of the most successful programming languages ever Over 4 million developers in every major industry …while on vacation 9 10 9 10 The Python Programming Language The Python Programming Language Where did it get its name? Core Principles • Beautiful is better than ugly. Not the snake… the Monty Python comedy troupe What is it used for? • Explicit is better than implicit. Everything… it is a general‐purpose language • Simple is better than complex. • Complex is better than complicated. First public release: 1991 • Readability counts. • …and more… 11 12 11 12 2
CSC 1010 Lecture 1 Algorithms Examples of Algorithms A step‐by‐step procedure for solving a problem • Making a peanut butter and jelly sandwich • Navigating a human robot around the room • Performing awesome dance moves Give it some input… It does something… Then it produces some output 13 14 13 14 Algorithm: Performing Dance Moves Algorithm: Did you see the bugs? while music is playing: while music is playing: Left hand out and up Left hand out and up Right hand out and up Right hand out and up Flip Left hand Flip Left hand Flip Right hand Flip Right hand Left hand to right shoulder Left hand to right shoulder Right hand to left shoulder Right hand to left shoulder Left hand to back of head Left hand to back of head Right ham to back of head Right ham to back of head Left hand to right hit Left hand to right hit Right hand to left hit Right hand to left hit https://www.youtube.com/watch?v=vlzwuFkn88U https://www.youtube.com/watch?v=vlzwuFkn88U Left hand on left bottom Left hand on left bottom Right hand on right bottom Right hand on right bottom Wiggle Wiggle Wiggle Wiggle Jump Jump 15 16 15 16 Algorithm: Fixed the bugs! Programming Errors while music is playing: Syntax – the grammar rules for the language Left hand out and up Right hand out and up Semantics – the meaning of things in the language Flip Left hand Flip Right hand Left hand to right shoulder Syntax errors – grammar problems or typos Right hand to left shoulder Left hand to back of head Runtime errors – crashes when it runs Right hand to back of head Left hand to right hip Logic errors – works but get the wrong answer Right hand to left hip https://www.youtube.com/watch?v=vlzwuFkn88U Left hand on left bottom Testing – trying to break your program Right hand on right bottom Wiggle Debugging – finding and fixing problems or "bugs" Wiggle Jump 17 18 17 18 3
CSC 1010 Lecture 1 Programming Errors Programming Errors The interpreter analyzes a program and reports any syntax errors The interpreter runs the program, runtime errors cause it to fail divide by 0 missing error colon t ot al = 7 pr i nt ( 99 / 0) i f t ot al > 0 pr i n t ( ' The t ot al i s a posi t i ve num ber ' ) el se: pr i nt ' The t ot al i s NO T posi t i ve' Tr aceback ( m ost r ecent cal l l ast ) : Fi l e " r unt i m e_er r or . py" , l i ne 1, i n pr i nt ( 99 / 0) print Zer oDi vi si onEr r or : di vi si on by zer o spelled missing wrong parentheses 19 20 19 20 Programming Errors Computer Hardware The physical components: The interpreter runs the program, logic errors give wrong results • monitor, mouse, keyboard, disk drives, etc. • system circuit boards which include: main processor, pr i nt ( ' The per i m i t er of a squar e wi t h 3 i nch si des i s' ) memory, graphics processor, and sound card. pr i nt ( 4 * 4, ' f eet . ' ) No syntax errors. The program runs without crashing. The per i m i t er of a squar e wi t h 3 i nch si des i s 16 f eet . spelled wrong output should in output be on 1 line If it's part of a computer system and you Wrong! units should Should be 12 can touch it, it is computer hardware. be inches 21 22 21 22 Computer Hardware Computer Hardware The von Neum ann architecture Overheating Central Processing Unit (CPU) If a computer was a person… • Control Unit: heart • Arithmetic Logic Unit: thinking brain CPU: brain synapses • Memory Unit: remembering brain • Input: the senses • Output: speech & movement http://www.youtube.com/watch?v=y39D4529FM4 23 24 23 24 4
CSC 1010 Lecture 1 Computer Hardware Flow of Control What happens next in the program? Hard Disk in action Step by Step Calling Functions http://www.youtube.com/watch?v=9eMWG3fwiEU 25 26 25 26 Flow of Control Python Quickstart What happens next in the program? Step 1. Download from python.org Step 2. Install (double‐click on what you downloaded) Conditionals Loops Step 3. Run IDLE shell (a new menu option) Step 4. Run IDLE editor 27 28 27 28 Python Quickstart Using IDLE Step 1. Download from python.org IDLE is a Python editor and environment for running programs Step 2. Install (double‐click on what you downloaded) Syntax Highlighting Menus Step 3. Run IDLE shell (a new menu option) File > New File Step 4. Run IDLE editor File > Open File > Save Run > Run Module (F5) 29 30 29 30 5
CSC 1010 Lecture 1 Hello, World! Hello, World! Another example: The classic first program to write in any new language. pr i nt ( ' Tel l m e and I f or get . ’ ) Program statement: pr i nt ( ' Show m e and I r em em ber . ’ ) pr i nt ( ' I nvol ve m e and I under st and. ' ) pr i nt ( " Hel l o, W or l d! " ) Output: Tel l m e and I f or get . Show m e and I r em em ber . I nvol ve m e and I under st and. Hel l o, W or l d! 31 32 31 32 Hello, World! Make use of the download and R & R buttons on code in the textbook Download the program to your computer Run & Revise the code right in the browser 33 33 6
Recommend
More recommend