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

7.  What will be the output produced on execution of the following code snippets::
                  (i)  x = 5
                      y = 2
                      while x >= y:
                          print(x, y, sep='#')
                          x = x - 1
                          y = y + 1
                  (ii)  for x in 'World Peace':
                          if x == ' ':
                              continue
                          else:
                              print(x, end = ' ')
                  (iii)  num = 5
                      while(True):
                          print(num)
                          num = num - 1
                          if num == 2:
                              break
               8.  What is the use of the pass statement in Python? Illustrate your answer with a suitable example.
            E.  Application Based Questions
               1.  Write a program to display the sum of first n natural numbers.
               2.  Write a program to accept 10 numbers and display the sum of only odd numbers.
               3.  Write a program that accepts as input the count of numbers (say, n) to be entered, followed by the numbers, and displays
                  the second largest number.
               4.  Write a program in Python that takes n as input from the user and prints first n elements of a Fibonacci sequence
                  0       1        1       2        3        5       8…………….
               5.  Write a Python Script to accept two numbers and display all prime numbers between those two numbers.
               6.  Write a program to accept a number and check whether it is a palindrome.
               7.   Write a program in Python to accept names and marks of 10 students and then display the following:
                  a.  Average Marks
                  b.  The student with the highest marks
                  c.  The student with the lowest marks
               8.  Write a program to accept the values of p and n as input from the user and then display the sum of given series:
                          3
                       2
                              4
                  1-p+p -p +p - ...p n
               9.  Write a program to check whether a number is a perfect number or not.
                  (Note: A perfect number is positive and is equal to the sum of its divisors)
              10.  Write Python functions to display the following patterns.

                   i.                               ii.                               iii.




















                                                                                              Looping in Python  273
   270   271   272   273   274   275   276   277   278   279   280