Skip to main content
Chapter 7 of 11
NCERT Solutions

Functions — NCERT Solutions

CBSE · Class 11 · Computer Science

NCERT question answers for Functions, CBSE Class 11 Computer Science: 7 textbook questions solved step by step. Covers Exercise.

42 questions80 flashcards6 formulas & key relations5 concepts

Interactive on Super Tutor

Studying Functions? Get the full interactive chapter.

Quizzes, flashcards, AI doubt-solver and a step-by-step study plan — built for NCERT solutions and more.

Free trial, no card needed.

7 Questions Solved · 1 Section

The first 4 solutions are open to read. The other 3 are free with a Super Tutor account. Unlock all 7 free in Super Tutor

Exercise

1Observe the following programs carefully, and identify the error:

a) def create (text, freq):
for i in range (1, freq):
print text
create(5) #function call
b) from math import sqrt,ceil
def calc():
print cos(0)
calc() #function call
c) mynum = 9
def add9():
mynum = mynum + 9
print mynum
add9() #function call
d) def findValue( val1 = 1.1, val2, val3):
final = (val2 + val3) / val1
print(final)
findvalue() #function call
e) def greet():
return("Good morning")
greet() = message #function call

Show solution

a) create(5) is incorrect because the function create(text, freq) requires two arguments, but only one is given. Also, print text uses old syntax; in Python it should be print(text).

b) cos(0) causes an error because cos has not been imported. Only sqrt and ceil were imported from math. Use from math import cos or import math and then math.cos(0).

c) mynum = mynum + 9 gives an error because mynum is treated as a local variable inside add9(), but it is used before being assigned there. To use the global variable, declare global mynum inside the function.

d) The function header is wrong: a parameter with a default value cannot come before non-default parameters. So val1 = 1.1 must be placed after val2 and val3, or all following parameters must also have default values. Also, findvalue() is wrong because the function name is findValue().

e) greet() = message is invalid because a function call cannot be on the left side of an assignment. It should be message = greet().

Not sure why a step works? check your working in Super Tutor

2How is math.ceil(89.7) different from math.floor(89.7)?Show solution

math.ceil(89.7) gives the smallest integer greater than or equal to 89.7, so it is 90.

math.floor(89.7) gives the greatest integer less than or equal to 89.7, so it is 89.

So, ceil rounds up and floor rounds down.

Not sure why a step works? check your working in Super Tutor

3Out of random() and randint(), which function should we use to generate random numbers between 1 and 5. Justify.Show solution

We should use randint() because it generates a random integer in a given range. For numbers between 1 and 5, randint(1,5) will return an integer from 1 to 5, including both ends.

random() gives a random real number between 0.0 and 1.0, so it is not suitable for directly generating integers from 1 to 5.

Not sure why a step works? check your working in Super Tutor

4How is built-in function pow() function different from function math.pow() ? Explain with an example.Show solution

The built-in pow() function and math.pow() both compute powers, but they differ in return type and usage.

  • pow(x, y) is a built-in function. It returns xyx^y.
  • math.pow(x, y) belongs to the math module. It also returns xyx^y, but as a float.

Example:

  • pow(5, 2) gives 25
  • math.pow(5, 2) gives 25.0

Also, math.pow() requires importing the math module.

Not sure why a step works? check your working in Super Tutor

5Using an example show how a function in Python can return multiple values.

Free with a Super Tutor account

6Differentiate between following with the help of an example:

a) Argument and Parameter
b) Global and Local variable

Free with a Super Tutor account

7Does a function always return a value? Explain with an example.

Free with a Super Tutor account

3 more solved questions in Functions

They are free with a Super Tutor account, along with practice quizzes and flashcards for this chapter. Free to start, no card needed.

Frequently Asked Questions

What are the important topics in Functions for CBSE Class 11 Computer Science?
Key topics in Functions include Core Ideas of Functions, User Defined Functions, Arguments, and Parameters, Return Values and Multiple Values, Flow of Execution and Function Call Order. Study these first, then practise questions on each for Class 11 exams.
Are these NCERT Solutions for Functions free?
The first 4 of the 7 solutions on this page are open to read. The other 3 are free with a Super Tutor account — signing up is free and needs no card.
How should I revise Functions for Class 11 exams?
Learn the core ideas first, then work through the 42 practice questions on Functions. Revise definitions regularly and use flashcards for quick recall before the exam.

Sources & Official References

Content is aligned to the official syllabus. Refer to the board website for the latest curriculum.

For serious students

Get the full Functions chapter — start free.

Quizzes, flashcards, an AI doubt solver and a study plan for CBSE Class 11 Computer Science. Free to start, no card needed.