12th Standard CBSE Computer Science Functions Important Questions
By QB365
12th Standard CBSE Computer Science Functions Important Questions
QB365-Question Bank Software
Functions Important Questions
12th Standard CBSE
-
Reg.No. :
Computer Science
-
What will be the output of the following code?
print (type(type(int)))(a)type "int'
(b)< class 'type' > (c)Error
(d)< class "int' >
-
What will be the output of the following code?
L = ['a','b','c','d']
print (" ".join(L))(a)Error
(b)a b c d
(c)['a':b':c':d']
(d)None
-
What is called when a function is defined inside a class?
(a)Module
(b)Class
(c)Another function
(d)Method
-
Which of the following is the use of idf) function in python?
(a)Id() returns the identity of the object
(b)Every object doesn't have a unique ID
(c)All of the mentioned
(d)None of the mentioned
-
Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list after list1.pop(1)?
(a)[3,4, 5, 20, 5, 25, 1, 3]
(b)[1, 3, 3, 4, 5, 5, 20, 25]
(c)[3,5, 20, 5, 25, 1, 3]
(d)[1,3,4,5,20,5,25]
-
Find and write the output of the following Python code:
def fun(s):
k=len(s) .
m=""
for i in range(0,k):
if(s[i].isupper()):
m=m+s[i].lower()
elif s[i].isalpha():
m=m+s[i].upper()
else:
m=m+'bb'
print(m)
fun('schooI2@com')(a) -
What do you understand by local and global scope of variables? How can you access a global variable inside the function, if function has a variable with same name.
(a) -
What are the possible outcome(s) executed from the following code? Also specify the maximum and minimum values that can be assigned to variable
PICKER. import random
PICKER = random.randint (0, 3)
COLOR = ["BLUE","PINK", "GREEN", "RED"]
for I in COLOR:
for J in range (1, PICKER) :
print (I, end = " ")
print ()(i) (ii) (iii) (iv) BLUE BLUE PINK BLUEBLUE PINK BLUEPINK PINKGREEN PINKPINK GREEN BLUEPINKGREEN GREENRED GREENGREEN RED BLUEPINKGREENRED REDRED (a) -
How can we import a module in Python?
(a) -
What are the differences between parameters and arguments?
(a) -
What are default arguments?
(a) -
What are keyword arguments?
(a) -
What are the advantages of keyword arguments?
(a) -
Write a generator function generatesq ( ) that displays the square roots of numbers from 100 to n where n is passed as an argument.
(a) -
What are the advantages of dividing a program into modules.
(a) -
Differentiate between Built-in functions and user defined functions.
(a) -
Differentiate between Built-in functions and functions defined in modules.
(a) -
Write a program that reads a number, then converts it into octal, hexadecimal, ASCII and Unicode string using built in functions of Python.
(a) -
Write the corresponding Python expression for the following mathematical expressions:
i) 2-ye2y +4y ii) Iex- x2 - xI(a) -
Write a Python program using functions to calculate area of a triangle after obtaining its three sides.
(a) -
How are following two statements different?
import math
from math import *(a) -
What will be the output of the following code
sinppet and why?
# module calculate.py
''''''This module will be imported"""
defsum 0:
"""Prints sum of 10 and 5"''''
b=5
a=10
print ("sum=",a+b)
return
def diff():
"""prints difference of 20 and 5"""
a=30
b=5
print ("Difference=", a-b)
return
print ("This will print something")
greet= "Hello!"
#Fun.py import calculate print calculate.gra(a) -
What is an execution frame?
(a) -
What is the difference between passing mutable type arguments and immutable type arguments to the function?
(a) -
What are Positional arguments?
(a) -
Is indentation required in Python?
(a) -
What is a default parameter? How is it specified?
(a) -
From the function calls given below for a function defined as def fun(p,t,r=7, c=8): determine which is valid and which one is invalid. Give reasons.
(i) fun(p=5, t=2)
(ii) fun(c=2, r=7)
(iii) fun (80,p=7,r=2)(a) -
What is name resolution rule? Explain it.
(a) -
What will be the output of the following program.?
1 def increase (x): (b) a=l
2 a= a+x def ft):
3 return a=10
4 print(a)
5 a=20
6 b=5
7 increase (b)
8 print(a)(a) -
Spot the errors and rewrite the corrected codes.
total=0;
def sum(arg1, arg2) :
total = arg1 + arg2
print("Total:", total)
return total
sum (10,20)
print("Total:" total)(a) -
What will following function print when called?
def addEm (x,y,z):
return x+y+z
print(x+y+z)(a) -
Predict the output of the following codes.
(a) num=l (Each part carries 2 marks)
def myfunct):
returnnum
print (num)
print (myfunc ())
print (num)(a) -
Write a function to calculate volume of a box with appropriate default values for its parameters. Your function should have the following input parameters:
a) Length of box b) width of box c) height of box(a) -
Write a function that takes a number as argument and calculates cube for it. The function does not return a value. If there is no value passed to the function in function call, the function should calculate cube of 2.
(a) -
Write a function that receives two string arguments and checks whether they are same-length strings (returns True in this case otherwise False)
(a) -
Write a function namely nthRoot() that receives two parameter x and n and return nth root of x ie. x1/n The default value of n is 2
(a) -
Write a function that takes two numbers and returns the number that has minimum one's digit.
(a) -
Write a void function that receives a 4 digit number and calculates the sum of squares of first two digits of the number and last two digits of the number egoif 1233 is passed as argument then function should calculate (12)2+(33)2
(a) -
Write a function to swap two numbers.
(a) -
What are the rules to define a' function in Python?
(a) -
What does the len() function do?
(a) -
How can you make a module 'helloworld' out of these two functions?
def hello():
print ('Hello,',)
def world():
print ('World!')(a) -
Define pow(x, y) function in Python.
(a) -
What is a Python module? What is its significance?
(a) -
"Python has certain functions that you can readily use without having to write any special code." What type of functions are these ?
(a) -
What is the utility of built-in function help () ?
(a) -
What is the utility of Python standard library's math module and random module?
(a) -
Explain Scope of Variables.
(a) -
Find the error
def minus (total, decrement)
output = total - decrement
return output(a) -
What would be the output produced by the following code:
import math
import random
print (math. ceil (random.random( )))(a) -
Find the error(s) in the following code and correct them:
1. def describe intelligent life form ():
2. height = input ("Enter the height")
3. raw_input ("Is it correct?")
4. weight = input ("Enter the weight")
5. favourite-game = input ("Enter favorite game")
6. print ("your height", height, 'and weight', weight)
7. print ("and your favourite game is", favouritism, '.')(a) -
Write a function that:
(i) Asks the user to input a diameter of circle in inches.
(ii) Sets a variable called radius to one half of that number.
(iii)Calculate the area of circle.
(iv) Print the area of circle with appropriate unit.
(v) Return this same amount as the output of the function(a) -
What would be the output of the following ?
Explain.
def f1()}:
n = 44
def f2 ():
n= 77
print ("value of n", n ())
print ("value of n",n)(a) -
What do you mean by globals() and locals() functions
(a) -
What are docstrings ?How are they useful?
(a) -
Explain global vs. local variables.
(a) -
Explain anonymous functions.
(a) -
Identify the following function definitions as void or non-void function.
(i) def fun():
print("Hello!")
(ii) def fun():
print("Hello!")
return(1)
(iii) def fun():
print("Hello!")
retum(1)
(iv) def fun():
return(2)
print("Hello")(a) -
How are docstring different from comments?
(a) -
Give the output of the following code:
def Hello(Sum):
fori in Sum:
print(i)
S=("Hii", "Hello", "Namaste")
Hello(S)(a)