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.
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.
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) 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
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 .math.pow(x, y)belongs to the math module. It also returns , but as a float.
Example:
pow(5, 2)gives 25math.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
Free with a Super Tutor account
a) Argument and Parameter
b) Global and Local variable
Free with a Super Tutor account
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?
Are these NCERT Solutions for Functions free?
How should I revise Functions for Class 11 exams?
Sources & Official References
- NCERT Official — ncert.nic.in
- CBSE Academic — cbseacademic.nic.in
- CBSE Official — cbse.gov.in
- National Education Policy 2020 — education.gov.in
Content is aligned to the official syllabus. Refer to the board website for the latest curriculum.
More resources for Functions
Practice Quiz
Test yourself with a quick quiz
Important Questions
Exam-style questions with answers
Revision Notes
Key points for last-minute revision
Formula Sheet
The chapter's formulas in one place
Chapter Summary
Understand the chapter at a glance
Concept Maps
See how topics connect
Study Plan
Step-by-step plan for this chapter
Flashcards
Quick-fire cards for active recall
Syllabus
What topics to cover
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.