Page 142 - Computer Science Class 11 With Functions
P. 142

2.  Assertion(A):  sum Marks is a valid identifier.
              Reasoning (R):  An identifier cannot contain any space or a special symbol except an underscore.
           3.  Assertion (A):  The following statement will not be executed in a Python program.
                          # This is a practice session
              Reasoning (R):  The above is an example of a comment.
           4.  Assertion(A):  eval() is a built-in function.
              Reasoning(R):  A built-in function is a pre-defined function in Python.
         Ans.  1. a  2. d  3. a  4. b


               Case Based Questions


           1.  Simrat has started programming in Python. She has studied print() with sep and end clauses. Now, she wants to accept the
              name, DOB, Contact No, and hobby of her friends and then display the data in the following format:
              YOUR DATA


              Name:
              Date of Birth:
              Contact No:
              ********************************************************************************************
              Hobby:


              Help her complete the task.

         Ans.  name = input('Enter your name :  ')
              dob  = input('Enter your date of birth as dd-mm-yy :  ')
              contactNo = input('Enter your contact number :  ')
              hobby = input('Enter your hobby :   ')
              print()
              print('YOUR DATA')
              print()


              print('Name :  ',   name)
              print('Date of Birth : ',   dob)
              print('Contact No:  ',   contactNo)
              print('**********************************************')
              print('Hobby :   ',   hobby)
           2.  Rahul has written his first program in Python to display the cube of a number. He saved the file as cube.py but the program
              could not be executed successfully as it has some errors. Identify the errors and rewrite the correct program.
              num = input('Please enter a number')
              cube = num * num * num
              Print cube
         Ans.  num is not typecasted to int and print function not used properly.

              num=int(input('Please enter a number'))
              cube=num * num * num
              print(cube)



         140   Touchpad Computer Science-XI
   137   138   139   140   141   142   143   144   145   146   147