Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 128 - 2615_KEC
P. 128

    Program34.py
                       File  Edit  Format    Run   Options   Window    Help

                       # Library Membership Fee Calculator
                       # Fee is Rs. 150 if age is between 5 to 18.
                       # Fee is Rs. 400 if age is between 19 to 50.
                       # Fee is Rs. 250 if age is above 50.
                       age = int(input("Enter your age: "))
                       if age >= 5 and age <= 18:
                           print("The membership fee is Rs. 150.")
                       elif age >= 19 and age <= 50:
                           print("The membership fee is Rs. 400.")
                       elif age > 50:
                           print("The membership fee is Rs. 250.")
                       else:
                           print("Membership not available for this age.")

                          Output
                       Enter your age: 18
                       The membership fee is Rs. 150.

                           REVISIT

                            A control structure is a programming language construct which affects the flow of the execution of a
                          program.
                            The statements that are executed in sequential order, i.e. one after the other without any jumps, are called
                          sequential statements.
                            When programmers are required to execute a particular set of statements depending upon a particular test
                          condition, a branching statement is required.
                            Logical operator return a Boolean result (True or False) based on the logical relationship between the
                          conditions.
                            String is a sequence of characters which is enclosed or surrounded by single (' '), double (" ") or Triple (''' ''')
                          quotes.

                      126   Premium Edition-VII

| 123 124 125 126 127 128 129 130 131 132 133 |