Class12 CS QuestionPaper Functions
Class12 CS QuestionPaper Functions
print(type(3.0 + 4))
print(i)
10. Write any two differences between global and local variables.
return a + b
12. Write a function `count_vowels(s)` that returns the number of vowels in a string.
13. What are default and keyword arguments? Give suitable code examples for each.
14. Write a Python program using recursion to find the sum of digits of a number.
16. Write a recursive function to generate and print the Fibonacci series up to n terms.
Solutions
Section A Answers:
1. b) _my_var
2. <class 'float'>
3. d) tuple
4. b) len()
5. b) Nested Function
Section B Answers:
Example:
8. def check_even_odd(n):
if n % 2 == 0:
print("Even")
else:
print("Odd")
9. i = 1
while i <= 5:
print(i)
i += 1
Section C Answers:
11. Output: 5 6
vowels = "aeiouAEIOU"
if n == 0: return 0
Section D Answers:
lst = list(set(lst))
lst.sort()
nums = [4, 7, 2, 7, 1, 9]
print("Second Largest:", second_largest(nums))
if n <= 1: return n
for i in range(5):