MODUL
E: 2
EVEYTHING BECOMES
PROGRAMMABLE
2.1.2
FLOWCHART
• FLOWCHARTS REPRESENT
S PROCESSES
AND WORKFLOWS.
• USED IN ENGINEERING, SCIENCE, AND
PROGRAMMING.
• SHOW INPUTS, DECISIONS, AND
RESULTS.
2.1.1 CHECK YOUR UNDERSTANDING -
FOLLOW THE FLOWCHART
2.1.3 SYSTEM SOFTWARE, APPLICATION SOFTWARE, AND
COMPUTER LANGUAGES
TWO TYPES OF SOFTWARE: SYSTEM AND
APPLICATION.
APPLICATION SOFTWARE: E.G., CISCO PACKET
TRACER.
SYSTEM SOFTWARE: E.G., LINUX, MACOS,
WINDOWS.
PROGRAMMING LANGUAGES CREATE
SOFTWARE.
2.1.4 PROGRAMMING
VARIABLES
VARIABLES ACT AS CONTAINERS FOR
VALUES.
EXAMPLES: NUMBERS, STRINGS, MEMORY
LOCATIONS.
EXPRESSION EXAMPLE: X + Y
= Z.
LOCAL VS GLOBAL Allow flexibility and reusability in
VARIABLES: programs.
2.1.5 BASIC PROGRAM
STRUCTURES
IF-THEN: DECISIONS BASED ON
CONDITIONS.
EXAMPLE: COMPARE TWO
VALUES.
FOR LOOP: REPEATS INSTRUCTIONS
A
SET NUMBER OF TIMES.
WHILE Loop: Repeats instructions
while
condition is true.
WHAT IS
BLOCKLY ? A VISUAL PROGRAMMING
TOOL
USES COLORED BLOCKS
INSTEAD OF TEXT CODE
INCLUDES VARIABLES,
CONDITIONALS, LOOPS, FUNCTION
NO NEED TO MEMORIZE
CODING SYNTAX
A BLOCKLY
PROGRAM
HOW BLOCKLY
WORKS
EACH BLOCK HAS A SPECIFIC
PURPOSE
(LIKE PRINT, LOOP, OR CONDITION)
BLOCKS CAN BE CONNECTED
TOGETHER
VARIABLES CAN BE CREATED AND
CHANGED
BLOCKLY CAN GENERATE REAL
CODE (PYTHON/JAVASCRIPT)
BLOCKLY VARIABLES &
FUNCTIONS
VARIABLES: STORE VALUES
FUNCTIONS: REUSABLE BLOCKS OF
CODE
BLOCKS SNAP TOGETHER EASILY
BLOCKLY
GAMES
2.3.1 WHAT IS
PYTHON?
• EASY-TO-READ AND POPULAR PROGRAMMING
LANGUAGE.
• GUIDED BY 'THE ZEN OF PYTHON'.
• SUPPORTED BY A STRONG COMMUNITY.
• EXAMPLE: GUESSING GAME PROGRAM.
2.3.2 PYTHON
INTERPRETER
• PYTHON IS AN INTERPRETED LANGUAGE.
• INTERPRETER PARSES AND EXECUTES CODE.
• INTERACTIVE MODE WITH >>> PROMPT.
• INSTALLED IN LINUX (/USR/BIN/PYTHON3) OR
WINDOWS.
Python Interpreter Welcome
Message
2.3.3 Variables and Basic Statements in Python
Python as a calculator.
Operators: +, -, *, /.
Variables store values.
Strings with single/double
quotes.
Functions allow code reuse.
Grouping with
parentheses
Use of Special
Variable
Variable Assignment and String Output
Usage Formatting
Undefined Variable Error
A Function to Add Two Numbers and Print the Result
Use of Quotes to Wrap Strings
2.3.4 Useful Functions and Data Types
•range(): generates number
sequences.
•Tuples: immutable sequences.
• Lists: mutable sequences.
•Sets: unique unordered
collections.
2.3.4 Useful Functions and Data
Range()Function Types in Python
Examples
Python Tuples
Example
DICTIONARIES
A dictionary is a list of elements that are separated by commas. Each element is a combination of a value and a unique key. Each key is
separated from its value by a colon. The entire dictionary is written within braces. Dictionary elements can be accessed, updated, and
deleted. There are also many built-in dictionary functions such as a function that compares elements within different dictionaries and
another that provides a count of the total number of elements within a dictionary. The examples show various dictionary operations.
2.3.5 Programming Structures in
Python
IF-THEN
SIMILAR TO OTHER LANGUAGES, PYTHON IMPLEMENTS AN IF-THEN STRUCTURE. IF-THEN BLOCKS CAN
Structures
BE USED TO ALLOW THE CODE TO MAKE DECISIONS BASED UPON THE RESULT OF AN EXPRESSION, AS
SHOWN IN THE EXAMPLE.
FOR Loop
Structure
THE FOR LOOP IN PYTHON ITERATES THE ITEMS OF ANY SEQUENCE (A LIST OR A
STRING), IN THE ORDER THAT THEY APPEAR IN THE SEQUENCE, AS SHOWN IN THE
EXAMPLE.
WHILE
Loop
The WHILE loop executes a block of code if the expression is true. The example
program uses a WHILE loop to calculate and print an initial sub-sequence of a
Fibonacci series in which each number in the series is the sum of the previous two.
2.4.1 Defining Prototyping
For prototyping in the IoT, it helps to have design skills, electronics skills, and physical/mechanical
skills (working with your hands to put things together). Networking and programming skills are also
extremely valuable. In addition, IoT developers also benefit from knowledge of cloud computing and
network and device security.
Because the IoT is still developing, there are still unknown tasks to discover. This is a great time to
invent something that is part of the IoT. Because the IoT combines people, process, data, and things,
there is no end to the inventions that the IoT can help create and then incorporate.
Prototyping
Is fully functional, but not fault-proof.
• Is an actual, working version of the
product.
• Is used for performance evaluation and further
improvement
• Has a complete interior and of product.
[Link] to
• May be relatively
• In the IoT,produce.
is often used as a technology
demonstrator.
2.4.2 How to
Prototype
Prototyping is one of the most important steps in turning an idea into reality. It allows us to
create a first version of our product, test it, and improve it before the final launch. Big companies
like Google use methods such as Rapid Prototyping to quickly develop innovations like the
Google Glass. However, not everyone has the same resources as Google, so alternative ways like
crowdfunding platforms—Kickstarter, Indiegogo, and Crowdfunder—help inventors bring their
ideas to life. A great example is the Pebble Time smartwatch, which became successful through
crowdfunding."
What IoT invention will you
create?
2.5.1 Physical
Materials
•Internet: exchange of
ideas.
•Materials: wood, metal, plastic,
clay, wires.
• Meccano/Erector Set for
prototypes.
• 3D Printing allows creation of solid objects from
digital 3D models (e.g., Makerbot).