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

10.  Write the escape sequences for the following:
                  a.  Horizontal tab
                  b.  Newline
             Ans:  a.  \t     b) \n
              11.  What will be the output produced on execution of each of the following instructions in Python shell:
                  a.  >>> print('We all like \n to play')
                  b.  >>> print('Tomorrow is a \t holiday')
                  c.  >>> Print('Tomorrow is a \t holiday')

             Ans:  a.  We all like
                    to play
                  b.  Tomorrow is a    holiday
                  c.  NameError: name 'Print' is not defined.
              12.  Give output produced on execution of each of the following:
                  a.  print('Sun','Mon','Tue', end='@@@')
                  b.  print('Jan','Feb','Mar',sep='-', end='#Quarter#')

             Ans.  a.  Sun Mon Tue@@@
                  b.  Jan-Feb-Mar#Quarter#
              13.  Write Python statements (to be executed in IDLE environment)  to accept the first name and last name of a person and print
                  them in one line, separated by a space:
             Ans:  >>> fName = input('Enter your first name :')
                  >>> lName = input('Enter your last name :')
                  >>> print(fName, lName)
              14.  Write Python statements (to be executed in IDLE environment)  to accept the first name and last name of a person and print
                  them in one line, separated by ***.
             Ans:  >>> fName = input('Enter your first name :')
                  >>> lName = input('Enter your last name :')
                  >>> print(fName, lName, sep='***')
              15.  Write a program to accept the radius of a circle and print its circumference.
             Ans:  #Objective: To compute circumference of a circle.
                  #User input: Radius of a circle.
                  #Output: Circumference of a circle, having a given radius
                  pi = 3.14
                  radius = int(input('Enter the radius of a circle : '))
                  circumference = 2 * pi * radius
                  print('radius:', radius, 'circumference:', circumference)


                   Assertion and Reasoning Based Questions


               The following questions are Assertion(A) and Reasoning(R) based questions. Mark the correct choice as
               a.  Both A and R are true and R is the correct explanation of A
               b.  Both A and R are true and R is not the correct explanation of A
               c.  A is true but R is false
               d.  A is false but R is true
               1.  Assertion (A):  myMarks is an identifier.
                  Reasoning (R):  An identifier begins with a letter or underscore character,   followed by a sequence of letters and digits.



                                                                                    Basics of Python Programming  139
   136   137   138   139   140   141   142   143   144   145   146