0% found this document useful (0 votes)
7 views

Functions CBSE Class12 Questions

Uploaded by

abhigyan8182
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Functions CBSE Class12 Questions

Uploaded by

abhigyan8182
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Class 12 CBSE: Function Chapter - Practice Questions

1. Write a Python function `add_two_numbers` that takes two numbers as arguments and returns

their sum.

Example: Input: add_two_numbers(3, 5), Output: 8

2. Create a function `is_even` that checks whether a given number is even or not. It should return

`True` if the number is even, and `False` otherwise.

Example: Input: is_even(4), Output: True

3. Write a function `greet_user` that accepts a name as input and prints a greeting in the format:

"Hello, [Name]!".

Example: Input: greet_user('Riya'), Output: Hello, Riya!

4. Write a Python function `find_square` to calculate and return the square of a number.

Example: Input: find_square(7), Output: 49

5. Create a function `is_prime` to check if a given number is a prime number. Return `True` if the

number is prime, otherwise return `False`.

Example: Input: is_prime(11), Output: True

6. Develop a function `simple_interest` to calculate simple interest. The function should take

principal (P), rate (R), and time (T) as inputs.

Formula: SI = (P * R * T) / 100

Example: Input: simple_interest(1000, 5, 2), Output: 100


7. Create a function `area_of_rectangle` to calculate the area of a rectangle. The function should

have default values for length and breadth as 1.

Example: Input: area_of_rectangle(5, 10), Output: 50

Input: area_of_rectangle(), Output: 1

8. Write a recursive function `factorial` to calculate the factorial of a number.

Example: Input: factorial(5), Output: 120

9. Develop a recursive function `sum_of_digits` to calculate the sum of the digits of a number.

Example: Input: sum_of_digits(1234), Output: 10

10. Create a recursive function `fibonacci` to return the nth Fibonacci number.

Example: Input: fibonacci(6), Output: 8

11. Write a Python function `count_vowels` to count the number of vowels in a given string.

Example: Input: count_vowels('education'), Output: 5

12. Create a function `reverse_string` that takes a string and returns the reversed version of the

string.

Example: Input: reverse_string('Python'), Output: nohtyP

13. Write a function `is_palindrome` to check if a string is a palindrome (reads the same forwards

and backwards).

Example: Input: is_palindrome('level'), Output: True

14. Create a function `apply_operation` that accepts two numbers and a function as input. The

function should apply the operation (passed as an argument) to the numbers.


Example: Input: apply_operation(4, 5, add_two_numbers), Output: 9

15. Write a function `find_largest` that accepts three numbers as arguments and returns the largest

number.

Example: Input: find_largest(10, 20, 15), Output: 20

You might also like