SlideShare a Scribd company logo
UNIT 3
ALGORITHM &
PROGRAMMING
Created by Mr. Nidal Saleh
Recall from previous session
 Function: also known as method/procedure which
is a set of commands that can be called again and
over again.
 Benefits of Function?
 Define Function then Call the Function to Execute
 Define one function inside another function
 Function is a form of Abstraction finding one
solution for multiple problems.
 Function use Top Down approach breaking down
big problems to sub problems.
LESSON OBJECTIVES
Students will:
 Learn to read App Lab’s API documentation
 Use functions that accept parameters in order
to complete a series of drawing puzzles
 Design a personal monogram making use of
the commands you learned during the lesson
 Activity: Demonstrate your knowledge in
Practice
L7: API & Functions with
Parameter
Discussion Board on D2L
 What makes a Programmer?
1. Reading Documentation
2. Learn by seeing examples of a language
3. Professional programmers will frequently
reference documentation while designing
software
4. Learning habits of mind and patterns that
allow you to use a language (including its
documentation) effectively
5. Practice makes you a perfect programmer
L7: API & Functions with
Parameter
 API (Application Programming Interface) is a collection
of commands used to build applications.
 Functions have parameters which are information that
customize and control the behavior of a function.
 For example, you can specify moveForward(103) to move
the turtle exactly 103 pixels
 Library collection of functions with shared purpose.
 Documentation: A description of the behavior of a
function
 Since parameter value can change, you will often see a written
description for the command. Example:
moveForward(distance), turnLeft(angle) -
drawRectangle(sideLength, width).Code.org
Code.org
L7: API & Functions with
Parameter
 App Lab has documentation: look up
