UNIT 6. Functions and Structured Programming
|
|
- Winfred Webb
- 5 years ago
- Views:
Transcription
1 UNIT 6 Functions and Structured Programming
2 DAY 1 What is a Function? What is Structured Programming?
3 I can.. Divide a large program into small problems. Write a Python program as a function
4 Planning a Wedding What are some of the steps we will take when planning a wedding?
5 Planning a Wedding Make Guest List Take Engagement Photos and Send out Save the Dates Decide on Wedding Party Find Wedding Gown, Bridesmaid Dresses, and Tuxes Pre-Marital Meeting with Officiant (Paster, Priest, etc) Food Tasting Purchase Decorations Plan Rehearsal Dinner Do Final Preps Decorate the Hall Prepare Food Dance and Enjoy!
6 What is Structured Programming? Organizing programs by breaking them up into smaller, easier to manage programs (called functions) Allows you to reuse code that is repeated! Divide and Conquer Method Top Down Design Break a large programming task (Top) into smaller and smaller subtasks (Bottom) **ALSO CALLED MODULAR PROGRAMMING**
7 Why is Structured Programming Needed? Past programming: Programming in older languages vs. modern style of programming Older: Spaghetti Code Hopelessly intertwined statements caused by numerous jumps between sections of code Nearly impossible to follow NO FLOW Modern: Use functions 1 main function where main code runs logically in order Will run other functions but always return to main.
8 Steps to Writing a Structured Program 1. Start with an Outline of the main program Write out pseudocode to describe major tasks to be performed Avoid thinking about the details of each major task right now 2. Write the main - mostly calls to functions Translate each English phrase into one or two function calls Use documentations to describe the actions and make programs readable
9 Steps to Writing a Structured Program 3. Write each function Define the function (name and parameters) Type the code for that function (indented) 4. Test and Debug Use a complete set of test data to be sure it works Make changes or refinements that are necessary or desireable
10 Example of the planning process
11 We ve Already Used Functions Brain storm as many functions as you can that we ve already used throughout this semester!
12 Functions Already Used Turtle graphics. forward() color() left() goto(x, y) Math functions sqrt(n) pi pow(b, n) floor(n) General Functions print() input() eval() String Functions len(x) upper(x) chr(x) ord(x) split(x) Random Functions random() randrange(x,y,z) randrange(x, y) **We ve actually used MORE than this**
13 What is a function? A sub-program or block of code that accomplishes a specific task Often returns a value, text, or object A Mini Program Also called a method or subroutine
14 New Approach to the Main Function We can (and will starting today) write our main function like a function! Functions Syntax: def <name of function> (): <statements>
15 Let s Write an Example Together Let s write a program that prints out the lyrics to the song Happy Birthday Main program must now be written as a function so we can add functions in later!
16 Program #1 # Happy Birthday Program # create main function def main (): # get name from user name = input( What is your name?: ) # print happy birthday to user print( Happy Birthday to you ) print( Happy Birthday to you ) print( Happy Birthday dear, name) print( Happy Birthday to you )
17 How do we make our program run? The main function is an executable function but we need to tell it to execute the main! def main () : <statements>.. main() This line of code at the end of a python program will run the main function
18 Let s Write our First Function In the happy birthday program do you notice any code repeating??? This is a perfect time to use a function!
19 Let s Look Back! # Happy Birthday Program # create main function def main (): # get name from user name = input( What is your name?: ) main() # print happy birthday to user print( Happy Birthday to you ) print( Happy Birthday to you ) print( Happy Birthday dear, name) print( Happy Birthday to you ) repeated 3 times repeated 3 times repeated 3 times
20 Let s Write a Function **Add this code beneath the main() statements** # function prints 1 line of Happy Birthday def happy (): print( Happy Birthday to you )
21 Let s Update our Main! # Happy Birthday Program # create main function def main (): # get name from user name = input( What is your name?: ) main() # print happy birthday to user happy() happy() calling and running the happy() function calling and running the happy() function print( Happy Birthday dear, name) happy() calling and running the happy() function
22 Program Write a program to print the lyrics to the song Old MacDonald. Your program should use functions for any repeated line of code. Write your program so it will sing Old Mac Donald for three different animals: Basic Verse: Old Mac Donald had a farm! Ee-igh-ee-igh-oh! And on that farm he had a cow! Ee-igh-ee-igh-oh! With a moo, moo here and a moo, moo there! Here a moo, there a moo, everywhere a moo, moo! Old Mac Donald had a farm! Ee-igh-ee-igh-oh!
23
24 DAY 2 Passing parameters to a function
25 I can.. Write a function in Python. Write a program that uses functions
26 Review of Terminology: What is a function? What is structured programming? What is structured programming also called? What are the benefits of structured programming?
27 Benefits of Structured Programs 1. Easier to read Each function will have documentations explaining its purpose 2. Easier to write Complicated programs broken down into smaller, easier to manage functions 3. Easier to use, change, adapt, modify, debug Only need to change in one location (not every time appears in program) Easily determine where an error is occuring 4. Easier to reuse Can be copied into another program Can be called in the same program multiple times 5. Other, More powerful programming languages require this kind of structure.
28 Writing Python Programs with Functions! def main(): <statements> function1() function2() def function1(): <statements> def function2(): <statements> main()
29 Question to Ponder 1. If each function is its own mini program, how is information shared between different functions? 2. How do I get data that is held within one subroutine into another one for processing??
30 Parameter Variable Values passed into the function The function needs these values in order to do its job May include as many parameters as the function needs If no parameters are needed the parentheses are empty **Yesterday s happy() function**
31 Parameter Passing A function definition with parameters: def <name> (<formal parameters>) : <statements> Example: def hello (person) : print( hello, person)
32 Parameter Passing A function call with parameters: <name>(<actual parameters>)
33 Parameters The parameter provides a method of transferring data from the main function to be the function being called Ex: ord( A ) chr(45) lower(message) takes in a CHARACTER takes in an INTEGER takes in a STRING
34 Let s update our Happy Birthday Program Version 1: Create a function called sing that will take in a parameter name and sing happy birthday to the person The Sing function should use the happy() function we create yesterday Program should sing Happy Birthday to Joe, Callie, and Alex
35 Let s update our Happy Birthday Program # Happy Birthday Program # create main function def main (): # get name from user name = input( What is your name?: ) main() # print happy birthday to user happy() happy() print( Happy Birthday dear, name) happy()
36 Sing Function # Sings happy birthday to a person with a given name def sing (personname): happy() happy() print( Happy Birthday dear, personname) happy()
37 How do we call a function with parameters? The same way we call any other function but we need to ensure we send it that parameter requirements Example: sing(personname)
38 Let s update our Happy Birthday Program # Happy Birthday Program # create main function def main (): # get name from user name = input( What is your name?: ) #sings happy birthday to user sing(name) # sends in name of user main()
39 Let s Sing to More People! # Happy Birthday Program # create main function def main (): # get name from user name = input( What is your name?: ) main() #sings happy birthday to user and others! sing(name) # sends in name of user sing( Joe ) sing( Callie ) sing( Alex )
40 Write a Program in Python that contains the following. Your program will: 1. Call a function which prints a welcome message. 2. Call a function which sends the user s name and comments to the user telling him/her how many characters are in the name 3. Calls a function which sends the user s age and comments on whether the user is able to drive or not. 4. Calls a function that sends in the user s favorite color and comments on the color. 5. Calls a function that generates a random number for the user and prints the number to the screen. 6. The user should be able to continuously play this game until they choose to quit.
41
42 DAY 3 Returning a Value
43 I can.. Write a function in Python that returns a value. Write a program that uses functions
44 Review of Terminology: What is a function? What is structured programming? What is structured programming also called? What are the benefits of structured programming?
45 How do we get a value from a function? Most functions we have used so far in this class have provided us with a value. Examples: len() lower() returns the number of characters in a string returns a copy of a string in all lower case letters randrange(4,9) returns a random integer between 4 and 8 ord() chr() returns a character at the ASCII number returns an integer for the ASCII character
46 Returning a Value Called Function returns a value to the program calling the function. If a value is returned, it must either be saved inside a variable in the program calling the function or used immediately when called If the returned value isn t saved or used, it is LOST Function are NOT required to return a value
47 Returning a Value Returning a Value def <name> (<formal parameters>) : <statements> return <variable name>
48 Returning a Value Example in Code def addition(num1, num2): sum = num1 + num2 return sum
49 Program: Convert Pounds to Kilograms # main program def main(): #welcome statement print( Converts pounds to kilograms \n \n ) # gets weight from user lbs = eval(input( Enter your weight in lbs: ) # converts pounds to kilograms, returns kgs, and # SAVES the value inside a new variable named kgs kgs = compute(lbs)
50 Program continued # prints kilograms to screen print(weight in kgs:,kgs) # function that converts pounds to kilograms def compute(lbs): kilograms = lbs/2.2 return kilograms #runs main program main()
51 2 nd Way to Use returned values # main program def main(): #welcome statement print( Converts pounds to kilograms \n \n ) # gets weight from user lbs = eval(input( Enter your weight in lbs: ) #prints kgs to screen print(weight in kgs:, compute(lbs) )
52 Write a Program that does the following 1. Write a program that converts between Fahrenheit and Celsius (C=(F-32)*5/9). Your program must use a function to calculate the temperature in Celsius and return the value to the main function to be output. 2. Write a program that asks the user for a number and then calculates the square of that number. Your program must use a function to calculate the square and return the value to the main function to be output.
53 Write a Program that does the following 3. Write a program that will find the area of a sphere (A=4*pi*r 2 ) with a radius provided by the user. Your program must use a function and return the area of the sphere to the main function to be output. 4. Write a function that calculates the sum of the first n natural numbers. N is a value that will be inputted by the user and should be used passed into a function that calculates the sun of the numbers from 1 to n. Your function must return a value to be outputted.
54
55 DAY 4 Passing more than one Parameter
56 I can.. Write a function in Python that takes in multiple parameters.
57 Review of Terminology: What is a function? What is structured programming? What is a parameter? What is a returned value?
58 What happens when we send in a parameter? Main function (or the function calling another function to run) sends in the VALUE This means if a variable name is placed in the parameter list, the VALUE is the only thing sent in THE VARIABLE VALUE WILL NOT BE CHANGED IN THE MAIN PROGRAM AS THE FUNCTION FUNS The variable value sent in will only be USED by the function to complete its task
59 Example def main(): name = input( What is your name: ) double(name) print(name) def double(name) : name = name*2 print(name) main()
60 Functions Using Parameters name name Each function stores its local variable information in different places in memory In this program there are actually 2 variables called name one saved in the main program s block of memory another stored in the double function s memory
61 Local Variable All variables are LOCAL to the function they are defined in. **Bubbler Explanation Example** To access a variable outside a function, it must be passed to the function
62 Passing Parameters Function Definition Syntax: def <name>(<formal parameter1>,, <formal parametern>) <body> Function Call Syntax: <name>(<actual parameter1>, <actual parametern>)
63 Passing Parameters by VALUE A copy of the VALUE of a variable are passed to the function. The function than creates it s own variable with that value this variable is LOCAL to the function
64 When Python Comes to a Function Call 1. The calling function suspends execution at the point of the call 2. The formal parameters of the function get assigned the values supplied by the actual parameters in the call. 3. The body of the function is executed. 4. Called function returns a value (if necessary) and the program returns to the point just after where the function was called.
65 Example Program #1 def main() : print( The value of x in main before the function call, x) changex(x) print( The value of x in main after the function call, x) def changex(x) print( The value of x at beginning of changex call, x) x = x + 25 print( The value of x after changex call, x) main()
66 Example Program #2 def() main: length = eval(input( Enter length: )) width = eval(input( Enter width: )) area = computearea(length, width) print( area =, area) def computearea(l, w) : a = l*w return a main()
67 Write a Program that does the following 1. Write a program that takes in two numbers from the user. Then write two function one that finds the SUM of the two numbers and one that finds the DIFFERENCE of the two numbers. Both functions should take in two parameters and return a value to the main program. 2. Write a program that takes in five numbers from the user (representing the 5 sides of a pentagon). Then write a function to find the PERIMETER of the pentagon. This function should take in the side lengths as parameters and return the perimeter to the main program. 3. Write a program that takes in three numbers from the user and finds the average. This program should contain a function that takes in three values as parameters and returns the average to the calling program.
68 Write a Program that does the following 4. Write a program that takes in the lengths of the two bases and the height of a trapezoid and calculates its area. This program should contain a function that takes in the three values as parameters and returns the area (A = ½ *h*(b1+b2)) 5. Write a program that takes in three numbers from the user (3 side lengths of a triangle). Then write a function that finds the area of the triangle using Heron s formula below (s = half the perimeter and is used to find the area). s = (a + b + c) / 2 A = s(s - a)(s - b)(s - c)
69
70 DAY 5 Combining Structure Programming with Control Structures (if and loops)
71 I can.. Use control structures (loops and conditionals) with function calls.
72 Example Program 1 Roll two dice until get a roll of 2 (snake eyes each die is a 1) Track how many rolls it takes to roll snake eyes Print the number of rolls to the screen
73 Example Program 1 - Code from random import randrange def main(): roll = 0 rolltotal = 0 while rolltotal!= 2 : rolltotal = rolldice() roll = roll + 1 print( It took, roll, rolls to get snake eyes )
74 Example Program 1 Code (pg 2) def rolldice(): roll1 = randrange(1, 7) roll2 = randrange(1, 7) rolltotal = roll1 + roll2 return rolltotal main()
75 Example Program 2 Takes in a number States whether the number is even or odd (using a function)
76 Example Program 2 - Code def main(): number = eval(input( Please enter in a number: )) evenodd = evenorodd(number) print( Your number is, evenodd) def evenorodd(number): if number%2 == 0: return even else : return odd main()
77 Write a Program that does the following 1. Write a program that takes in 2 numbers from a user. Your program should then send these two values into a function as parameters. The function should find the sum of ALL of the numbers between these two values. **Extension have a second function to calculate the sum of all the odd numbers and a third function to calculate the sum of all the even numbers between these as well** 2. Write a program that find the average of 5 test scores. Your program should have one function that finds the sum of all 5 test scores and returns the sum to the main program. Your program should then have a second function that finds the average of all the test scores and returns the average to the main program.
78 Write a Program that does the following 3. Write a program that finds the slope between two points entered in by the user (x1, y1) and (x2, y2). Your program should have a function that checks whether x1 and x2 are the same. If the are, the slope should not be calculated (0 in denominator will throw an error). If they are NOT the same, the slope of the line should be calculated. Use the equation below. Slope = y2 y1 x2 x1 4. Write a program that simulates a coin flip. The user of the program should enter in how many times a coin should flip. Your program should have a function that simulates a coin flip and returns the result of a flip. **Extension design your program so that it will ask the user if they want to play again after the simulation has occurred. If they choose to play again the program will run again with all values reset, if they choose to quit the game will simply end.
79
80 Program 5 How many items did you buy Cycles through item prices and finds sum Asks for tax Calculates total cost Asks user if they want to play again Widgets and Dodads project
81 EXTRA Write a program that draws a circle to the screen. The program should take in an (x, y) coordinate for the center of the circle, the radius, and the color of the circle from the user. This program should then contain a function that takes in these parameters and draws the appropriate circle to the screen.
Functions. Learning Outcomes 10/1/2012. CMSC 201 Fall 2012 Instructor: John Park Lecture Section 01 Discussion Sections 02-08, 16, 17
Functions CMSC 201 Fall 2012 Instructor: John Park Lecture Section 01 Discussion Sections 02-08, 16, 17 1 Adapted from slides by Sue Evans et al. 2 Learning Outcomes Understand why programmers divide programs
More informationChapter 3 Problem Solving and the Computer
Chapter 3 Problem Solving and the Computer An algorithm is a step-by-step operations that the CPU must execute in order to solve a problem, or to perform that task. A program is the specification of an
More informationCS 115 Exam 1, Fall 2015 Thu. 09/24/2015
CS 115 Exam 1, Fall 2015 Thu. 09/24/2015 Name: Section: Rules and Hints You may use one handwritten 8.5 11 cheat sheet (front and back). This is the only additional resource you may consult during this
More informationCMSC201 Computer Science I for Majors
CMSC201 Computer Science I for Majors Lecture 10 Functions Last Class We Covered The string data type Built-in functions Slicing and concatenation Escape sequences lower() and upper() strip() and whitespace
More informationIntro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming
Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals
More informationCMSC201 Computer Science I for Majors
CMSC201 Computer Science I for Majors Lecture 13 Functions Prof. Jeremy Dixon Based on concepts from: http://mcsp.wartburg.edu/zelle/python/ppics2/index.html Last Class We Covered Midterm exam Comments?
More information5th Grade Mathematics Essential Standards
Standard 1 Number Sense (10-20% of ISTEP/Acuity) Students compute with whole numbers*, decimals, and fractions and understand the relationship among decimals, fractions, and percents. They understand the
More informationArchdiocese of Washington Catholic Schools Academic Standards Mathematics
5 th GRADE Archdiocese of Washington Catholic Schools Standard 1 - Number Sense Students compute with whole numbers*, decimals, and fractions and understand the relationship among decimals, fractions,
More informationREPRESENTING ALGORITHMS. REPRESENTING ALGORITHMS IB DP Computer science Standard Level ICS3U
C A N A D I A N I N T E R N A T I O N A L S C H O O L O F H O N G K O N G 2.1 Introduction 2.2 Representing Algorithms algorithm should be clear, precise, and unambiguous one possibility is to use the
More informationPart 1 Arithmetic Operator Precedence
California State University, Sacramento College of Engineering and Computer Science Computer Science 10: Introduction to Programming Logic Activity C Expressions Computers were originally designed for
More informationUNIT 5. String Functions and Random Numbers
UNIT 5 String Functions and Random Numbers DAY 1 String data type String storage in data String indexing I can.. Explain the purpose of the string variable type and how it is stored in memory. Explain
More informationName ANSWER KEY Date Period Score. Place your answers in the answer column. Show work clearly and neatly. FOCUS ON WHAT IS NECESSARY FOR SUCCESS!
OAKS Test Review PRACTICE Name ANSWER KEY Date Period Score Place your answers in the answer column. Show work clearly and neatly. FOCUS ON WHAT IS NECESSARY FOR SUCCESS! Solve:. n = 5. 4(4x ) = (x + 4)
More informationMy 5 th Grade Summer Math Practice Booklet
My 5 th Grade Summer Math Practice Booklet Name Number Sense 1. Write a ratio (fraction) comparing the number of rectangles to the number of triangles. Then write a ratio (fraction) comparing the number
More informationIntroduction to Java Unit 1. Using BlueJ to Write Programs
Introduction to Java Unit 1. Using BlueJ to Write Programs 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save
More informationCourse Outlines. Elementary Mathematics (Grades K-5) Kids and Numbers (Recommended for K-1 students)
Course Outlines Elementary Mathematics (Grades K-5) Kids and Numbers (Recommended for K-1 students) Shapes and Patterns. Grouping objects by similar properties. Identifying simple figures within a complex
More informationIntroduction to Computer Science with Python Course Syllabus
CodeHS Introduction to Computer Science with Python Course Syllabus Course Overview and Goals The CodeHS Introduction to Computer Science in Python course teaches the fundamentals of computer programming
More informationIndividual research task. You should all have completed the research task set last week. Please make sure you hand it in today.
Lecture 6 Individual research task. You should all have completed the research task set last week. Please make sure you hand it in today. Previously Decision structures with flowcharts Boolean logic UML
More informationDecisions, Decisions. Testing, testing C H A P T E R 7
C H A P T E R 7 In the first few chapters, we saw some of the basic building blocks of a program. We can now make a program with input, processing, and output. We can even make our input and output a little
More informationSUMMER REVIEW PACKET 2 FOR STUDENTS ENTERING ALGEBRA 1
SUMMER REVIEW PACKET FOR STUDENTS ENTERING ALGEBRA Dear Students, Welcome to Ma ayanot. We are very happy that you will be with us in the Fall. The Math department is looking forward to working with you
More informationIntroduction to Computer Programming for Non-Majors
Introduction to Computer Programming for Non-Majors CSC 2301, Fall 2015 Chapter 6 Part 1 The Department of Computer Science Objectives 2 To understand why programmers divide programs up into sets of cooperating
More informationThe births of the generations are as follow. First generation, 1945 machine language Second generation, mid 1950s assembly language.
Lesson Outcomes At the end of this chapter, student should be able to: Describe what a computer program is Explain the importance of programming to computer use Appreciate the importance of good programs
More informationAdministrativia. CS107 Introduction to Computer Science. Readings. Algorithms. Expressing algorithms
CS107 Introduction to Computer Science Lecture 2 An Introduction to Algorithms: and Conditionals Administrativia Lab access Searles 128: Mon-Friday 8-5pm (unless class in progress) and 6-10pm Sat, Sun
More informationWhole Numbers. Integers and Temperature
Whole Numbers Know the meaning of count and be able to count Know that a whole number is a normal counting number such as 0, 1, 2, 3, 4, Know the meanings of even number and odd number Know that approximating
More informationChapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved.
Chapter 4 Procedural Abstraction and Functions That Return a Value Overview 4.1 Top-Down Design 4.2 Predefined Functions 4.3 Programmer-Defined Functions 4.4 Procedural Abstraction 4.5 Local Variables
More informationChapter 2: Data and Expressions
Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University August 21, 2017 Chapter 2: Data and Expressions CS 121 1 / 51 Chapter 1 Terminology Review
More informationWriting and Understanding C++
Writing and Understanding C++ Writing programs in any language requires understanding the syntax and semantics of the programming language as well as language-independent skills in programming. Syntax
More informationChapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1
Chapter 2 Input, Processing, and Output Fall 2016, CSUS Designing a Program Chapter 2.1 1 Algorithms They are the logic on how to do something how to compute the value of Pi how to delete a file how to
More information3.2 Graphs of Linear Equations
3.2 Graphs of Linear Equations Learning Objectives Graph a linear function using an equation. Write equations and graph horizontal and vertical lines. Analyze graphs of linear functions and read conversion
More informationChapter 3: Functions
Chapter 3: Functions Index: A: Introduction to Functions 1 Page 2 B: Introduction to Functions 2 (U3 L1) Page 8 C: Function Notation (U3 L2) Page 13 D: Graphs of Functions (U3 L3) Page 18 E: Graphical
More informationBasics of Programming with Python
Basics of Programming with Python A gentle guide to writing simple programs Robert Montante 1 Topics Part 3 Obtaining Python Interactive use Variables Programs in files Data types Decision-making Functions
More informationProgramming Practice (vs Principles)
Programming Practice (vs Principles) Programming in any language involves syntax (with rules, parentheses, etc) as well as format (layout, spacing, style, etc). Syntax is usually very strict, and any small
More informationComputer and Programming: Lab 1
01204111 Computer and Programming: Lab 1 Name ID Section Goals To get familiar with Wing IDE and learn common mistakes with programming in Python To practice using Python interactively through Python Shell
More informationLesson 2. Introducing Apps. In this lesson, you ll unlock the true power of your computer by learning to use apps!
Lesson 2 Introducing Apps In this lesson, you ll unlock the true power of your computer by learning to use apps! So What Is an App?...258 Did Someone Say Free?... 259 The Microsoft Solitaire Collection
More information1.1 Defining Functions
1.1 Defining Functions Functions govern many interactions in our society today. Whether buying a cup of coffee at the local coffee shop or playing a video game, we are using a function in some fashion.
More informationVariable A variable is a value that can change during the execution of a program.
Declare and use variables and constants Variable A variable is a value that can change during the execution of a program. Constant A constant is a value that is set when the program initializes and does
More informationIntro. to Computing. Lecture 7 Page1
1. Read sections 6.1 and 6.2 of the textbook. A function is a procedural abstract, i.e., a named body of code that performs some task when it is called/invoked. Often a function will have one or more parameter
More informationI can use number bonds and matching subtraction facts up to 20.
Year 1, Maths end of year expectations I can count to and past 100. Forwards and backwards starting from any number. I can count, read and write numbers to 100 in numerals and count in jumps of 2, 5 and
More informationGrades 7 & 8, Math Circles 20/21/22 February, D Geometry Solutions
Faculty of Mathematics Waterloo, Ontario NL 3G1 Centre for Education in Mathematics and Computing D Geometry Review Grades 7 & 8, Math Circles 0/1/ February, 018 3D Geometry Solutions Two-dimensional shapes
More informationText Input and Conditionals
Text Input and Conditionals Text Input Many programs allow the user to enter information, like a username and password. Python makes taking input from the user seamless with a single line of code: input()
More informationFunctions: Decomposition And Code Reuse
Functions: Decomposition And Code Reuse This section of notes shows you how to write functions that can be used to: decompose large problems, and to reduce program size by creating reusable sections. Tip
More informationMath 8 SOL Review
Math 8 SOL Review 2011-2012 SOL 8.1 The student will a) simplify numerical expressions involving positive exponents, using rational numbers, order of operations, and properties of operations with real
More informationProblem Solving With C++ Ninth Edition
CISC 1600/1610 Computer Science I Programming in C++ Professor Daniel Leeds dleeds@fordham.edu JMH 328A Introduction to programming with C++ Learn Fundamental programming concepts Key techniques Basic
More informationWriting and Understanding C++
Writing and Understanding C++ There are language independent skills in programming (C++, Java, ) However, writing programs in any language requires understanding the syntax and semantics of the programming
More informationADW GRADE 3 Math Standards, revised 2017 NUMBER SENSE (NS)
NUMBER SENSE (NS) Students understand the relationships among the numbers, quantities and place value in whole numbers up to 1,000. They understand the relationship among whole numbers, simple fractions
More informationGlossary Flash Cards. acute angle. absolute value. Additive Inverse Property. Big Ideas Math Red
Glossary Flash Cards absolute value acute angle Addition Property of Equality additive inverse Additive Inverse Property angle Copyright Big Ideas Learning, LLC Big Ideas Math Red 1 An angle whose measure
More informationROCHESTER COMMUNITY SCHOOL MATHEMATICS SCOPE AND SEQUENCE, K-5 STRAND: NUMERATION
STRAND: NUMERATION Shows one-to-one correspondence for numbers 1-30 using objects and pictures Uses objects and pictures to show numbers 1 to 30 Counts by 1s to 100 Counts by 10s to 100 Counts backwards
More informationStratford upon Avon School Mathematics Homework Booklet
Stratford upon Avon School Mathematics Homework Booklet Year: 7 Scheme: 1 Term: 1 Name: Show your working out here Homework Sheet 1 1: Write 7:43 pm using the 24 hour clock 11: Find the area of this shape.
More informationExpression and Equations
7 CHAPTER Expression and Equations Basic Concepts In algebra, letters are used as variables. A variable can assume values of numbers. Numbers are called constants. Math Note: In some cases, a letter may
More informationRETURN X return X Returning a value from within a function: computes the value of variable exits the function and returns the value of the variable
STUDENT TEACHER CLASS WORKING AT GRADE TERM TARGET YEAR TARGET Pseudocode Python Description BEGIN END Identifies the start of a program Identifies the end of a program READ X, Y, Z input() Identifies
More informationCONDITION CONTROLLED LOOPS. Introduction to Programming - Python
CONDITION CONTROLLED LOOPS Introduction to Programming - Python Generating Random Numbers Generating a random integer Sometimes you need your program to generate information that isn t available when you
More informationFamily Literacy. readers. Easy Algebra Reading Practice
Family Literacy readers Easy Algebra Reading Practice UNIT 2 Integers and Expressions 2.0 A Review of Unit 1 preface About Family Literacy Algebra Prep Readers These readers are not intended to be a complete
More informationPage 1 CCM6+7+ UNIT 9 GEOMETRY 2D and 3D 2D & 3D GEOMETRY PERIMETER/CIRCUMFERENCE & AREA SURFACE AREA & VOLUME
Page 1 CCM6+7+ UNIT 9 GEOMETRY 2D and 3D UNIT 9 2016-17 2D & 3D GEOMETRY PERIMETER/CIRCUMFERENCE & AREA SURFACE AREA & VOLUME CCM6+7+ Name: Math Teacher: Projected Test Date: MAIN CONCEPT(S) PAGE(S) Vocabulary
More informationIntroduction to Python (All the Basic Stuff)
Introduction to Python (All the Basic Stuff) 1 Learning Objectives Python program development Command line, IDEs, file editing Language fundamentals Types & variables Expressions I/O Control flow Functions
More informationWeek One: Introduction A SHORT INTRODUCTION TO HARDWARE, SOFTWARE, AND ALGORITHM DEVELOPMENT
Week One: Introduction A SHORT INTRODUCTION TO HARDWARE, SOFTWARE, AND ALGORITHM DEVELOPMENT Outline In this chapter you will learn: About computer hardware, software and programming How to write and execute
More informationLecture 7: Functions. CS1068+ Introductory Programming in Python. Dr Kieran T. Herley 2018/19. Department of Computer Science University College Cork
Lecture 7: Functions CS1068+ Introductory Programming in Python Dr Kieran T. Herley 2018/19 Department of Computer Science University College Cork Summary Functions in Python. Terminology and execution.
More informationCollege Readiness (597 topics) Course Name: College Prep Math Spring 2014 Course Code: ARTD4-3N6XJ
Course Name: College Prep Math Spring 2014 Course Code: ARTD4-3N6XJ ALEKS Course: Math for College Readiness Instructor: Ms. Dalton Course Dates: Begin: 01/19/2015 End: 06/18/2015 Course Content: 606 Topics
More informationLinby Primary School Targets Ladder. Linby Primary School Targets Ladder
Target Sheet 1a I can read numbers to 10 (1, 2, 3 etc) written as digits 1,2,3,.Make sure you can do this out of order (5, 9, 2) I can count up to 10 objects accurately and consistently. (Both things that
More informationWelcome to Python 3. Some history
Python 3 Welcome to Python 3 Some history Python was created in the late 1980s by Guido van Rossum In December 1989 is when it was implemented Python 3 was released in December of 2008 It is not backward
More informationMath A Regents Exam 0601 Page 1
Math A Regents Exam 0601 Page 1 1. 060101a, P.I. A.A.1 A car travels 110 miles in hours. At the same rate of speed, how far will the car travel in h hours? [A] 55h [B] 0h [C]. 06010a, P.I. A.A.14 h 0 Which
More informationIntroduction to computers and Python. Matthieu Choplin
Introduction to computers and Python Matthieu Choplin matthieu.choplin@city.ac.uk http://moodle.city.ac.uk/ 1 Objectives To get a brief overview of what Python is To understand computer basics and programs
More informationPosition. By the end of the year, it is expected that children will be able to sequence events in chronological order. My Numeracy Targets Year 1
My Numeracy Targets Year 1 Number and place value Multiplication and Division Addition and subtraction I can count up and down from 0 to 100 and more. I can count, read and write numbers up to 100. I can
More informationFunctions: Decomposition And Code Reuse
Programming: problem decomposition into functions 1 Functions: Decomposition And Code Reuse This section of notes shows you how to write functions that can be used to: decompose large problems, and to
More informationWHOLE NUMBER AND DECIMAL OPERATIONS
WHOLE NUMBER AND DECIMAL OPERATIONS Whole Number Place Value : 5,854,902 = Ten thousands thousands millions Hundred thousands Ten thousands Adding & Subtracting Decimals : Line up the decimals vertically.
More information(f) d={ alchemist :( a, t ), shaman : ( s, n ), wizard : ( w, z )} d[ shaman ][1]
CSCI1101 Final Exam December 18, 2018 Solutions 1. Determine the value and type of each of the expressions below. If the question has two lines, assume that the statement in the first line is executed,
More informationProgramming Logic and Design Seventh Edition Chapter 2 Elements of High-Quality Programs
Programming Logic and Design Chapter 2 Elements of High-Quality Programs Objectives In this chapter, you will learn about: Declaring and using variables and constants Assigning values to variables [assignment
More informationTry typing the following in the Python shell and press return after each calculation. Write the answer the program displays next to the sums below.
Name: Date: Instructions: PYTHON - INTRODUCTORY TASKS Open Idle (the program we will be using to write our Python codes). We can use the following code in Python to work out numeracy calculations. Try
More informationCMSC201 Computer Science I for Majors
CMSC201 Computer Science I for Majors Lecture 09 For Loops All materials copyright UMBC unless otherwise noted Last Class We Covered Lists and what they are used for Operations a list can perform Including
More informationNMC Sample Problems: Grade 8
NM Sample Problems: Grade 8. right triangle has side lengths of 4 and 8. What is the length of the hypotenuse (the longest side)? 4 0 4 4. n isosceles triangle has a base length of 0 and a side length.
More informationIntro. Scheme Basics. scm> 5 5. scm>
Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if
More informationLecture 04 FUNCTIONS AND ARRAYS
Lecture 04 FUNCTIONS AND ARRAYS 1 Motivations Divide hug tasks to blocks: divide programs up into sets of cooperating functions. Define new functions with function calls and parameter passing. Use functions
More informationn! = 1 * 2 * 3 * 4 * * (n-1) * n
The Beauty and Joy of Computing 1 Lab Exercise 9: Problem self-similarity and recursion Objectives By completing this lab exercise, you should learn to Recognize simple self-similar problems which are
More informationGENERAL MATH FOR PASSING
GENERAL MATH FOR PASSING Your math and problem solving skills will be a key element in achieving a passing score on your exam. It will be necessary to brush up on your math and problem solving skills.
More informationHello, World! EMT1111: Logic and Problem Solving Fall 2016 Dr. Mendoza
Hello, World! EMT1111: Logic and Problem Solving Fall 2016 Dr. Mendoza LESSON 4 (Labs): Python Overview IV SIMPLE PYTHON PROGRAMS II Lab Assignment 1 (poem2.py) Put the blocks below into the correct order
More informationUnit II. (i) Computer Programming Languages
Unit II. (i) Computer Programming Languages Need of a computer programming language: A programming language is an artificial language designed to communicate instructions to a computer. Thousands of different
More informationThis is a function because no vertical line can be drawn so that it intersects the graph more than once.
Determine whether each relation is a function. Explain. 1. A function is a relation in which each element of the domain is paired with exactly one element of the range. So, this relation is a function.
More informationMental Math. Grade 9 Mathematics (10F) General Questions. test, what percentage of students obtained at least 50% on the test?
F 1 Specific Learning Outcome: 9.SS.4 1. Add: -4 + 3.1-9.3 2. If 19 out of 20 students obtained at least 15 on the last mathematics 30 test, what percentage of students obtained at least 50% on the test?
More informationLab 2: Booleans, Strings, Random Numbers, Recursion, Variables, Input function
Lab 2: Booleans, Strings, Random Numbers, Recursion, Variables, Input function Due: Mar25 (Note that this is a 2-week lab) This lab must be done using paired partners. You should choose a different partner
More information2500( ) ( ) ( ) 3
Name: *Don't forget to use your Vertical Line Test! Mr. Smith invested $,00 in a savings account that earns % interest compounded annually. He made no additional deposits or withdrawals. Which expression
More information1. POSITION AND SORTING Kindergarten
MATH CURRICULUM KINDERGARTEN 1. POSITION AND SORTING Kindergarten A. Position and Location 1. use the words inside and outside to describe the position of objects. 2. use the words over, under, and on
More informationappend() function, 66 appending, 65, 97, 296 applications (apps; programs), defined, 2, 296
Index Note: Page numbers followed by f, n, or t indicate figures, notes, and tables, respectively. Symbols += (addition and assignment operator), 100, 187 + (addition operator), \ (backslash), 240 / (division
More information1.0 Fractions Review Name: Date: Goal: to review some key fractions skills in preparation for the upcoming unit. Main Ideas: b)!!
1.0 Fractions Review Name: Date: Goal: to review some key fractions skills in preparation for the upcoming unit Toolkit: Working with integers Operations with fractions Main Ideas: Reducing Fractions To
More informationUnit 4 End-of-Unit Assessment Study Guide
Circles Unit 4 End-of-Unit Assessment Study Guide Definitions Radius (r) = distance from the center of a circle to the circle s edge Diameter (d) = distance across a circle, from edge to edge, through
More information06/11/2014. Subjects. CS Applied Robotics Lab Gerardo Carmona :: makeroboticsprojects.com June / ) Beginning with Python
CS95003 - Applied Robotics Lab Gerardo Carmona :: makeroboticsprojects.com June / 2014 Subjects 1) Beginning with Python 2) Variables 3) Strings 4) Basic arithmetic operators 5) Flow control 6) Comparison
More informationMaths Target Wall Year 1
Maths Target Wall Year 1 I can count up and down from 0 to 100 and more. I can count, read and write numbers up to 100. I can count in 2 or 5 or 10 When you show me a number, I can tell you what is one
More informationMiddle School Summer Review Packet for Abbott and Orchard Lake Middle School Grade 7
Middle School Summer Review Packet for Abbott and Orchard Lake Middle School Grade 7 Page 1 6/3/2014 Area and Perimeter of Polygons Area is the number of square units in a flat region. The formulas to
More informationMiddle School Summer Review Packet for Abbott and Orchard Lake Middle School Grade 7
Middle School Summer Review Packet for Abbott and Orchard Lake Middle School Grade 7 Page 1 6/3/2014 Area and Perimeter of Polygons Area is the number of square units in a flat region. The formulas to
More informationSoftware Development Pseudocode
Software Development Pseudocode Software Development: Pseudocode Task 1 Task 1 Students are graded out of 10 for assignments. A+ 10 A 9 B+ 8 B 7 C+ 6 C 5 D+ 4 D 3 E+ 2 E 1 Fail 0 This is the current pseudocode
More informationIntro to Python Programming
Intro to Python Programming If you re using chromebooks at your school, you can use an online editor called Trinket to code in Python, and you ll have an online portfolio of your projects which you can
More informationChapter Procedural Abstraction and Functions That Return a Value. Overview. Top-Down Design. Benefits of Top Down Design.
Chapter 4 Procedural Abstraction and Functions That Return a Value Overview 4.1 Top-Down Design 4.2 Predefined Functions 4.3 Programmer-Defined Functions 4.4 Procedural Abstraction 4.5 Local Variables
More informationChapter 4. Procedural Abstraction and Functions That Return a Value
Chapter 4 Procedural Abstraction and Functions That Return a Value Overview 4.1 Top-Down Design 4.2 Predefined Functions 4.3 Programmer-Defined Functions 4.4 Procedural Abstraction 4.5 Local Variables
More information2009 Fall Startup Event Thursday, September 24th, 2009
009 Fall Startup Event This test consists of 00 problems to be solved in 0 minutes. All answers must be exact, complete, and in simplest form. To ensure consistent grading, if you get a decimal, mixed
More informationAP CSA 3rd Period MR. D. Course Map
AP CSA 3rd Period MR. D. Course Map AP Computer Science in Java (Mocha) Aug. 10, Aug. 11, Aug. 14, Aug. 15, 1.1.1 Introduction to With Karel 1.1.2 Quiz: Karel Commands 1.1.3 Our First Karel Program 1.1.4
More informationI can fluently multiply within 100 using strategies and properties. (i.e., associative property of multiplication; basic facts) I/E R R
FOURTH GRADE BROKEN ARROW MATH 1 2 3 Operations and Algebraic Thinking: Use the four operations with whole numbers to solve problems *BA 1 I can explain how a multiplication equation can be used to compare.
More informationProgramming with Python
Programming with Python Dr Ben Dudson Department of Physics, University of York 21st January 2011 http://www-users.york.ac.uk/ bd512/teaching.shtml Dr Ben Dudson Introduction to Programming - Lecture 2
More informationPerimeter, Area, Surface Area, & Volume
Additional Options: Hide Multiple Choice Answers (Written Response) Open in Microsoft Word (add page breaks and/or edit questions) Generation Date: 11/25/2009 Generated By: Margaret Buell Copyright 2009
More informationMath 1201 Unit 5: Relations & Functions. Ch. 5 Notes
Math 1201 Unit 5: Relations & Functions Read Building On, Big Ideas, and New Vocabulary, p. 254 text. 5.1 Representing Relations (0.5 class) Read Lesson Focus p. 256 text. Outcomes Ch. 5 Notes 1. Define
More informationCe qui est important dans l'enseignement des mathématiques. Marian Small novembre 2017
Ce qui est important dans l'enseignement des mathématiques Marian Small novembre 2017 Playing with math Uae your linking cubes. Show that the mean of 4, 7 and 7 is 6. Playing with math Uae your linking
More informationPage 1 CCM6+ Unit 10 Graphing UNIT 10 COORDINATE PLANE. CCM Name: Math Teacher: Projected Test Date:
Page 1 CCM6+ Unit 10 Graphing UNIT 10 COORDINATE PLANE CCM6+ 2015-16 Name: Math Teacher: Projected Test Date: Main Concept Page(s) Vocabulary 2 Coordinate Plane Introduction graph and 3-6 label Reflect
More informationChapter 2 Writing Simple Programs
Chapter 2 Writing Simple Programs Charles Severance Textbook: Python Programming: An Introduction to Computer Science, John Zelle (www.si182.com) Software Development Process Figure out the problem - for
More informationCISC 110 Week 3. Expressions, Statements, Programming Style, and Test Review
CISC 110 Week 3 Expressions, Statements, Programming Style, and Test Review Today Review last week Expressions/Statements Programming Style Reading/writing IO Test review! Trace Statements Purpose is to
More information