CLASS - VII | CHAPTER -6 ( FUN WITH FUNCTIONS ) SOLVED WORKSHEET

CLASS - VII
CHAPTER - 6 ( FUN WITH FUNCTIONS )
Worksheets

 

Objective Type Questions 

Question 1 Function in a program decreases readability
                    Option 1 True
                    Option 2 False

Answer: Option 2 


Question 2 Function in a program increases code reusability 
                    Option 1 True 
                    Option 2 False 

Answer: Option 1 


Question 3 Functions in programming help in reducing code redundancy 
                    Option 1 True 
                    Option 2 False 

Answer: Option 1


Question 4 A function can return a value 
Option 1 True 
Option 2 False 

Answer: Option 1 


Question 5 What do we call the variables found in the definition of the function on which further operations may be performed? 
Option 1 Return value 
Option 2 Parameter(s) 
Option 3 Data types 
Option 4 None of the above 

Answer: Option 2


Standard Questions 

1. Explain  advantages of using functions. 
ANSWER: Few of the advantages of using functions are: 
                    Increases readability makes code organized and easy to understand. 
                    Reduces code length: redundant code is removed and replaced by functions. 
                    Reusability: Code reusability increases.


2. What are function parameters? 
ANSWER: The variables accepted by a function to perform the set of tasks defined in its body are called function parameters.


3. Explain how functions help in reducing redundancy of code. 
ANSWER: The main idea behind using a function in your code is to keep the code DRY (Don’t Repeat Yourself). Cutting  out repeated commands helps to minimize errors, keeps code short, and saves programming time.


4. Can functions return a value? 
ANSWER:  Yes functions can return a value.



5. Explain what the output of below program will be:
            def test(x, y):
             if x > y: 
             return y 
             def test1(x, y, z): 
             return test(x, test(y, z)) 
             print(test1(2, 7, -1)) 

ANSWER : 1


6. Find an error in the below program:
        def sum(numbers): 
        total = 0
        for x in number: 
        total += x 
        return total 
        print ( sum ( ( 1 , 2 , 3 , 4 , 5 ) ) )

ANSWER: Variable “number” is not defined anywhere in the program.