documentation about the commands of the language
penColor(), penWidth() dot(), arcLeft(), arcRight(),
moveTo(), turnTo()
Hexadecimal
penColor(“#FF0099”)
Students are asked read documentation
about all the new commands.
Watch Video
L7: Activity 1 to 13 on Code.org
 Design a personal monogram making use of
the commands you learned during the lesson
 Share your image & Upload to D2L
Draw whatever you like!
The only requirements are:
• use at least 3 different colors
• use moveTo
Explore the documentation for any new
commands you see and use your skills as
both an artist and user of API
documentation to draw something of
your own choosing.
If in doubt: try to re-create
"I [heart] CS" drawing
shown here.
Learning Objectives
 Identify situations for creating functions with
parameters.
 Incorporate functions with parameters into an
"Under the Sea" digital scene.
 Test functions with parameters using random
input.
L8: Creating Functions with Parameters
Watch Video
L8: Creating Functions with
Parameters
 What are the benefits of creating Functions with
Parameters?
1. Control behavior of the function – Customize it
for user needs.
2. Create complex drawings.
3. Can generalize solutions to problems instead of
duplicating code.
4. Offers extra flexibility - removes the need to
create multiple functions that do almost the same
thing. – Remove repetition and patterns
5. Easily experiment with different inputs to see
what kind of output we can produce.
Watch Video D2L Discuss & Share
 Defining multiple functions to draw different
sized squares results in lots of repetitive
functions .
 Any time you find yourself effectively copy and
pasting large sections of code, it's usually a
sign that there is a better way.
L8: Creating Functions with
Parameters
L8 Activity 1 to 14 on Code.org
 Modify the program that creates an “Under the
Sea” scene by adding parameters to functions.
 Use the random number functions to supply
random values to function calls so the scene
looks a little different every time the program
runs.
Example: randomNumber(0,3) to randomize
image so that every time your run program you
get different scenes like below:
Recap from this session
 What is an API
 How to create a function with parameter
 How to become a good programmer
 Benefit of creating functions with parameters
Ad

More Related Content

What's hot (20)

compiler vs interpreter
compiler vs interpretercompiler vs interpreter
compiler vs interpreter
Faculty of Science , portsaid Univeristy
 
Computer programming project 15sec
Computer programming project 15secComputer programming project 15sec
Computer programming project 15sec
Jenny Brown
 
Language translator
Language translatorLanguage translator
Language translator
asmakh89
 
Compilation v. interpretation
Compilation v. interpretationCompilation v. interpretation
Compilation v. interpretation
Alexander Bollbach
 
TensorFlow Lite for mobile & IoT
TensorFlow Lite for mobile & IoT   TensorFlow Lite for mobile & IoT
TensorFlow Lite for mobile & IoT
Mia Chang
 
Translators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreterTranslators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreter
baabtra.com - No. 1 supplier of quality freshers
 
Introduction
IntroductionIntroduction
Introduction
Kamran
 
Python Lecture 1
Python Lecture 1Python Lecture 1
Python Lecture 1
Inzamam Baig
 
Introduction to compiler interpreter
Introduction to compiler interpreterIntroduction to compiler interpreter
Introduction to compiler interpreter
poojapainter
 
La 5 Pl Translator
La 5   Pl TranslatorLa 5   Pl Translator
La 5 Pl Translator
Cma Mohd
 
Interpreted and compiled language
Interpreted and compiled languageInterpreted and compiled language
Interpreted and compiled language
baabtra.com - No. 1 supplier of quality freshers
 
Compilation of c
Compilation of cCompilation of c
Compilation of c
Way2itech
 
Functional programming ideas in python
Functional programming ideas in pythonFunctional programming ideas in python
Functional programming ideas in python
Manish Tomar
 
Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.
Md Hossen
 
Eclipse Luna - What's New!
Eclipse Luna - What's New!Eclipse Luna - What's New!
Eclipse Luna - What's New!
Noopur Gupta
 
COMPILER DESIGN OPTIONS
COMPILER DESIGN OPTIONSCOMPILER DESIGN OPTIONS
COMPILER DESIGN OPTIONS
sonalikharade3
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming Language
Cihad Horuzoğlu
 
How a Compiler Works ?
How a Compiler Works ?How a Compiler Works ?
How a Compiler Works ?
Hirdesh Vishwdewa
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
Akhil Kaushik
 
Language Translator ( Compiler)
Language Translator ( Compiler)Language Translator ( Compiler)
Language Translator ( Compiler)
Nazmul Hyder
 

Viewers also liked (6)

Datastructure algoritm
Datastructure algoritmDatastructure algoritm
Datastructure algoritm
Nergui Batjargal
 
Algorithm.ppt
Algorithm.pptAlgorithm.ppt
Algorithm.ppt
Tareq Hasan
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
Venkatesh Iyer
 
Introduction to Programming Languages
Introduction to Programming LanguagesIntroduction to Programming Languages
Introduction to Programming Languages
educationfront
 
Programming languages
Programming languagesProgramming languages
Programming languages
Asmasum
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
Varun Garg
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
Venkatesh Iyer
 
Introduction to Programming Languages
Introduction to Programming LanguagesIntroduction to Programming Languages
Introduction to Programming Languages
educationfront
 
Programming languages
Programming languagesProgramming languages
Programming languages
Asmasum
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
Varun Garg
 
Ad

Similar to Algorithm and Programming (20)

JAVA-java-basic and introduction.module.pptx
JAVA-java-basic and introduction.module.pptxJAVA-java-basic and introduction.module.pptx
JAVA-java-basic and introduction.module.pptx
catliegay
 
Dive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdfDive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdf
SudhanshiBakre1
 
Mastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_argumentsMastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_arguments
Ruth Marvin
 
Reasons to migrate from Delphi 7 to Delphi 2009
Reasons to migrate from Delphi 7  to Delphi 2009Reasons to migrate from Delphi 7  to Delphi 2009
Reasons to migrate from Delphi 7 to Delphi 2009
Michael Findling
 
Reasons to migrate from Delphi 7 to Delphi 2009
Reasons to migrate from Delphi 7 to Delphi 2009Reasons to migrate from Delphi 7 to Delphi 2009
Reasons to migrate from Delphi 7 to Delphi 2009
Michael Findling
 
Javascript mynotes
Javascript mynotesJavascript mynotes
Javascript mynotes
AntoniaSymeonidou1
 
Ex11 mini project
Ex11 mini projectEx11 mini project
Ex11 mini project
Elanthendral Mariappan
 
over all view programming to computer
over all view programming to computer over all view programming to computer
over all view programming to computer
muniryaseen
 
Top Ten Reasons to Upgrade from Delphi 7
Top Ten Reasons to Upgrade from Delphi 7Top Ten Reasons to Upgrade from Delphi 7
Top Ten Reasons to Upgrade from Delphi 7
Michael Findling
 
Envisioning the Future of Language Workbenches
Envisioning the Future of Language WorkbenchesEnvisioning the Future of Language Workbenches
Envisioning the Future of Language Workbenches
Markus Voelter
 
Why functional programming in C# & F#
Why functional programming in C# & F#Why functional programming in C# & F#
Why functional programming in C# & F#
Riccardo Terrell
 
C++ question and answers
C++ question and answersC++ question and answers
C++ question and answers
AdenKheire
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting Started
Martin Chapman
 
F# Tutorial @ QCon
F# Tutorial @ QConF# Tutorial @ QCon
F# Tutorial @ QCon
Tomas Petricek
 
Compose Camp session 2.pptx.pdf
Compose Camp session 2.pptx.pdfCompose Camp session 2.pptx.pdf
Compose Camp session 2.pptx.pdf
Dhruv675089
 
pythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxpythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptx
RohitKumar639388
 
Agile development with Ruby
Agile development with RubyAgile development with Ruby
Agile development with Ruby
khelll
 
Book management system
Book management systemBook management system
Book management system
SHARDA SHARAN
 
Python training
Python trainingPython training
Python training
Kunalchauhan76
 
Tell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature FlagsTell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature Flags
Jorge Ortiz
 
JAVA-java-basic and introduction.module.pptx
JAVA-java-basic and introduction.module.pptxJAVA-java-basic and introduction.module.pptx
JAVA-java-basic and introduction.module.pptx
catliegay
 
Dive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdfDive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdf
SudhanshiBakre1
 
Mastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_argumentsMastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_arguments
Ruth Marvin
 
Reasons to migrate from Delphi 7 to Delphi 2009
Reasons to migrate from Delphi 7  to Delphi 2009Reasons to migrate from Delphi 7  to Delphi 2009
Reasons to migrate from Delphi 7 to Delphi 2009
Michael Findling
 
Reasons to migrate from Delphi 7 to Delphi 2009
Reasons to migrate from Delphi 7 to Delphi 2009Reasons to migrate from Delphi 7 to Delphi 2009
Reasons to migrate from Delphi 7 to Delphi 2009
Michael Findling
 
over all view programming to computer
over all view programming to computer over all view programming to computer
over all view programming to computer
muniryaseen
 
Top Ten Reasons to Upgrade from Delphi 7
Top Ten Reasons to Upgrade from Delphi 7Top Ten Reasons to Upgrade from Delphi 7
Top Ten Reasons to Upgrade from Delphi 7
Michael Findling
 
Envisioning the Future of Language Workbenches
Envisioning the Future of Language WorkbenchesEnvisioning the Future of Language Workbenches
Envisioning the Future of Language Workbenches
Markus Voelter
 
Why functional programming in C# & F#
Why functional programming in C# & F#Why functional programming in C# & F#
Why functional programming in C# & F#
Riccardo Terrell
 
C++ question and answers
C++ question and answersC++ question and answers
C++ question and answers
AdenKheire
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting Started
Martin Chapman
 
Compose Camp session 2.pptx.pdf
Compose Camp session 2.pptx.pdfCompose Camp session 2.pptx.pdf
Compose Camp session 2.pptx.pdf
Dhruv675089
 
pythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxpythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptx
RohitKumar639388
 
Agile development with Ruby
Agile development with RubyAgile development with Ruby
Agile development with Ruby
khelll
 
Book management system
Book management systemBook management system
Book management system
SHARDA SHARAN
 
Tell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature FlagsTell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature Flags
Jorge Ortiz
 
Ad

Recently uploaded (20)

Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
UPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guideUPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guide
abmerca
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
UPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guideUPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guide
abmerca
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 

Algorithm and Programming

  • 2. Recall from previous session  Function: also known as method/procedure which is a set of commands that can be called again and over again.  Benefits of Function?  Define Function then Call the Function to Execute  Define one function inside another function  Function is a form of Abstraction finding one solution for multiple problems.  Function use Top Down approach breaking down big problems to sub problems.
  • 3. LESSON OBJECTIVES Students will:  Learn to read App Lab’s API documentation  Use functions that accept parameters in order to complete a series of drawing puzzles  Design a personal monogram making use of the commands you learned during the lesson  Activity: Demonstrate your knowledge in Practice L7: API & Functions with Parameter
  • 4. Discussion Board on D2L  What makes a Programmer? 1. Reading Documentation 2. Learn by seeing examples of a language 3. Professional programmers will frequently reference documentation while designing software 4. Learning habits of mind and patterns that allow you to use a language (including its documentation) effectively 5. Practice makes you a perfect programmer
  • 5. L7: API & Functions with Parameter  API (Application Programming Interface) is a collection of commands used to build applications.  Functions have parameters which are information that customize and control the behavior of a function.  For example, you can specify moveForward(103) to move the turtle exactly 103 pixels  Library collection of functions with shared purpose.  Documentation: A description of the behavior of a function  Since parameter value can change, you will often see a written description for the command. Example: moveForward(distance), turnLeft(angle) - drawRectangle(sideLength, width).Code.org Code.org
  • 6. L7: API & Functions with Parameter  App Lab has documentation: look up documentation about the commands of the language penColor(), penWidth() dot(), arcLeft(), arcRight(), moveTo(), turnTo() Hexadecimal penColor(“#FF0099”) Students are asked read documentation about all the new commands. Watch Video
  • 7. L7: Activity 1 to 13 on Code.org  Design a personal monogram making use of the commands you learned during the lesson  Share your image & Upload to D2L Draw whatever you like! The only requirements are: • use at least 3 different colors • use moveTo Explore the documentation for any new commands you see and use your skills as both an artist and user of API documentation to draw something of your own choosing. If in doubt: try to re-create "I [heart] CS" drawing shown here.
  • 8. Learning Objectives  Identify situations for creating functions with parameters.  Incorporate functions with parameters into an "Under the Sea" digital scene.  Test functions with parameters using random input. L8: Creating Functions with Parameters Watch Video
  • 9. L8: Creating Functions with Parameters  What are the benefits of creating Functions with Parameters? 1. Control behavior of the function – Customize it for user needs. 2. Create complex drawings. 3. Can generalize solutions to problems instead of duplicating code. 4. Offers extra flexibility - removes the need to create multiple functions that do almost the same thing. – Remove repetition and patterns 5. Easily experiment with different inputs to see what kind of output we can produce. Watch Video D2L Discuss & Share
  • 10.  Defining multiple functions to draw different sized squares results in lots of repetitive functions .  Any time you find yourself effectively copy and pasting large sections of code, it's usually a sign that there is a better way. L8: Creating Functions with Parameters
  • 11. L8 Activity 1 to 14 on Code.org  Modify the program that creates an “Under the Sea” scene by adding parameters to functions.  Use the random number functions to supply random values to function calls so the scene looks a little different every time the program runs. Example: randomNumber(0,3) to randomize image so that every time your run program you get different scenes like below:
  • 12. Recap from this session  What is an API  How to create a function with parameter  How to become a good programmer  Benefit of creating functions with parameters
  翻译: