Functions as everyday items

Slides:



Advertisements
Similar presentations
Chapter 4 Constructors and Destructors. Objectives Constructors – introduction and features The zero-argument constructor Parameterized constructors Creating.
Advertisements

Spring Semester 2013 Lecture 5
Functions Prototypes, parameter passing, return values, activation frams.
Def f(n): if (n == 0): return else: print(“*”) return f(n-1) f(3)
CSC241 Object-Oriented Programming (OOP) Lecture No. 9.
Passing information through Parameters ( our setter methods or mutators) Formal Parameter – parameter in the method. public void SetA(int x){ (int x) is.
Lesson 16 Exceptions Lesson Exceptions1. Murphy’s Law Anything that can go wrong will go wrong Lesson Exceptions2.
Q and A for Chapter 3.4 – 3.14 CS 104 Victor Norman.
Functions That Do Not Return a Value 03/09/11. Reminders  Quiz 3 Friday Work with partner on for-loop activity. Work with partner on for-loop activity.
Diagrams of CAPM Chapter 10 figures. Correlation coefficient.
Wed/Fri Week 2 Functions! What are they? What do they look like in JavaScript? What are they good for? How do I use them? Some examples… Mini-Lab 1!!!
Macro & Function. Function consumes more time When a function is called, the copy of the arguments are passed to the parameters in the function. After.
CS 31 Discussion, Week 4 Faisal Alquaddoomi, Office Hours: BH 2432, MW 4:30-6:30pm, F 12:30-1:30pm (today)
Functions Art &Technology, 3rd Semester Aalborg University Programming David Meredith
Overview of Project 5 Slides are available at : Project will be checked off in class
Luke Plourde. My Scenario I was recently shopping at the local grocery store and Was at the customer service counter returning an appliance with my mother,
Lecture 15: Projects Using Similar Data. What is an Array? An array is a data structure consisting of related data items of the same type. Stored in a.
1 Structure of a C Program (continued) Presentation original from Dr. Turner’s class USF - COP C for Engineers Summer 2008.
More about Java Classes Writing your own Java Classes More about constructors and creating objects.
Department of Electronic & Electrical Engineering Functions Parameters Arguments Pointers/dereference & * Scope Global/Local Storage Static/Automatic.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
Lists in Python Lists as Arguments/Parameters. Lists as arguments to functions Just like other data types, lists can be sent to functions as arguments.
Engine Update time Update World List World List contains all of the objects/signals in the world state Factory Class State Machine Factory Lift Factory.
COSC 1223 Computer Science Concepts I Joe Bryan. What is a function? Like a mini-program that performs a specific task Two types: Built-in functions Functions.
Quiz 3 Topics Functions – using and writing. Lists: –operators used with lists. –keywords used with lists. –BIF’s used with lists. –list methods. Loops.
CPSC 221 Call by value, pointer and reference in C++ Page 1 Hassan Khosravi January – April 2015 CPSC 221 Basic Algorithms and Data Structures Call by.
Solar and Lunar Eclipses
How do they work? Why protect them? What can we do to look after them?
Chapter 10: Void Functions
Solar and Lunar Eclipses
Advanced Programming Behnam Hatami Fall 2017.
More on Functions ANSI-C.
Call Stacks, Arguments and Returns
6A will / won’t (predictions)
Default Argument.
Solar and Lunar Eclipses
Pointers & Functions.
Passing Parameters by value
Anatomy of a Function Part 1
Example 1.
How Objects Behave Chapter 4.
Nate Brunelle Today: Functions again, Scope
Program Flow Control Selection & repetition
Array and Method.
Private.
Functions Pass By Value Pass by Reference
Pointers.
Microscope Notes BRING IN 10 items from home
Encapsulation in Alloy
Ball meets Paddle.
Krisp Tips How to build a Feedback-Rich Culture.
Nate Brunelle Today: Functions
Method of Classes Chapter 7, page 155 Lecture /4/6.
Notes from Week 5 CSE 115 Spring 2006 February 13, 15 & 17, 2006.
Traffic Light.
Seoul National University
Pointers & Functions.
Anatomy of a Function Part 1
Light and shadows.
Unit-1 Introduction to Java
Solar and Lunar Eclipses
Nate Brunelle Today: Functions
Nate Brunelle Today: Functions again, Scope
Object-Oriented Design AND CLASS PROPERTIES
Functions That Do Not Return a Value
Transparent objects allow you to see clearly through them
Light and Shadows.
Runtime Stack Activation record for hanoi;
C Parameter Passing.
Chapter 4 Test Review First day
Presentation transcript:

Functions as everyday items

def donation_box(coin): Do you get anything back (directly)? No. So this is a void function.

def recycling_bin(paper, plastic, other): Do you get anything back (directly)? No. So this is a void function.

def gumball_machine(coin): Do you get anything back (directly)? Yes, candy! So this is a value-returning function.

def traffic_light(): Clearly you don’t pass anything to the traffic light, so no arguments and hence no parameters, but do you get something from “using” the traffic light? Yes, a traffic signal. So this is a value-returning function.