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

4.   Write a program that accepts the radius, r, height, h and slant height, sh of a cone, and calculates its volume
                 and  surface  area.  Save  the  file  as  cone.py.  Also,  execute  the  program  and  write  the  output  in  the  space
                 provided.
                 The volume of a cone = (1 / 3) πr h cubic units
                                              2
                 Surface area = π * r (r + L)

              5.  Write a program to display the area and perimeter of a rectangle.
              6.   Write a function txtDigit() that accepts a numeric digit as an argument and  displays the digit in words. For
                 example, for the input 5, it should display: five
              7.   Write a program that reads  a character as a user input, checks whether it is an alphabet, digit or a special
                 character, and displays output such as the following:

                & is a special character.
                7 is a digit.
              8.   Write a program to develop a calculator. It accepts two numbers and a character operator  ( +, -, *, /) and displays
                 the sum, difference, product, quotient , and remainder, respectively. An appropriate message should be displayed
                 if any other character operator is passed as an operator.

              9.  Write a program to accept a number and compute its factorial.
             10.  Write a program to print the factors of a given number.
             11.  Write a program to accept a number and display its reverse.
             12.  Write programs in Python to print the following patterns:

                                                         Python Patterns

























             13.   Write a program that accepts two strings and checks whether the second string is a substring (forms part) of the
                 first string. If yes, the program should display the starting index that marks the beginning of the second string;
                 otherwise, it should display 'Substring DOES NOT exist'.

             14.   Write a program that accepts two strings and appends the shorter string after the longer one. For example, if
                 string1 is 'Hi' and string2 is 'Hello', the output would be 'HelloHi'.

             15.   Write a program that accepts a string s and a number n. The program displays all vowels in the string n number
                 of times, in the string in the same sequence in which they appear in the input string. For example, if the value of
                 s is helicopter and the value of n is 5, the output should be:

                 eeeeeiiiiieeeee





                                                                                                      Practical  383
   380   381   382   383   384   385   386   387   388   389   390