English

NCERT solutions for Computer Science [English] Class 11 chapter 7 - Functions [Latest edition]

Advertisements

Chapters

NCERT solutions for Computer Science [English] Class 11 chapter 7 - Functions - Shaalaa.com
Advertisements

Solutions for Chapter 7: Functions

Below listed, you can find solutions for Chapter 7 of CBSE NCERT for Computer Science [English] Class 11.


Exercise
Exercise [Pages 170 - 173]

NCERT solutions for Computer Science [English] Class 11 7 Functions Exercise [Pages 170 - 173]

Exercise | Q 1. a) | Page 170

Observe the following program carefully, and identify the error:

def create (text, freq):
            for i in range (1, freq):
              print text
create(5)           #function call
Exercise | Q 1. b) | Page 170

Observe the following program carefully, and identify the error:

from math import sqrt,ceil
def calc():
      print cos(0)
calc()                #function call
Exercise | Q 1. c) | Page 170

Observe the following program carefully, and identify the error:

mynum = 9
def add9():
       mynum = mynum + 9
       print mynum
add9()                          #function call
Exercise | Q 1. d) | Page 170

Observe the following program carefully, and identify the error:

def findValue( vall = 1.1, val2, val3):
                 final = (val2 + val3)/ vall
                 print(final)
findvalue()                      #function call
Exercise | Q 1. e) | Page 170

Observe the following program carefully, and identify the error:

def greet():
         return("Good morning")
greet() = message                    #function call
Exercise | Q 2. | Page 170

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

Exercise | Q 3. | Page 170

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

Exercise | Q 4. | Page 170

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

Exercise | Q 5. | Page 170

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

Exercise | Q 6. a) | Page 170

Differentiate between the following with the help of an example:

Argument and Parameter

Exercise | Q 6. b) | Page 170

Differentiate between the following with the help of an example:

Global and Local variable

Exercise | Q 7. | Page 170

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

Activity-Based Questions

Exercise | Q 1. | Page 171

To secure your account, whether it be an email, online bank account, or any other account, it is important that we use authentication. Use your programming expertise to create a program using a user-defined function named login that accepts userid and password as parameters (login(uid,pwd)) that displays a message “account blocked” in case of three wrong attempts. The login is successful if the user enters the user ID as "ADMIN" and the password as "St0rE@1". On successful login, display the message “login successful”.

Exercise | Q 2. | Page 171

XYZ store plans to give a festival discount to its customers. The store management has decided to give discount on the following criteria:

Shopping Amount Discount Offered
>=500 and <1000  5%
>=1000 and <2000  8%
>=2000  10%

An additional discount of 5% is given to customers who are members of the store. Create a program using a user-defined function that accepts the shopping amount as a parameter and calculates the discount and net amount payable on the basis of the following conditions:

Net Payable Amount = Total Shopping Amount – Discount.

Exercise | Q 3. | Page 171

The ‘Play and learn’ strategy helps toddlers understand concepts in a fun way. Being a senior student you have taken responsibility to develop a program using user-defined functions to help children master two and three-letter words using English alphabets and the addition of single-digit numbers. Make sure that you perform a careful analysis of the type of questions that can be included as per the age and curriculum.

Exercise | Q 4. | Page 172

Take a look at the series below:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55… To form the pattern, start by writing 1 and 1. Add them together to get 2. Add the last two numbers: 1 + 2 = 3. Continue adding the previous two numbers to find the next number in the series. These numbers make up the famed Fibonacci sequence: the previous two numbers are added to get the immediate new number.

Exercise | Q 5. a) | Page 172

Create a menu-driven program using user-defined functions to implement a calculator that performs the following:

Basic arithmetic operations(+, -, *, /)

Exercise | Q 5. b) | Page 172

Create a menu-driven program using user-defined functions to implement a calculator that performs the following:

log10(x), sin(x), cos(x)

Suggested Lab. Exercises

Exercise | Q 1. | Page 172

Write a program to check the divisibility of a number by 7 that is passed as a parameter to the user-defined function.

Exercise | Q 2. | Page 172

Write a program that uses a user-defined function that accepts name and gender (as M for Male, F for Female) and prefixes Mr/Ms on the basis of gender.

Exercise | Q 3. | Page 172

