CBSE Class 8 Introduction To Coding Ch1-Conditionals In Details

The board has introduced the new CBSE NCERT Rationalised Syllabus to reduce the students’ dependence on coaching institutes and learn themselves. To follow National Education Policy 2020, CBSE has brought a coding curriculum to Class 8. Microsoft is helping in creating this new curriculum.

CBSE has launched the Book Overview and soon it will be available in your school and near stationary. But till then NotesChahiye.Com will provide you with Quality Notes and Courses based on this book.

Today, we will walk you through the complete Class 8 Introduction To Coding Chapter 1-Conditionals In Details. Let start.

Conditionals In Details Syllabus 2023: What Will We Learn

The first chapter of Introduction To Coding is Conditionals In Details. The chapter will teach students about different conditional statements and syntaxes used in programming.

Here is the content of the table for Conditionals In Details:

  • Introduction to Conditionals
  • Control Structure
  • Basic Syntax of Conditionals
  • Conditional Operators
  • Use Conditionals in Programs
  • Advanced Conditional Statements
  • Logical Operators
  • Practice and Exercises

#1: Introduction To Conditionals: Definition & Examples

The conditional in programming is a statement or instruction that tells the computer what to do and don’t in given situations. But it computes based on a block of instructions (code), not self-decision.

These conditional statements are also called Logical Statements. Here are 5 real-life examples of it:

  • If it’s Sunday, sleep in. Otherwise, wake up for school.
  • If the traffic light is green, drive forward. Otherwise, stop and wait for the light to turn green.
  • If you have worn shoes, enter the class. Else don’t.
  • If you secure more than 33%, you pass. Else fail.
  • If the user clicks the “submit” button, save their form data. Otherwise, don’t save it.

But here you have to note that computer does not understand Human language. It computer low-level-language (0-1) based on high-level-language (programming OR coding). So that we first understand what is “Control Structure”

CBSE Class 8 Introduction To Coding Ch1-Conditionals In Details

#2: Control Structure: Understanding and Types

In computer programming, a Control Structure is a way to control the flow of a program’s execution. It determines the order in which statements are executed based on certain conditions or rules.

In other languages, Control Structure is a way to control the flow of a program’s execution. It determines the order in which statements are executed based on certain conditions or rules.

Here is a very easy example of a control structure: Instagram Reels Upload

  • Step1: First, you have to create Instagram Account
  • Step2: Then click on “Upload Reel” in the App.
  • Step3: Select your video.

And in each step, there may be more other control structures.

There are three types of control structures

  1. Sequential
  2. Selection/Conditional
  3. Iteration

#1: Sequential Control Structure

In a sequential control structure, the computer follows a straight line of code from top to bottom, executing each statement in the order in which it appears.

For example, if you want to find the area of a rectangle then you first measure the length and width of it and then in the second step you have to multiply them.

                                                                                  Python syntax
  width=3
  height=4
  area=width*height
  print(area)

Here program cannot execute print(area) directly without executing the first width, height and area. This is a sequential control structure.

#2: Selection/Conditional Structure

A Selection/Conditional Structure is a programming tool that helps programs to make choices based on certain conditions.

When you use this structure in your program, it can determine whether a condition is true or false, and take appropriate action based on that result.

For example, you write a program for “Pass” or Fail. If marks are more than 33 Pass otherwise Fail. In this example, you will use if-else.

                                                                                  Python syntax
    if x > 33: 
     print("x is Pass") 
  else:
     print("x is not Fail")

This type of structure is also sometimes called a branching structure because it enables the program to “branch off” in different directions based on the result of a condition.

#3: Iteration

Iteration is another type of control structure in programming. It involves repeating a set of instructions multiple times, either a fixed number of times or until a certain condition is met.

For example, counting rupee 1 coins after breaking Gullak. You will count until it not finish. Iteration.

The most common type of iteration in programming is the “for” loop, which allows a program to repeat a block of code a fixed number of times.

                                                                                  Python syntax 
  coins = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] # list of 10 rupee1 coins
        count = 0

  for coin in coins: 
     count += 1 

  print("You have", count, "rupee1 coins.")

Understanding IF-ELSE and ELSE-IF conditional statement

We have discussed Conditional Statements in the very first. Here we are going to discuss How You Can Apply Them In Programming.

There are different types of conditional control structures such as:

  • If
  • If-else
  • Else-if
  • Switch

But we will only learn about If-else and Else-if.

Use Of If-else

The if-else conditionals follow these three steps to execute your given condition:

  • Step1: Evaluate the condition
  • Step2: Execute For True
  • Step3: Else execution block
  x = 5
  # Step 1: Evaluate the condition
  if x > 10:
      # Step 2: Execute for True
      print("x is greater than 10")
  else:
      # Step 3: Else execution block
      print("x is less than or equal to 10")

Flow-Chart If-else

CBSE Class 8 Introduction To Coding Ch1-Conditionals In Details Flow-Chart If-else

Nested Conditionals Statement In Details

Read all these statements first:

  • Step 1: You have a science project due next week, but you’re not sure if you have all the necessary materials to complete it.
  • Step 2: You check your notes and the project guidelines to see what materials you need.
  • Step 3: If you have everything you need, you’ll start working on the project. If not, you’ll move to the next step.
  • Step 4: You ask your teacher or a classmate for the missing materials. If they have the materials, you borrow them.
  • Step 5: If you can’t find the materials, you check online or visit the library to see if you can find the information or materials you need.
  • Step 6: Once you have all the materials, you start working on the project.
  • Step 7: If you get stuck or need help, you can ask your teacher, a classmate, or a tutor for assistance.
  • Step 8: You complete the project on time and submit it to your teacher.

Until you do not True for one step you will check the next steps. This is Nested Conditionals.

A nested conditional statement is a conditional statement that is placed within another conditional statement. In other words, the inner conditional statement is executed only if the outer conditional statement is true.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *