IST256 : Applications Programming for Information Systems

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Modular Programming With Functions
CS0004: Introduction to Programming Repetition – Do Loops.
Loops (Part 1) Computer Science Erwin High School Fall 2014.
C Lecture Notes 1 Program Control (Cont...). C Lecture Notes 2 4.8The do / while Repetition Structure The do / while repetition structure –Similar to.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 5 - Functions Outline 5.1Introduction 5.2Program.
COMP 14 Introduction to Programming Miguel A. Otaduy May 25, 2004.
Python November 18, Unit 7. So Far We can get user input We can create variables We can convert values from one type to another using functions We can.
Chapter 2 Writing Simple Programs
FunctionsFunctions Systems Programming Concepts. Functions   Simple Function Example   Function Prototype and Declaration   Math Library Functions.
Functions and subroutines – Computer and Programming.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. C How To Program - 4th edition Deitels Class 05 University.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 3 Simple.
CSCI 130 Chapter 5 Functions. Functions are named uniquely Performs a specific task Is independent –should not interfere with other parts of program May.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Functions.
How to start Visual Studio 2008 or 2010 (command-line program)
Functions, Procedures, and Abstraction Dr. José M. Reyes Álamo.
Writing JavaScript Functions. Goals By the end of this unit, you should understand … How to breakdown applications into individual, re-usable modules.
A First Book of ANSI C, Fourth Edition1 Functions for Modularity 04/24/15.
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
Python uses boolean variables to evaluate conditions. The boolean values True and False are returned when an expression is compared or evaluated.
Structured Program Development Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010.
Procedural Programming Criteria: P2 Task: 1.2 Thomas Jazwinski.
1 Chapter 6 Methods. 2 Motivation Find the sum of integers from 1 to 10, from 20 to 30, and from 35 to 45, respectively.
INLS 560 – F UNCTIONS Instructor: Jason Carter.
1 Printing in Python Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external files.
GCSE Computing: Programming GCSE Programming Remembering Python.
Midterm Review Important control structures Functions Loops Conditionals Important things to review Binary Boolean operators (and, or, not) Libraries (import.
Introduction to Functions CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Controlling Program Flow with Decision Structures.
Review Expressions and operators Iteration – while-loop – for-loop.
Why Repetition? Read 8 real numbers and compute their average REAL X1, X2, X3, X4, X5, X6, X7, X8 REAL SUM, AVG READ *, X1, X2, X3, X4, X5, X6, X7, X8.
Functions in C++ Top Down Design with Functions. Top-down Design Big picture first broken down into smaller pieces.
A First Book of ANSI C Fourth Edition
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
Chapter 6 Functions The Tic-Tac-Toe Game. Chapter Content In this chapter you will learn to do the following: 0 Write your own functions 0 Accept values.
Functions. What is a Function?  We have already used a few functions. Can you give some examples?  Some functions take a comma-separated list of arguments.
Python Programming Module 3 Functions Python Programming, 2/e1.
CSC 1010 Programming for All Lecture 5 Functions Some material based on material from Marty Stepp, Instructor, University of Washington.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 23, 2005 Lecture Number: 11.
Lesson 06: Functions Class Participation: Class Chat:
Fundamentals of Python: First Programs
Exam #1 You will have exactly 30 Mins to complete the exam.
IST256 : Applications Programming for Information Systems
Lesson 05: Iterations Class Chat: Attendance: Participation
Introduction to C++ Introduced by Bjarne Stroustrup of AT&T’s Bell Laboratories in mid-1980’s Based on C C++ extended C to support object-oriented programming.
JavaScript: Functions
Function There are two types of Function User Defined Function
Chapter 5 - Functions Outline 5.1 Introduction
Chapter 3 Simple Functions
Lesson 05: Iterations Topic: Introduction to Programming, Zybook Ch 4, P4E Ch 5. Slides on website.
Structured Program
IPC144 Introduction to Programming Using C Week 3 – Lesson 2
IST256 : Applications Programming for Information Systems
Lesson 06: Functions Class Chat: Attendance: Participation
Introduction to C++ Introduced by Bjarne Stroustrup of AT&T’s Bell Laboratories in mid-1980’s Based on C C++ extended C to support object-oriented programming.
ERRORS AND EXCEPTIONS Errors:
Module 4 Loops.
Lecture3.
Topics Introduction to Functions Defining and Calling a Void Function
Topics Introduction to Functions Defining and Calling a Function
IPC144 Introduction to Programming Using C Week 4 – Lesson 1
Basic Concepts of Algorithm
Methods/Functions.
IST256 : Applications Programming for Information Systems
Functions, Procedures, and Abstraction
CMPT 120 Lecture 13 – Unit 2 – Cryptography and Encryption –
REPETITION Why Repetition?
Scope Rules.
IST256 : Applications Programming for Information Systems
Presentation transcript:

IST256 : Applications Programming for Information Systems Functions

Agenda Connection Activity Teaching: Practice Activity Quiz 2, Homework Check Teaching: Functions, definitions, calls, named arguments, variable scope Practice Activity Name-Here

Quiz #2, HW Check Connect Activity After you turn in the quiz, Open number guessing game For a Homework Check

Functions A Functions are 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 a function call. Functions are designed to be written once, but called many times. Functions are like their own little programs. They take input, which we call the function arguments and give us back output that we refer to as return values. Arguments Function Return Values

Watch Me Code “I know a guy, his name is Terry” “Hey Lade, Lade, Lo!” “He got so hungry, he ate is canary” “99 Bottles of Beer on the wall” # this does not execute until called def chorus(): return "Hey Lade, Lade, Lo" # start of program print ("I know I guy his name is Terry") print (chorus()) print ("He got so hungry he ate his canary")

Check Yourself: 90 Second Challenge What is x(1,1,1) ? What is x(100,0,-100)? What is x(‘1’,’2’,’3’)? What is the name of this function? How many inputs does it have? How many outputs?

Watch Me Code Area and Perimeter of a rectangle. Concept: Named Arguments Introduce named arguments.

Function Variable Scope Variables defined outside any function are Global Variables. These are accessible from everywhere including inside function definitions. Variables defined inside a function are Local Variables, and are only accessible inside the function definition. Local variables with the same name take precedence over global variables

Check Yourself: 90 Second Challenge List the Global Variables List the variables local to x() What prints on line 7? Line 8? Line 9? Is the variable a on 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  F Then 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.