First Term Jss 2 Robotics and Ai
First Term Jss 2 Robotics and Ai
I
Sample curriculum
WEEKS
1. Introduction to Javascript
Definition of Javascrpt
2. Javascript Events
3. Variables and constant in Javascript
4. Javascript operators
5. Javasript control statement (i)
(a) How to use if statement
(b) How to use if-else statement
(c) How to use switch statement
6. Javascript control statement (ii)
(d) How to use tenary operators
(e) How to use for-loop statement
7. Mid term break
8. Introduction to Robotics
Definition of Robot and Robotics
9. Types of Robot
(using A.I stater kits as a case study)
10. Revision
11-13. Examination
WEEK ONE
INTRODUCTION TO JAVASCRIPT
JavaScript is a versatile and widely-used programming language that enables
programmer to create interactive and dynamic web pages, web applications,
and mobile applications.
What is JavaScript?
1. Client-side scripting
2. Dynamic typing
3. Object-oriented
4. First-class functions
5. Prototype-based
1. Web development
2. Game development
3. Desktop applications
4. Server-side programming (with Node.js)
EVALUATION
1, what is Javascript ?
2. Highlight reasons why we learn Javascript.
3. List four basic concept of Javascript
WEEK TW0
1. Install Visual Studio Code (VS Code)
Make sure you have VS Code installed on your computer.
2. Create a JavaScript File
1. Open VS Code.
2. Create a new file by clicking on File > New File or pressing Ctrl + N.
3. Save the file with a .js extension (e.g., script.js) by clicking on File >
Save As... or pressing Ctrl + S.
3. Write JavaScript Code
console.log('Hello, World!');
JAVASCRIPT EVENT
JavaScript events are actions or occurrences that happen in a web page or
application, such as:
1. Mouse clicks
2. Key presses
3. Page loads
4. Form submissions
5. Hovering over elements
6. Touch events (on mobile devices)
1. click
2. hover
3. submit
4. change
5. keydown
6. load
7. scroll
8. resize
9. touchstart
10. touchmove
Event Listeners
Example:
// Add an event listener to a button element
document.getElementById('myButton').addEventListener('click', function() {
console.log('Button clicked!');
});
Event Object
When an event occurs, an event object is passed to the event listener function.
The event object contains information about the event, such as:
Example:
Event Propagation
Event propagation in JavaScript refers to the process by which an event travels
through the Document Object Model (DOM) tree, allowing multiple elements
to respond to the same event.
1. Capturing phase: The event propagates from the top-most element (window)
down to the target element.
2. Bubbling phase: The event propagates from the target element up to the top-
most element (window).
During event propagation, the event object is passed to each element's event
listener function, allowing them to respond to the event.
EVALUATION
1. States examples of event propagation
2. List five Javascript common events
3. Explain the term event object
WEEK THREE
Variables and constants in JavaScript
Variables
In JavaScript, a variable is a container that holds a value. It can be considered
as a labeled box where data or value can be stored .
Example:
let name = 'John';
console.log(name); // Output: John
Constants
A constant is a variable whose value cannot be changed once it's declared.
How variable can be used in Javascript
1. Declare a constant using const.
2, Assign a value to a constant using the assignment operator (=).
3. Trying to reassign a value to a constant will result in an error.
Example:
const PI = 3.14;
console.log(PI); // Output: 3.14
PI = 2.71; // Error: Assignment to constant variable.
Key differences between variables and constants
1. Variables can be reassigned, while constants cannot.
2. Constants are immutable, while variables are mutable.
Best practices on how to handle constant in javascript
1. Use const for values that don't change, like configuration settings or
mathematical constants.
2. Use let for values that change, like user input or temporary calculations.
3. Avoid using var unless you need to support older browsers.
EVALUATION
1. Differentiate berween variable and constant in Javascript
2. How can variable be used in Javascript
3. Write a simple javascript progtam to declare PI as maths constant
statement
WEEK FOUR
Javascript operators
1. Arithmetic Operators
- + (Addition)
- - (Subtraction)
- * (Multiplication)
- / (Division)
- % (Modulus)
- ** (Exponentiation)
2. Assignment Operators
- = (Assignment)
- += (Addition Assignment)
- -= (Subtraction Assignment)
- *= (Multiplication Assignment)
- /= (Division Assignment)
- %= (Modulus Assignment)
3. Comparison Operators
- == (Equal)
- != (Not Equal)
- === (Strict Equal)
- !== (Strict Not Equal)
- > (Greater Than)
- < (Less Than)
- >= (Greater Than or Equal)
- <= (Less Than or Equal)
4. Logical Operators
5. Bitwise Operators
6. String Operators
- + (Concatenation)
7. Ternary Operator
- ?: (Conditional Operator)
1. Arithmetic Operators
2. Assignment Operators
3. Comparison Operators
4. Logical Operators
- Check if a user is 18 or older and has a valid ID: let age = 20; let hasId =
true; if (age >= 18 && hasId) { console.log("Allowed"); }
- Check if a value is either 5 or 10: let num = 5; if (num === 5 || num ===
10) { console.log("Valid"); }
5. String Operators
6. Ternary Operator
- Simplify an if-else statement: let age = 20; let status = age >= 18 ?
"Adult" : "Minor";
EVALUATION
1. Write three examples of assignment operators
2. Give five examples of bitwise operators
WEEK FIVE
Javasript control statement (i)
(a) How to use if statement
(b) How to use if-else statement
(c ) How to use switch statement
1. Conditional Statements:
- If-else statements: Execute code based on a condition.
- Switch statements: Execute code based on a value.
2. Loops:
- For loops: Repeat code for a specified number of iterations.
- While loops: Repeat code while a condition is true.
- Do-while loops: Repeat code while a condition is true, with a guaranteed
first iteration.
3. Jump Statements:
- Break statements: Exit a loop or switch statement.
- Continue statements: Skip to the next iteration of a loop.
- Return statements: Exit a function and return a value.
4. Exception Handling:
- Try-catch statements: Catch and handle runtime errors.
Example
If-Else Statement
Else If Statement
1. Add the else if keyword after the initial if statement.
2. Follow with another condition in parentheses ().
3. Write the code to be executed if the second condition is true inside curly
braces {}.
Example
let age = 25;
if (age >= 18) {
console.log("You are an adult!");
} else if (age >= 13) {
console.log("You are a teenager!");
} else {
console.log("You are a kid!");
}
Guideline
- Use parentheses around the conditions.
- Use curly braces around the code blocks.
- Keep the conditions and code blocks indented for readability.
How to use switch statement in Javascript
The switch statement in JavaScript is used to execute different blocks of code
based on the value of a variable or expression. Here's the basic syntax:
switch (expression) {
case value1:
break;
case value2:
break;
default:
Example:
let day = 2;
switch (day) {
case 1:
console.log("Monday");
break;
case 2:
console.log("Tuesday");
break;
default:
console.log("Another day");
In this example, the switch statement checks the value of the day variable. If it's
1, it logs "Monday". If it's 2, it logs "Tuesday". If it's neither 1 nor 2, it logs
"Another day".
Guideline
- Use break statements to exit the switch block after executing the matching
case.
- Use the default case to catch values that don't match any other case.
- You can also use strings, booleans, or even expressions as case values.
Step-by-step guide on how to use switch statements in JavaScript:
1. Start with the switch keyword followed by the expression in parentheses ().
2. Add case clauses for each value you want to check, followed by a colon :.
3. Write the code to be executed for each case inside the case clause.
4. Use the break statement to exit the switch block after executing the matching
case.
5. Add a default clause to catch values that don't match any case.
Example:
let color = 'red';
switch (color) {
case 'red':
console.log('The color is red');
break;
case 'blue':
console.log('The color is blue');
break;
default:
console.log('The color is not red or blue');
}
In this example
- The switch statement checks the value of the color variable.
- If color is 'red', it logs 'The color is red'.
- If color is 'blue', it logs 'The color is blue'.
- If color is neither 'red' nor 'blue', it logs 'The color is not red or blue'.
Guideline
- Use break statements to avoid executing multiple cases.
- Use the default clause to handle unexpected values.
- Keep the switch block organized and readable.
EVALUATION
1. What is control statement ?
2. State how to use If-Else statement in Javascript
3. Write the code to be executed if the second condition is false inside curly
braces {}.
WEEK SIX
Javascript control statement (ii)
(d ) How to use tenary operators
(e ) How to use for-loop statement
Example:
let age = 25;
let status = age >= 18 ? "Adult" : "Minor";
Breakdown:
- age >= 18 is the condition.
- "Adult" is the true value.
- "Minor" is the false value.
Guideline
1. Use ternary operators for simple if-else statements.
2. Keep the condition, true value, and false value concise.
3. Use parentheses for clarity if needed.
More examples:
- let isAdmin = user.role === "admin" ? true : false;
- let message = isEmpty ? "Please fill in the field" : "Field is valid";
- let result = num > 0 ? "Positive" : num < 0 ? "Negative" : "Zero"; (nested
ternary operator)
// code to be executed
Example:
console.log(i);
Output: 0, 1, 2, 3, 4
In this example:
let i = 0;
i < 10
i++
console.log(i);
Output: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Tips on guideline
1. Use let or var to declare the counter variable.
2. Adjust the initialization, condition, and increment to fit your needs.
3. Use break to exit the loop prematurely.
4. Use continue to skip to the next iteration.
EVALUATION
1. List three parts of tenary operators .
2. What is the output of the program below
for (let i = 0; i < 5; i++) {
console.log(i);
Output:
WEEK SEVEN
MID-TERM BREAK
WEEK EIGHT
Introduction to Robotics
Definition of Robot and Robotics
Robotics is a multidisciplinary field that combines engineering, computer
science, and mathematics to design, build, and operate robots. Here's an
introduction to robots and robotics:
What is a Robot?
A robot is a programmable machine that can perform tasks autonomously or
semi-autonomously, often with human-like capabilities. Robots can be physical
(hardware) or virtual (software).
Types of Robots
1. Industrial Robots: Used in manufacturing and production.
2. Service Robots: Assist humans in various tasks, like cleaning, cooking, and
healthcare.
3. Autonomous Robots: Self-navigating robots, like drones and self-driving
cars.
4. Humanoid Robots: Designed to resemble and mimic human appearance and
movement.
5. Social Robots: Interact with humans, like chatbots and virtual assistants.
Robotics Subfields
1. Artificial Intelligence (AI): Enables robots to learn, reason, and make
decisions.
2. Machine Learning (ML): Allows robots to improve performance through
data analysis.
3. Computer Vision: Enables robots to interpret and understand visual data.
4. Robotics Engineering: Focuses on designing, building, and operating robots.
5. Human-Robot Interaction (HRI): Studies how humans interact with robots.
Robotics Applications
1. Manufacturing and Production
2. Healthcare and Medicine
3. Transportation and Logistics
4. Service and Hospitality
5. Space Exploration
6. Military and Defense
7. Agriculture and Environment
Benefits of Robotics
1. Increased Efficiency
2. Improved Accuracy
3. Enhanced Productivity
4. Augmented Human Capabilities
5. Improved Safety
Robotics Challenges
1. Technical Complexity
2. Ethical Concerns
3. Job Displacement
4. Safety and Security
5. High Development Costs
EVALUATION
1. What is Robot and Robotics ?
2. States five benefits of Robotics
3. List five applications of Robotics to the society
WEEK NINE
Types of Robots
1. Industrial Robots: Used in manufacturing, assembly, and production.
Examples include welding robots, painting robots, and assembly line robots.
7. Military and Defense Robots: Used for surveillance, explosive disposal, and
combat, including:
- Drone Swarms: Coordinated groups of drones for surveillance and attack.
- Battlefield Robots: Robots for explosive disposal and combat support.
8. Space Exploration Robots: Used for planetary exploration and research, such
as:
- Rovers: Robots for planetary surface exploration.
- Satellites: Robots for orbital research and surveillance.
9. Swarm Robots: Large groups of simple robots that work together, such as:
- Nano-Robots: Tiny robots for medical and environmental applications.
- Flocking Robots: Robots that mimic bird flocking behavior.
EVALUATION
State and explain any five types of Robots