Page 254 - Computer Science Class 11 Without Functions
P. 254

import math

              side1 = int(input('Enter length of side 1 :  '))
              side2 = int(input('Enter length of side 2 :  '))
              side3 = int(input('Enter length of side 3 :  '))

              s = (side1+side2+side3)/2
              area = math.sqrt(s*(s-side1)*(s-side2)*(s-side3))

              print('The area of triangle is ',  area)
           2.  Stuti has studied the math module in class today. Her teacher has asked her to write a program to accept an angle in
              degrees as an input, convert it to radians and then display sine, cosine and tangent of the angle using the  functions from
              math module. Help her complete the task.
         Ans:  '''

              Objective: To print sine, cosine, and tangent of the angle in degrees
              Input: angle - numeric value
              Output: sine, cosine, and tangent of the angle
              '''

              import math

              angleDegree = int(input('Enter angle in degrees: '))

              angleRadian = angleDegree * (math.pi/180)

              print('The angle in radians is  ',   angleRadian)
              print('The sine of angle ',   angleDegree ,   ' degrees is ',   math.sin(angleRadian ))
                print('The cosine of angle ',   angleDegree ,   ' degrees is ',   math.cos(angleRadian
              ))
                print('The tangent of angle ',   angleDegree ,   ' degrees is ',   math.tan(angleRadian
              ))



                                                  Assessment


        A.  Multiple Choice questions
           1.  Consider the given Python code.

              import random
              devices = ['Monitor',   'Keyboard',   'Mouse',   'Speaker']
              for i in range(random.randint(0,  2)):
                  print(devices[i],  '*',  end=' ')
              Which of the following lines of output will never be produced on execution of the above code?
              a.  Monitor * Keyboard *
              b. Monitor*
              c. Monitor * keyboard * Mouse *
              d. None of the above

         252    Touchpad Computer Science-XI
   249   250   251   252   253   254   255   256   257   258   259