Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tuesday, November 8th Warm Ups:

Similar presentations


Presentation on theme: "Tuesday, November 8th Warm Ups:"— 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 Readability
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
y = / (3 * (10 - 9)) z = ** 2 m = 6 / 3 + 3

13 2 + 2 Integers and Floating Point Numbers
Integers = whole numbers 4, 0, 99 Floating point numbers = 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 expression 4.What is Python? 5.How will your knowledge of scratch and finch help you with python?

20 It has evaluated the expression
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 both evaluate to 15 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 executed successfully 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 = create variable >>> var state variable value stored >>> var variable used variable remembered and used >>> 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 Strings can have almost any keyboard character ‘ ‘
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 creating a set of instructions
Flow of execution creating a set of instructions That is the basic definition of programming

32 # will allow you to add a comment to explain
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 Variable names are case-sensitive
Computers will only do what you tell them Variable names should be relevant 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 This is a function INSIDE the random
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 Arguments tell the function how to behave
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 string string string
Another example of concatenating strings together print('Well, ' + name + ' I am thinking of a number between 1 and 100.') + + string string string

43

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

45 Boolean Data Type Conditions 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

46 Booleans, Comparison Operators, Conditions
Experiment … pages 11, 12 Booleans, Comparison Operators, Conditions

47 Int( ) function Break statements Str( ) 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

48 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

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

50 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 program Due 11/15 end of class

51 Wednesday, November 16th Warm Up: Today, you are going to create your own MadLib! Create madlib using Python  (all it takes is variables, print and input functions and concatenation)  Use these Functions: input & print Create at least 4 Variables Use Concatenation of strings & variables Include the date and time at the beginning of the code import datetime  Due at end of class on 11/16

52 Thursday, November 17th Warm Up: When your python program doesn’t work, how do you fix it? Today Mad Lib Finish reviewing joke programs and flow charts Review Scratch game Chapter 6 Python

53 Monday, April 11th Warm Up: Please take the chapter six handout from the middle table. Read the code. Write on the document what each line of code does. If you don’t know, circle it. Today: Schedule discussion Brief Overview of chapter six Time to work on chapter six

54 Tuesday, November 29th Today: Chapter 6 more to learn!
Warm Up: It’s time to get back into Python! In your journal, define: Loops, blocks, Boolean Data Type, Comparison Operator (if you can’t remember, you can always look it up in the “book”!) Today: Chapter 6 more to learn! Get a copy of the Dragon program from the middle table

55 Chapter 6

56 Def () function Def function is creating, or defining, a new function that we can call later in our program. This way you don’t have to recreate the same code multiple times.

57 Functions Define the function BEFORE you call it in the program
Let’s look at the chooseCave function. On what lines is it defined? On what line is it executed or called?

58 Return Value ONLY inside Def blocks
Breaks us out of the function (like Break will break out of a while loop) Look at line 17

59 Or Else Else – always comes after the IF block
Explains what happens IF the condition is NOT met Colon : must always accompany the else key word Look at line 32

60 or not Truth Tables and A and B is Entire statement
True and True is True True and False is False False and True is False False and False is False A or B is Entire statement True or True is True True or False is True False or True is True False or False is False not A is Entire statement not True is False not False is True and or not

61 Boolean – Truth tables Look at line 13
It’s an expression with a boolean operator “AND” Which means ….

62 Boolean – Truth tables While
The cave is NOT 1 And (since AND is used, both of these conditions must be true for the boolean to be true) The cave is NOT 2 (line 14) Ask the user which cave they want (line 15) The user’s input is the variable “cave” What happens if the user enters “two” or “pig” or “17”?

63 Global Scope Variables
Remember I said we would come back to this … Global Scope Variables read outside and inside functions, but can only be modified outside of all functions. Where can we find one in Dragon? Local Scope Variables read or modified inside that function. “forgotten” after the function is executed Where can we find one in Dragon? Global: Local: line 12, part of the choose cave function

