Page 2 - HA
P. 2

Home Assignment


                   if a + b:
                       print('True')
                   else:
                     print('False')
               6)  What is the difference between else and elifconstruct of if statement?

               7)  What is the purpose of range() function? Give oneexample.
               8)  Program to print positive differences of two numbers.

               9)  Program to check whether a number is positive, negative or zero.

               10) Display the appropriate message (not case sensitive) as per the colour of signal at the road
                   crossing.
                   Signal colour  Message
                   RED            STOP
                   ORANGE         BE SLOW
                   GREEN          GO

               11) Let us write a program to create a simple calculator to perform basic arithmetic operations
                   on two numbers.
                   The program should do the following:
                   •  Accept two numbers from the user.
                   •  Ask user to input any of the operator (+, -, *, /).An error message is displayed if the user
                     entersanything else.
                   •  Display only positive difference in case of theoperator "-".
                   •  Display a message “Please enter a value otherthan 0” if the user enters the second
                     number as0 and operator ‘/’ is entered.
               12) Write a program to find the largest/smallest of three number.

               13) Write a program that takes the name and age of theuser as input and displays a message
                   whether theuser is eligible to apply for a driving license or not.

                   (the eligible age is 18 years).

               14) Write a program to check if the year entered by theuser is a leap year or not.
               15) Write a program to find the grade of a student whengrades are allocated as given in the
                   table below.
                   Percentage of Marks      Grade
                   Above 90%                A
                   80% to 90%               B
                   70% to 80%               C
                   60% to 70%               D
                   Below 60%                E
                   Percentage of the marks obtained by the student is inputto the program.

               16) Write a program to find roots of a quadratic equation (all the three types of roots)
   1   2   3   4