Explore 1.5M+ audiobooks & ebooks free for days

Only €10,99/month after trial. Cancel anytime.

TouchCode Class 8: Coding Book
TouchCode Class 8: Coding Book
TouchCode Class 8: Coding Book
Ebook182 pages48 minutes

TouchCode Class 8: Coding Book

Rating: 0 out of 5 stars

()

Read preview

About this ebook

TouchCode, a series for grades 1–8, is a specially designed book to develop Computational Thinking skills and move towards making codes.

TouchCode books for Grades 1–5 have activities based on various skills that amplifies the CT skills and build a strong foundation for middle school. TouchCode books for Grades 6–8 take a step ahead and let the c
LanguageEnglish
PublisherOrange Education Pvt Ltd.
Release dateJun 12, 2024
ISBN9789391246983
TouchCode Class 8: Coding Book

Read more from Team Orange

Related to TouchCode Class 8

Related ebooks

Computers For You

View More

Reviews for TouchCode Class 8

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    TouchCode Class 8 - Team Orange

    1

    CONDITIONALS IN DETAILS

    Introduction

    In programming, the flow of the program is a very important aspect. If controlled correctly, a program can be made highly efficient. In this chapter, you are going to learn about the flow of program.

    Types of Control Structures

    Control structure is a coding construct that is used to decide the flow of a program based on the parameters given to it. Usually, a control structure accepts and analyses a variable to make a decision on which direction to proceed. So, the control structure is a basic decision-making process in computing.

    The three basic types of control structures are:

    Sequential: Statements in a program are executed sequentially or step-by-step in an order in which the instructions are written.

    Selection/Conditional: It is used to test a condition in a program. It takes decision to execute one statement/operation over another statement/operation depending on the condition.

    Iteration: It executes set of statements for a certain number of times till the given condition is true. Example: Loops

    On the basis of the above three control structures, programming has derived many types of control statements to suit different needs.

    Understanding IF-ELSE and ELSE-IF statements

    Every day, you take many decisions depending on the situation. For example, if you are given a number and you need to check if the number is even or odd, you will check this by dividing the number with 2. If the remainder is 1, the number is odd and if the remainder is 0, then the number is even.

    IF-ELSE Statement

    The above mentioned logic can be applied through if-else statement. The if-else statement requires three things:

    Evaluation statement: Condition or expression that is being checked.

    Execution statement: Operations which will be performed if the condition appears to be true.

    Else execution block: Operation which will be performed only if the evaluation statement is false.

    Flowchart:

    Explanation: To implement this in a program, you will use, number%2=0, i.e., we divide the number by 2 and if the remainder comes out to be 0, then the number is even, otherwise the number is odd.

    ELSE-IF Statement

    Suppose you need to compare two numbers a, b and check if a is greater than b or they are equal. To implement this, you need to check two conditions.

    In python, the keyword elif, is used for checking another statement in case the previous statement is false.

    Code:

    a=23

    b=23

    if a>b:

    print (a is greater than b)

    elif a==b:

    print (a is equal to b)

    else:

    print (a is less than b)

    Explanation: In this, you are comparing the values of two variables by using a comparison operator. In the first statement it checks if a is greater than b, if this condition is true then it print (a is greater than b), and if the condition is false, then elif block will execute and checks if a is equal to b, if it is true, then it prints (a is equal to b) and if it is false then it print (a is less than b).

    Logical Operators

    Logical operators are the fundamental blocks used to implement a decision-making capability in the code. When you need to make decision based on two or more checks, it is necessary to have a combination of logical operators.

    Logical operators work like Boolean variables and return either TRUE or FALSE.

    The three most important logical operators are:

    AND

    Enjoying the preview?
    Page 1 of 1