1 / 82

Tuesday, November 8 th

Tuesday, November 8 th. Warm Ups: Please find your new seat! Please NOTICE the personal technology sign is RED. NOTE: if you did NOT present your Finch project yet, we can discuss in the last ten minutes Today … we CONTINUE Python!. Programming. Computer Screens OFF Fold paper into 1/3

ewitt
Download Presentation

Tuesday, November 8 th

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tuesday, November 8th • Warm Ups: • Please find your new seat! • Please NOTICE the personal technology sign is RED. • NOTE: if you did NOT present your Finch project yet, we can discuss in the last ten minutes • Today … we CONTINUE Python!

  2. Programming • Computer Screens OFF • Fold paper into 1/3 • Left side: “Programming Skills I’ve Learned” • Middle: “Programs/Projects” • Right Side: “Programming skills I still WANT to Learn”

  3. Programming Skills I’ve learned Make a list!!!

  4. Programming Skills I still WANT to learn Make a list!

  5. Let’s fill in our programs/projects

  6. Here’s what we are about today … • Identify programming skills you’ve learned, skills you want to learn and see the progression between the programming languages we use in class. • Define integers, operators, values and expressions and practice these mathematical tools using Python.

  7. Why Python? • Python is a high level language • It still “hides” much of the technical computer language • You can use “English” to program • Dynamic programming language • Fast and incremental development • Self checks at run time

  8. Why Python • Expressive Power • How easy it is to express an idea • How concisely you can express your idea • Readability • Indentation • Use of words instead of symbols

  9. Python Chapter 2 Syntax error programming language

  10. Some Simple Math … • Your interaction with Python begins with some simple math … • Let’s set the stage first … • You take notes …

  11. Arithmetic Operations & Hierarchy of Operations Operator operation Basic expression ** Exponentiation A ** B * Multiplication A * B / Division A / B + Addition A + B - Subtraction A - B

  12. Examples Evaluate the following expressions: x = 3 * 6 - 12 / 3 x = 4 ** (8 / 4) y = 12 + 6 / (3 * (10 - 9)) z = 5 + 4 ** 2 m = 6 / 3 + 3

  13. Integers and Floating Point Numbers Integers = whole numbers 4, 0, 99 Floatingpointnumbers = numbers with decimal point 4.0, 0.0, 23.45 Expressions are made up of values and operators operator value value 2 + 2 Scratch operators were the green blocks expression

  14. Python … • Python has an “interactive shell” where you can program a line of code and quickly see whether or not it works • It’s an icon on your desktop that looks like this: (turn on screen and OPEN it!)

  15. Let’s test it out … • With IDLE open, enter 2 + 2 • What happens?

  16. What’s the computer program (Python) really doing? If you wanted to do the same thing in Scratch, how would you do that?

  17. In Summary • Identify programming skills you’ve learned, skills you want to learn and see the progression between the programming languages we use in class. • Define integers, operators, values and expressions and practice these mathematical tools using Python. • TOMORROW … You get to PLAY on your own, with a great tutorial.

  18. Thursday, November 10th • Warm Up: Please retrieve your questions from yesterday and please get out a pen or pencil • Also, please determine exactly where you are in the Python “book” (chapter 3? Chapter 4???) • Today: • Review Python Concepts • Continue work

  19. Questions from 11/9 • 1.What’s the difference between an Integer and a floating number?2.What’s the difference between an Operator and a value? 3.Explain what an Expression is and what it means to evaluate an expression4.What is Python?5.How will your knowledge of scratch and finch help you with python?

  20. Python isn’t limited to just numbers. It’s more than just a fancy calculator. When a computer solves the expression 10+5 to get the value 15 It has evaluated the expression 10+5 and 10+3+2 both evaluate to 15 5 + is NOT an expression

  21. Creating Variables • Variable- Location where memory can be stored on the computer. Value can change as the program is running. • To save the values that our expressions evaluate to use them later • Used to hold temporary information • Used to control the type of data in calculations • Can store only one piece of data at any time • Data is processed faster

  22. Statements • When you press Enter • And there is no “error message” • The instruction has been executedsuccessfully • The instruction (assignment statement) creates the variable to be stored • Statement = not single value • Expression = single value

  23. Create a variable and evaluate it • >>> var = 12 create variable • >>> var state variable • 12 value stored • >>> var+6 variable used • 18 variable remembered and used • >>> 12+6 is just like var + 6

  24. Using multiple variables • >>> fish = 100 • >>> bear = 140 • >>> fish + bear • 240 • >>> Fish variable has 100 inside it What does bear represent?

  25. Overwriting a variable • Replacing the value in a variable with a new value • The old value is permanently forgotten

  26. Questions to complete 11/10 • How do you create a variable in Python? How does that compare to scratch? • How do you store a variable in Python? • How do you overwrite a variable in Python? • What does it mean when Python “evaluates an expression?” • What’s a string? How do you indicate something is a string?

  27. Python Chapter 3

  28. Friday, November 11th • Warm Up: Take a “Guess” handout from the middle table • Read it, analyze what the program is doing • Feel free to write all over the paper • Let’s review it together … again feel free to write on the code

  29. Strings • Little chunks of text • To create a string put information between two single quotes • ‘ ‘ >>> speak = 'hello' >>> speak 'hello' >>> Strings can have almost any keyboard character

  30. String Concatenation You can add one string to another >>> 'Hello ' + 'World!' 'Hello World!' >>>

  31. Flow of execution creating a set of instructions That is the basic definition of programming

  32. Comments # will allow you to add a comment to explain something that will not interfere with the flow of execution Function Mini programs and some are already programmed into Python code Print () Print function will display text on screen between () Input () Waits for input for the user to enter Function calls will evaluate a single value --- Return Value

  33. Computers will only do what you tell them Variable names should berelevant to what they are for Variable names are case-sensitive World WorlD world These are all different variables Capitalize if you use more than one word in variable and no spaces VariableNameMultipleWords

  34. Guess Program – flow chart • How do you flow chart “while” • How do you flow chart “if”

  35. Monday, November 14th • Warm Up: Please get out your completed flow chart for the guess program. • Today: Review chapter four, questions, chapter 5 – joke program

  36. Python Chapter 4

  37. Import, Module, Function • Import is a code that tells Python to “bring in” a module • Function: prewritten code or mini program that you can use in Python, available in your program • It’s like boxed spaghetti noodles instead of making them from scratch • Examples: print ( ), input ( ), • Module: prewritten code or mini program used in Python, you must IMPORT into your program • It’s like a frozen dinner with spaghetti, noodles and bread • Example: Random

  38. Random Function number = random.randint(1, 20) This is a function INSIDE the random module. This function will return a random integer between two numbers Number is a variable that is storing the random number

  39. Arguments Values that are passed to a function when the function is called Arguments tell the function how to behave Arguments are separated by commas

  40. Let’s practice • Open Python’s IDLE (remember, that’s where you can practice code) • In chapter four, turn to pages 6 & 7 • Play with the random.randint function!!!

  41. Loops Loops are parts of code that will happen (executed) over and over Blocks Blocks begin where the line is indented four spaces Blocks end where the line indentation is the same as before the block You must have blocks to create loops

  42. Concatenation Review Another example of concatenating strings together print('Well, ' + name + ' I am thinking of a number between 1 and 100.') + + string string string

  43. Comparison Operators < Less than > Greater than <= Less than or equal to >= Greater than or equal to == Equal to != Not equal to

  44. Boolean Data Type Two values TRUE or FALSE Case sensitive Not strings Also called bools Conditions Expression that combines two values with a comparison operator Always evaluates a Boolean value

  45. Experiment … pages 11, 12 Booleans, Comparison Operators, Conditions

  46. Int( ) function Converts strings to integers with this function Break statements Tells the program to jump out of the while-block Str( ) function Converts an integer to a string with this function

  47. Now work on Chapter 4 OR if you have completed everything, move on to Chapter 5 There are 6 definitions on my website that you need to complete for chapter four

  48. Tuesday, November 15th • Warm Up: Create a flow chart for the joke program

  49. Chapter Five • Writing Jokes! • Complete chapter 5 by writing and running the program • Then, complete all the tasks in chapter 5 • Then, create your own joke program • - include at least three jokes- include user input- show Mrs. H when done both the flow chart and your own joke programDue 11/15 end of class

More Related