Page 336 - Computer Science V2.0 Class 11
P. 336

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:
                                4
                             3
                          2
                    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.




















               322   Touchpad Computer Science (Ver. 2.0)-XI
   331   332   333   334   335   336   337   338   339   340   341