Saturday, April 29, 2023

Function in Python Test 29 April 2023

 Function Chapter Test  Class - 12 A Computer Science

GBSSS Khajoori Khas

Date: 29/04/2023

 

1. What will be the output of the following code? 

def check(): 

global num 

num=1000 

print(num) 

num=100 

print(num) 

check()

 print(num)

 

2. Function can alter only Mutable data types? (True/False)

 


3. What will be the output of the following code? 

 

def drawline(char='$',time=5): 

print(char*time) 

drawline() 

drawline('@',10) 

drawline(65) 

drawline(chr(65))

 

4. What will be the output of the following code? 

def Fun1(mylist): 

for i in range(len(mylist)): 

if mylist[i]%2==0: 

mylist[i]/=2 

else: 

mylist[i]*=2 

list1 =[21,20,6,7,9,18,100,50,13] 

Fun1(list1) 

print(list1)

 

5. What will be the output of the following code? 

X = 100 

def Change(P=10, Q=25): 

global X 

if P%6==0: 

X+=100 

else: 

X+=50 

Sum=P+Q+X 

print(P,'#',Q,'$',Sum) 

Change() 

Change(18,50) 

Change(30,100)

 

6. What will be the output of the following code? 

def Alter(M,N=50): 

M = M + N 

N = M - N 

print(M,"@",N) 

return M

A=200 

B=100 

A = Alter(A,B) 

print(A,"#",B) 

B = Alter(B) 

print(A,‟@‟,B)

 

7. A Function can call another function or itself? (True/False)
8. _______ keyword is used to define a function
9. What are the different types of function? 
10. What are the different types of function arguments?




Series in Pandas Test - 29 April 2023

 Class 12 - B Series in Pandas Test:, GBSSS Khajoori Khas

1. Create a Series and Explain the use of head() and tail()

import pandas as pd

D=[10,20,30,40,50,60,70,80,90]

I=['a','b','c','d','e','f','g','h','i']

S=pd.Series(D,I)

print(S)

print(S.head())  #print —-------------------- elements

print(S.tail())     #print —-------------   elements

print(S.head(3))    #print —-----------------  elements

print(S.tail(3))    #print —----------- elements

print(S.head(-2))   #print —--- —---------------- elements (not print —------------  elements)

print(S.tail(-2))   #print —---------------- elements (not print —---------------- elements)

2. Which of the following are modules/libraries in Python?

a. NumPy

b. Pandas

c. Matplotlib

d. All of the above

3. NumPy stands for ____

a. Number Python

b. Numerical Python

c. Numbers in Python

d. None of the above

  1. _________ is an important library used for analyzing data.

a. Math

b. Random

c. Pandas

d. None of the above

  1. Important data structure of pandas is/are ___________

a. Series

b. Data Frame

c. Both of the above

d. None of the above

  1. Pandas Series can have _________________ data types

a. float

b. integer

c. String

d. All of the above

  1. _________ is used when data is in Tabular Format.

a. NumPy

b. Pandas

c. Matplotlib

d. All of the above

  1. Which of the following commands is used to install pandas?

a. pip install pandas

b. install pandas

c. pip pandas

d. None of the above