Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 39 - 2501_KVS_C-7
P. 39

    print("The angle is a right angle.")
                     # Checking if the angle is a straight angle (180 degrees)

                     else:
                         if angle == 180:
                             print("The angle is a straight angle.")
                     In this example, we have used two if statements to check the value of the angle. This
                     kind of structure is useful when you want to test multiple conditions that are not directly
                     related to each other. This type of structure is called Nested if statement.  We'll go into
                     more detail about nested  if statements and their usage in class 8, where you will learn how
                     to manage multiple conditions in a more structured way.

                     Let us revise what we have learnt:
                        Programming is the process of writing precise instructions that tell a computer exactly

                          how to perform a task.
                        print() function is used to display output.
                        Decision structure in programming allows you to execute statements based on a given
                          condition.

                                                               Exercise

                              Something to know

                       A.  Answer the following questions:

                            1.    Which function is used to take user input at run time?

                            2.      Ravita wrote a program to find the sum of marks of 03 subjects. She is getting error
                                  in her program. Help her to resolve errors?
                                  Sub1=input("Enter marks of Subject1")
                                  Sub2= input("Enter marks of Subject2")

                                  Sub3= input("Enter marks of Subject3")
                                  Total=Sub1+Sub2+Sub3
                                  print(Total)

                            3.    When do you use a decision structure?
                            4.    What is if..else statement? Write its syntax?

                            5.    Why do you use int() and float() function?

                       B.   Fill in the blanks.
                            1.    ________________ is a set of statements written at the same indent.

                            2.    ________________ function is used to take user input at run time.

                            3.    ________________ is an optional component in if… else statement.

                                                                               Python Programming                       37

| 34 35 36 37 38 39 40 41 42 43 44 |