Functions

Class 11 · Computer Science · 17 Questions

1intermediate🔍 Analyze5 marksShort Answer

Observe the following programs carefully, and identify the error:

2beginner💡 Understand2 marksShort Answer

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

3intermediate🔧 Apply2 marksShort Answer

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

4intermediate💡 Understand3 marksShort Answer

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

5intermediate🔧 Apply3 marksShort Answer

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

6intermediate💡 Understand4 marksShort Answer

Differentiate between following with the help of an example:

7beginner💡 Understand2 marksShort Answer

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

1intermediate🔧 Apply4 marksLong Answer

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

2intermediate🔧 Apply4 marksLong Answer

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 the gender.

3intermediate🔧 Apply4 marksLong Answer

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

4intermediate🔧 Apply4 marksLong Answer

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)

5intermediate🔧 Apply4 marksLong Answer

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

6intermediate🔧 Apply4 marksLong Answer

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.

7advanced🔧 Apply5 marksLong Answer

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.

8advanced🔧 Apply5 marksLong Answer

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 5: Outstanding Marks 4: Excellent Marks 3: Good Marks 2: Read more to score more Marks 1: Needs to take interest Marks 0: General knowledge will always help you. Take it seriously.

1advanced🔧 Apply5 marksCase Study

7.1 Convert all the functionality in Chapter 5 and 6 using user defined functions.

2advanced🔧 Apply5 marksCase Study

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 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.