Page 118 - PortGPT_V2.1_C7_Flipbook
P. 118

b.   y = 8

                                if (y > 5)
                                    print("y is greater than 5")
                           c.   x = 10


                                if (x = 5):
                                    print("x is equal to 5")


                    Let's exPLore                                                                    Technology Literacy

                      Surf the Internet and find more programs of looping in Python.



                       tech Practice                                                               Critical Thinking
                                                                                                     Technology Literacy
                     Write a program to:
                     1.   display a menu with different food items and their prices. Ask the user to select an item
                        from the menu by entering its corresponding number. Using conditional statements,
                        calculate the total bill based on the selected item and quantity.
                     2.   calculate the total price after applying discounts. Ask the user to enter the price and the
                        discount percentage. If the discount percentage is greater than 25%, display a message
                        indicating that the discount is not valid.
                     3.   convert the temperature from Celsius to Fahrenheit. Take the temperature as input
                        from the user. Determine if the temperature is below freezing (0°C) or not. Display the
                        appropriate message with the converted temperature.

                     4.   calculate the area of a square or circle according to the input given by the user. If the input
                        is 1, then calculate the area of a square, otherwise find the area of a circle. Ask the user to
                        input the values for square or circle based on the input.






                                                          For The Teacher



                         Discuss all the topics covered in this chapter with the students.
                         Tell the students, how to use indentation to define the body of the conditional statement.

















                  116   Premium Edition-VII
   113   114   115   116   117   118   119   120   121   122   123