64 But …. What do I do if I need to take a global variable and use it inside a function? I have to “give” or “pass” that global variable to the function That’s called a parameter

65 Parameters Line 19 Def checkCave (chosenCave) : Variable names inside parenthesis are called parameters Parameters are local variables that are defined when we call a function chosenCave is a new, local, temporary variable It’s the variable that indicates which cave the user selected

66 This is where the game actually begins!!!!

67 It begins … Set variable playAgain to yes Make sure playAgain is yes
Run Intro function (which prints several lines) Set a variable, caveNumber, to the results of the chooseCave function Run checkCave function, Using the caveNumber Variable, to determine whether or not the user picked the friendly cave Ask the player if s/he wants to play Again, get player’s input

68 Ticket Out Please take out a piece of paper, put your name on it, and answer these questions: 1. What is a global variable?, 2. What is a local variable? 3. What does the time.sleep (2) function do? 4. What’s the proper name for the “2” in the time.sleep function above? 5. What does the “2” do?? 6. What does the “return” keyword do (on line 17)in the following function?

69 Wednesday, November 30th Warm Up: What is the purpose of the def function and why would you use it in a program?

70 Skills to create a program
Get with your 8:00 clock partner Create a new python program, name it practice.py Write python code that accomplishes each of these tasks (work on one of them at a time): NOTE: DO NOT USE the def function!!!!! NOTE: start a NEW program User chooses from a list of options Different programming based on the user’s choice

71 More Skills to Create a Program
Create random variable Uses boolean operator to compare two variables and take some action Allows user to choose ‘Play again”

72 Next Steps Share python program with your partner
Decide what program you would like to create for your assessment Create a flow chart of the program

73 Thursday, December 1st Warm Up: SIT BY SAME PARTNER FROM YESTERDAY
Did you complete the first two tasks? User chooses from a list of options Different programming based on the user’s choice Which one have you struggled with the most?

74 User chooses from a list of options
Different programming based on the user’s choice Create a variable and set it equal to a random number Uses boolean operator to compare two variables and take some action Allows user to choose ‘Play again”

75 Friday, December 2nd Warm Up: Video
Today: Create a flow chart for a Python program you will make

76 What’s a 4?? Program is professional in quality and ready for publication. Program has a clear purpose, and a clear ending. The program involves the user. The program has a logical ending or allows the user to “play again”. Expertise in PYTHON is demonstrated. This program is a cut above the rest – clearly demonstrating knowledge and expertise using PYTHON.

77 To Do Create flow chart – show it to Mrs. H for approval
Begin work on your program Due: Wednesday 12/7

78 Wednesday, December 7th Warm Up: Write in your journal three things you learned from Mrs. Houtman’s presentation Today: Create a program in Python Show off your Python skills … check the rubric to make sure your program is a “4” Due Thursday, December 8th NOTE: I’m still missing some flow charts!

79 Thursday, December 8th USE THIS ENTIRE CLASS PERIOD TO PERFECT YOUR PYTHON PROGRAM Friday: Peer Review, turn in program

80 Friday, December 9th Warm Up: Please take a peer review rubric from the table and then open your Python program Field Trip reminders Conduct peer review with your 3:00 clock partner – no partner, meet at middle table and find someone

81 Turn in your game Save your file using the proper name: hour_lastname_firstname_python CLOSE THE FILE Go to : Password = hasseld Doesn’t ask for password?  You are not on the proper site! Upload the file when done THEN TURN IN THE PEER REVIEW IN MY BOX!

82 Wednesday, December 14th Warm Up: Please have your documentation from Javascript up so Mrs. H can check it in – even if you didn’t complete it, I want to see what you did get done Today: review guide for Python quiz – quiz on Friday


Download ppt "Tuesday, November 8th Warm Ups:"

Similar presentations


Ads by Google