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

Ø   This process of dividing a computer program into separate independent blocks of code or sub-programs with
                  different names and functionalities is known as modular programming.
              Ø   Each independent unit of code is called a module.
              Ø   A function is a sub-program that acts on data to perform a particular task and often returns a value.
              Ø   A function is always defined before it is called.
              Ø   Functions can be broadly classified into user-defined functions, built-in functions and functions defined in
                  modules.
              Ø   User-defined functions are defined only once to perform a particular task but can be executed multiple times
                  in the same program.
              Ø   A function call statement is given to execute the statements of a function.
              Ø   Parameters of a function is the optional list of input value(s) required by the function to perform the required
                  task.
              Ø   This list of values given during the function call is the argument(s) list.






                                                  Solved Exercise


            A.  Multiple Choice Questions
               1.  What is the primary purpose of Python modules?
                  a.  To create custom data types
                  b.  To organize code into reusable units
                  c.  To perform file input/output operations
                  d.  To define mathematical equations
               2.  How do you import a Python module called "example_module"?
                  a.  import example_module
                  b.  from example_module import *
                  c.  include example_module
                  d.  require example_module
               3.  What is the result of the expression round(math.pi, 3)?
                  a.  3.141                b. 3.14                c. 3.142              d. 3.143

               4.  Which function in the math module returns the smallest integer greater than or equal to a given number?
                  a.  ceil()               b. floor()             c. sqrt()             d. pow()

               5.  What is the output of math.gcd(16, 24)?
                  a.  2                    b. 4                   c. 8                  d. 16

               6.  Which math module function calculates the square root of a number?
                  a.  sin()                b. cos()               c. sqrt()             d. pow()

               7.  What function from the random module generates a random integer between a specified range, including both endpoints?
                  a.  random.randint()
                  b.  random.random()
                  c.  random.randrange()
                  d.  random.choice()
               8.  What does the statistics.mean() function calculate?
                  a.  Mode                 b. Median              c. Mean               d. Standard deviation




                                                                                                      Modules    249
   246   247   248   249   250   251   252   253   254   255   256