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

Answer The Following Questions Using Python Programming Language

This document contains a summary of a computer science test for class 12. It includes 14 multiple choice or short answer questions testing Python programming concepts like functions, variables, errors, recursion, dictionaries, strings and Fibonacci series. Students are asked to write Python code to solve problems, define terms, analyze code samples, and describe function outputs and behavior.

Uploaded by

Manav Arya Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
362 views

Answer The Following Questions Using Python Programming Language

This document contains a summary of a computer science test for class 12. It includes 14 multiple choice or short answer questions testing Python programming concepts like functions, variables, errors, recursion, dictionaries, strings and Fibonacci series. Students are asked to write Python code to solve problems, define terms, analyze code samples, and describe function outputs and behavior.

Uploaded by

Manav Arya Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

APEEJAY SCHOOL, SAKET

FIRST UNIT TEST 2021-22


CLASS 12
COMPUTER SCIENCE (083)
Time 1 hour M.M. 25
Answer the following questions using Python programming language

1. Which keyword is used to define a user defined function 1


2. What are the rules to be followed while giving default arguments in 1
user defined functions?
3. Give one advantage and one disadvantage of recursive functions. 1
4. What are local and global variables? Illustrate with example 2
5. Differentiate between syntax error and run time error. Give a suitable example 2
in Python to illustrate both.
6. Will the following code execute successfully? Write the output if yes, 2
otherwise rewrite the corrected code, while explaining each correction.
def Interest(P,R=12,T):
I = (P*R*T)/100
print(I)

Interest(20000,.08,15) #Line 1
Interest(T=10,20000,.075) #Line 2
Interest(50000,.07) #Line 3
Interest(P=10000,R=.06,Time=8) #Line 4
Interest(80000,T=10) #Line 5
7. What will be the output of following code? Which argument method 2
is used in the following program?
def sum(*n):
s=0
for i in n:
print i
sum()
sum(10)
sum(10,20)
sum(10,20,30)
8. What will be the output of following code? 2
def drawline(char='$',time=5):
print(char*time)
drawline()
drawline('@',10)
drawline(65)
drawline(chr(65))
9. Call the given function using KEYWORD ARGUMENT method, 2
with values 20 and 30
def Swap(num1,num2):
num1,num2=num2,num1
print(num1,num2)
10. Write the output of the following python code: 2
msg = "World is Beautiful again 2022"
print(msg[3:])
print(msg[:4],msg[4:])
print(msg[::-1])
print(msg[0:4],msg[11:10])

11. What possible outputs(s) are expected to be displayed at the time of execution 2
of the following code? Specify the maximum possible value that would be
assigned to each of the variables FROM and TO.
import random AR=[20,30,40,50,60,70];
FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO+1):
print (AR[K],end=”#“)

(i) 10#40#70# (ii) 30#40#50#


(iii) 50#60#70# (iv) 40#50#70#

12. Given the following declaration 2


Myd={„empno‟:1,‟name‟:‟Vikrant‟,‟salary‟:50000}
Chander, Python programmer wants to print all the keys of dictionary and
values stored in dictionary, Help Chander by filling the blanks given in
print() statement to achieve the task:
print( )
print( )

13. Does the given function represent recursion? How many times will this 2
function execute?

14. Write a function “fibo” that takes a number n and display the nth term of 2
Fibonacci series.

You might also like