Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 108 - 2625 PortGPt V2.1
P. 108

    On running the program given on previous page, we get the following output:

                          Output

                        Enter the first number: 45
                        Enter the second number: 65
                        Second number is greater than first number

                        Enter the first number: 38
                        Enter the second number: 22
                        First number is greater than second number

                      Program 4: To display one of the two alternate messages.

                          Program4.py
                       File  Edit  Format   Run   Options  Window    Help

                        #Program to display one of two alternate massages
                        passing_score = 60
                        my_score = int(input('Enter a score: '))
                        if(my_score >= passing_score):
                            print('congratulations on passing the exam')
                        else:
                            print('You failed, try harder next time')

                      On running the above program, we get the following output:

                          Output
                        Enter a score: 78
                        Congratulations on passing the exam

                        Enter a score: 45
                        You failed, try harder next time

                              Let’s catch uP

                        Find the error in the following code and rewrite it.

                        if(age > 18)
                        print(‘You are eligible to vote’)
                        else:
                        print(‘Not eligible to vote’)

                      106   Premium Edition-VII

| 103 104 105 106 107 108 109 110 111 112 113 |