Publications: 97 | Followers: 0

## _-Functions

Publish on Category: Birds 0

IST256 :Applications Programming for Information Systems
Functions
Agenda
ConnectionActivityQuiz 2, Homework CheckTeaching:Functions, definitions, calls, named arguments, variable scopePractice ActivityName-Here
Connect Activity
Quiz#2,HW CheckAfter you turn in the quiz,Opennumber guessing gameFor a Homework Check
AFunctionsare a named sequence of statements which accomplish a task. They promote modularity, making our code less complex and encourage code-reuse.When you “run” a defined function it’s known as afunction call. Functions are designed to bewritten once, butcalled many times.Functions are like their own little programs. They take input, which we call thefunction argumentsand give us back output that we refer to asreturn values.
Functions
Watch Me Code
“I know aguy, his name is Terry”“Hey Lade, Lade, Lo!”“He got so hungry, he ate is canary”“Hey Lade, Lade, Lo!”“99 Bottles of Beer on the wall”
Check Yourself: 90 Second Challenge
What is the name of this function?How many inputs does it have?How many outputs?
What isx(1,1,1)?What isx(100,0,-100)?What isx(‘1’,’2’,’3’)?
Watch Me Code
Area and Perimeter of a rectangle.Concept: Named Arguments
Variables defined outsideanyfunction areGlobalVariables.Theseareaccessiblefrom everywhereincluding inside function definitions.Variables defined inside a function areLocal Variables, and are only accessible inside the function definition.Local variables with the same nametake precedence overglobalvariables
Function VariableScope
Check Yourself: 90 Second Challenge
List the Global VariablesList the variables local tox()What prints on line 7?Line 8?Line 9?Is the variableaon lines 2 and 6 the same? Explain.
Help me Code
Grade Calculator:Write a function to calculate a letter grade given a number grade 0-100 based on this scale:>=90 A |>=80  B |>=70  C |Else  FThen write a program to input a number grade and output a letter grade.
Now You Code
Write a function to convert miles to KM and write another function to convert KM to miles.Test your functions by writing a program:It should input a distance value as a float and input a unit (either KM or Miles)It then outputs the converted value. If you enter miles, it converts to KM, for example.It should repeat this process until a ZERO is entered for a unit.
Conclusion Activity
Your “Ticket Out”Take out a piece of paper.Print your name at the topWrite down ONE THING on the paper you learned today.My TA’s will collect your paper on the way out.The activity will beeffort graded.

0

Embed

Share

Upload

Make amazing presentation for free
_-Functions