Write a program that has a user-defined function to accept the coefficients of a quadratic equation in variables and calculate its determinant. For example: if the coefficients are stored in the variables a, b, and c then calculate the determinant as b2-4ac. Write the appropriate condition to check determinants on positive, zero, and negative and output appropriate results.

Exercise | Q 4. | Page 172

ABC School has allotted unique token IDs from (1 to 600) to all the parents for facilitating a lucky draw on the day of their Annual day function. The winner would receive a special prize. Write a program using Python that helps to automate the task. (Hint: use random module)

Exercise | Q 5. | Page 172

Write a program that implements a user-defined function that accepts Principal Amount, Rate, Time, and Number of Times the interest is compounded to calculate and displays compound interest. (Hint: CI = P*(1 + r/n)nt)

Exercise | Q 6. | Page 173

Write a program that has a user-defined function to accept 2 numbers as parameters, if number 1 is less than number 2 then numbers are swapped and returned, i.e., number 2 is returned in place of number1 and number 1 is reformed in place of number 2, otherwise the same order is returned.

Exercise | Q 7. | Page 173

Write a program that contains user-defined functions to calculate area, perimeter, or surface area whichever is applicable for various shapes like square, rectangle, triangle, circle, and cylinder. The user-defined functions should accept the values for calculation as parameters and the calculated value should be returned. Import the module and use the appropriate functions.

Exercise | Q 8. | Page 173

Write a program that creates a GK quiz consisting of any five questions of your choice. The questions should be displayed randomly. Create a user-defined function score() to calculate the score of the quiz and another user-defined function remark (scorevalue) that accepts the final score to display remarks as follows:

Marks Remarks
5 Outstanding
4 Excellent
3 Good
2 Read more to score more
1 Needs to take an interest
0 General knowledge will always help you. Take it seriously.

Case Study-Based Question

Exercise | Q 1 | Page 173

For the SMIS system extended in Chapter 6 let us do the following:

  1. 7.1 Convert all the functionality in Chapters 5 and 6 using user-defined functions.
  2. 7.2 Add another user-defined function to the above menu to check if the student has short attendance or not. The function should accept the total number of working days in a month and check if the student is a defaulter by calculating his or her attendance using the formula: Count of days the student was present or the total number of working days. In case the attendance calculated is less than 78%, the function should return 1 indicating short attendance otherwise the function should return 0 indicating attendance is not short.

Let’s peer review the case studies of others based on the parameters given under “DOCUMENTATION TIPS” at the end of Chapter 5 and provide feedback to them.

Solutions for 7: Functions

Exercise
NCERT solutions for Computer Science [English] Class 11 chapter 7 - Functions - Shaalaa.com

NCERT solutions for Computer Science [English] Class 11 chapter 7 - Functions

Shaalaa.com has the CBSE Mathematics Computer Science [English] Class 11 CBSE solutions in a manner that help students grasp basic concepts better and faster. The detailed, step-by-step solutions will help you understand the concepts better and clarify any confusion. NCERT solutions for Mathematics Computer Science [English] Class 11 CBSE 7 (Functions) include all questions with answers and detailed explanations. This will clear students' doubts about questions and improve their application skills while preparing for board exams.

Further, we at Shaalaa.com provide such solutions so students can prepare for written exams. NCERT textbook solutions can be a core help for self-study and provide excellent self-help guidance for students.

Concepts covered in Computer Science [English] Class 11 chapter 7 Functions are Introduction to Functions, Functions, The Advantages of Function, User Defined Functions, Creating User Defined Function, Arguments and Parameters, Functions Returning Value, Scope of a Variable, Python Standard Library, Built-in Functions, Module, Types of Module, Built-in Modules, From Statement, Flow of Execution.

Using NCERT Computer Science [English] Class 11 solutions Functions exercise by students is an easy way to prepare for the exams, as they involve solutions arranged chapter-wise and also page-wise. The questions involved in NCERT Solutions are essential questions that can be asked in the final exam. Maximum CBSE Computer Science [English] Class 11 students prefer NCERT Textbook Solutions to score more in exams.

Get the free view of Chapter 7, Functions Computer Science [English] Class 11 additional questions for Mathematics Computer Science [English] Class 11 CBSE, and you can use Shaalaa.com to keep it handy for your exam preparation.

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×