[go: up one dir, main page]

0% found this document useful (0 votes)
15 views7 pages

Abhyas Test 1 - Descriptive - QP

The document consists of a series of questions related to Python programming, divided into five sections with varying marks. It covers topics such as Python syntax, functions, data structures, and error handling. Each question requires the respondent to predict outputs, correct code, or explain concepts in Python.

Uploaded by

Bhuvan Harshaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views7 pages

Abhyas Test 1 - Descriptive - QP

The document consists of a series of questions related to Python programming, divided into five sections with varying marks. It covers topics such as Python syntax, functions, data structures, and error handling. Each question requires the respondent to predict outputs, correct code, or explain concepts in Python.

Uploaded by

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

Marks

Q.No.
Section – A: Answer all the questions [ 09 X 01 = 09 Marks] Allotte
:
d
How a>b>c will be interpreted by Python? 1
1
a) a>b or a>c b) a>b not a>c c) a>b and a>c d) a>b && a>c
Mr Subodh is working with a dictionary in python for his project. He 1
wants to display the key, and value pair but confuse by these
2 statements, choose the correct statement for him:
a) dict.values() b) disct.keys() c) dict.keysvalues() d) dict.items()
Following set of commands are executed in shell, what will be the 1
output?
3 >>>str="hello"
>>>str[:2]
a) he b) lo c) olleh d) hello
What is the output of the 1
following?
x = ['ab', 'cd']
for i in x:
4
i.upper()
print(x)
a) [‘ab’, ‘cd’] b) [‘AB’, ‘CD’] c) [None, None] d) none of the
mentioned
Consider the given expression: 1
not True and False or True
5 Which of the following will be correct output if the given expression is
evaluated?
a) True b) False c) NONE d) NULL
What is the output of below 1
program?
def cube(x):
6 return x * x * x
cube(3)
print x
a) 9 b) 3 c) 81 d) 27
7 Archi is confused between arguments and parameters. Select the fact 1
about argument and parameter and solve her doubt.

a) arguments are those values being passed and parameters are those
values received

b) parameters are those values being passed and arguments are those
values received

c) arguments appear in the function header and parameters appear in


the function call

d) arguments can have same name and parameters can have value
type
Rashmin is learning the python functions He read the topic types of 1
python functions. He read those functions already available in the
python library is called ___________. Fill appropriate word in this blank:
8
a) UDF (User Defined Function) b) Built-in Functions c) Modules d)
Reusable Function
Q9 is ASSERTION AND REASONING based questions. Mark the
correct choice as.
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False (d) A is false but R is True
Assertion (A):- Process of inserting an element in stack is called Push. 1
9 Reasoning (R):- In a stack, if a user tries to remove an element from empty stack it is
called overflow.
Q.No.
Section – B : Answer all the questions [ 03 X 02 = 06 Marks]
:
Predict the output for the following code: 2
s=”welcome2cs”
n=len(s)
m= “ ”
for i in range(0, n):
if (s[i] >=’a’ and s[i]<=’m’):
m=m+s[i].upper()
10 elif (s[i] >=’n’ and s[i]<=’z’):
m=m+s[i].lower()
else:
m=m+’&’
print(m)
=

11 Rewrite the following code after correcting the errors: 2


def alpha(n, string=’xyz’, k=10):
return beta(string)
return n
def beta(string)
return string==str(n)
print(alpha(“Valentine’s Day”):)
print(beta(string=’true’))
print(alpha(n=5, “Good-bye”):)
=

2
Predict the output of the Python code given
below:

x=1
def fun1( ):
x=3
x=x+1
print(x)

12 def fun2( ):

global x

x=x+2

print(x)
fun1( )
fun2( )
=

Q.No.
Section – C : Answer all the questions [ 02 X 03 = 06 Marks]
:
13 Write a function in PUSH(Lst) Python, where Lst is a set of numbers. 3
From this list, push all numbers divisible by 5 into a stack
implemented by using a list. Display the stack if it has atleast one
element, otherwise display appropriate error message (Underflow!)
=
Predict the output: 3
values = [10, 20, 30, 40, 50]
for val in values:
14 for I in range(1, val%9):
print(I, “*”, end=””)
print()
=
Q.No.
Section – D : Answer all the questions [ 02 X 05 = 10 Marks]
:
a) Predict the output: 3+2
def changedata(str1):
length=len(str1)
temp=""
for i in range(0, length):
if str1[i].islower():
temp=temp+str1[i].upper()
elif str1[i].isupper():
temp=temp+str1[i].lower()
elif str1[i].isdigit():
temp=temp+str(int(str1[i])+1)
else:
temp=temp+'^'
15
print(temp)
changedata("Kvs_nishant@2023")
=

b) Find error in the following code(if any) and correct code by


rewriting code and underline the correction:
x= int(“Enter value of x:”)
for in range [0,10]:
if x=y
print( x + y)
else:
print( x‐y)

16 a) Write a function that receives 2 string arguments and checks 2+2+


whether they are same length strings (returns True in this case 1
otherwise False)
=

b) Find the output of the following Python code:


def fun1(msg, length)
if (length==0):
return
else:
print(msg[length-1], end= ““)
fun1(msg, length-1)
fun1(‘amit’,4)
=

c) Find the error in following code. State the reason of the


error.
list1 =[1998, 2002, 1997, 2000]
list2 =[2014, 2016, 1996, 2009]
print"list1 + list 2 = : ", list1 +list2 #statement 1
print"list1 * 2 = : ", list1 *2 #statement 2
=

Q.No.
Section – E : Answer all the questions [ 01 X 04 = 04 Marks]
:
17 a) Write definition of a method COUNTNOW(PLACES) to find and display 2+2
those place names in which there are more than 5 characters.
For example:
If the list PLACES contains ["DELHI", "LONDON", "PARIS", "NEW YORK",
"DUBAI"]
The following output should be displayed:
LONDON
NEW YORK
=

b) Write definition of a method EvenSum(NUMBERS) to add those


values in the list of NUMBERS which are even.
=

You might also like