0% found this document useful (0 votes)
4 views

Session 9 - Variables in App Lab

The document provides an overview of fundamental concepts in Artificial Intelligence, focusing on variables, design elements, and basic arithmetic operations. It includes definitions, types of variables, and examples, as well as practical applications using code.org's App Lab. The objective is to equip students with the skills to create apps by utilizing control elements and storing information in variables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Session 9 - Variables in App Lab

The document provides an overview of fundamental concepts in Artificial Intelligence, focusing on variables, design elements, and basic arithmetic operations. It includes definitions, types of variables, and examples, as well as practical applications using code.org's App Lab. The objective is to equip students with the skills to create apps by utilizing control elements and storing information in variables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Fundamentals of

Artificial Intelligence
Review App Lab

 Where do we find conditional blocks?

 Which blocks can be used when


conditions are applied in project?

 What are arithmetic operators?

2
Amazon Future
Engineer
Introduction of AI
Session 09
(Time limit: 2 hours)
 What is Variable?
 Types of Variables
 Examples of Variable
Ø Design Elements
 Introduction to Math
 Hands-on-project

3
Purpose Objective

 Learners will learn about variables, design  Students will be able to:
elements and Introduction to math.  Add the control buttons, text input, text
 They will use code.org to explore the App lab area and dropdown elements.
and create an app.  Able to learn how to store information in
variable.

v Able to learn how to assign a value to


the variable.

v Able to learn basic mathematical


operations using math block.

v Design the projects based on


the elements using variable and math.
4
Let's watch this video

5
Types of Variables

Variables are simply names that you

use to refer to store

data/information. There are 3 types of

variables.

Ø Number – 1,2,3,4,5,etc.

Ø String – "A", "B", "hi", "good", etc.

Ø Boolean – True or False

6
Components of Variables
 Two components of variable – Variable name and Variable value

Keyword

Variable name Value

7
Examples of Variables

Now let's try this:


What is variable name in container 1 ?
What is the variable value in container 2 ?

Container 1 Container 2 Container 3


8
Examples of Variables

 In Container 1, "name" is the variable name and "john" is the


variable value(String).

Ø In Container 2, "age" is the variable name and ''25'' is the


variable value(Number)
9
Examples of Variables

 Let a variable named Roll

Number has a value 20.

 Now if we assign a new value 55

to it.

 Old value will be lost and new

value 55 will be placed in it.

10
Activity

Counting with Variables #1 | Express Course (2022) - Code.org


13
Design Elements
Text input:
The text input allows the person using your app to type in anything that they want such as
words, passwords or numbers.

Enter the
values inside
the text
input.

16
Design Elements

Text area:
The text area is used to enter one or more lines of text .

Enter the
text inside
the text area.

Entered
text will
appear here.

17
Design Elements

Dropdown:
The list of choices that appears on a computer screen when a person clicks on the
dropdown option.

Enter the text


inside the
dropdown.

18
Code Interface
getNumber():
• Gets the number from the specified screen element.
• To capture numeric data entered by the user your apps will need to read data
from text input().

setNumber():
• Sets the number for the specified screen element.
• Your apps will sometimes need to change, or clear, the numbers displayed.
• setNumber() can be used to update the number on a textInput, textLabel,
button.

15
Code Interface
Declare a variable:
• Declares a variable with the given name.
• Variable names cannot have spaces or special
characters. In practice, it is helpful to name
your variables in a way that describes the
value they store. For instance, if the variable
you create is to store a Score of project you
might name that variable Score.
Assign variable:
• Assign a value to a variable
• The variable getting the value always goes on
the left-hand side of the assignment operator
=. The right-hand side of the assignment
operator can be a number or a string, or the
number or string returned by a function, or
the numeric or string result of the evaluation
of an expression.

16
Code Interface

Basic Arithmetic Operations:


• Addition
• Subtraction
• Multiplication
• Division
• Equal to

21
Project Links

Piggy Bank Simple Calculator


22
Let's Summarize!

Q1. A ________ is a container that holds information that you can access.
a) Questions b) Variable

Q2. The ______ is used to enter one or more lines of text .


a) Text input b) Text area

Q3. All programming languages support the basic _____________.


a) Arithmetic operations b) Arithmetic sequence

23
Let's Summarize!

Q1. A ________ is a container that holds information that you can access.
a) Questions b) Variable

Q2. The ______ is used to enter one or more lines of text .


a) Text input b) Text area

Q3. All programming languages support the basic _____________.


a) Arithmetic operations b) Arithmetic sequence

24
“Education is the most powerful weapon which
you can use to change the world.”
--Nelson Mandela

THANK YOU

21

You might also like