0% found this document useful (0 votes)
51 views2 pages

Day-2 QP

This document contains 10 questions about Python concepts like functions, strings, lists, and global and local variables. Each question provides sample Python code and asks the reader to predict the output or find errors. The questions cover a range of Python topics including string indexing and slicing, list methods like insert, function definitions and calls, parameter passing, and global and local variables.

Uploaded by

Animesh kanjilal
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)
51 views2 pages

Day-2 QP

This document contains 10 questions about Python concepts like functions, strings, lists, and global and local variables. Each question provides sample Python code and asks the reader to predict the output or find errors. The questions cover a range of Python topics including string indexing and slicing, list methods like insert, function definitions and calls, parameter passing, and global and local variables.

Uploaded by

Animesh kanjilal
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

DAY-2 Assignment 2 Marks Questions-Revision Q4.

(a) Given is a Python string declaration:


Tour Python str="malayalam"
Write the output of print(str[ : :-1])
Q1. a)What will be the output of following code:
(b) Write the output of the code given below:
def ChangeVal(M,N): Employee1={'name':'John','salary':10000,'age':24}
for i in range(N): Employee2={'name':'Divya','salary':54000,'dept':'Sales'}
if M[i]%5 == 0 : Employee1.update(Employee2)
M[i]//=5 print(Employee1)
if M[i]%3 == 0 :
M[i]//=3
L=[25,8,75,12] Q5. (a) Predict the output of the Python code given
ChangeVal(L,4) below:
for i inL: def Display(str):
print(i,end="#") m=""
for i in range(0,len(str)):
Q2. a)Find and write the output of the following Python if(str[i].isupper()):
code: m=m+str[i].lower()
def Call (P=40,Q=20): elif str[i].islower():
P=P+Q m=m+str[i].upper()
Q=P– Q else:
print(P,'@',Q) if i%2==0:
returnP m=m+str[i-1]
else:
R=200 m=m+"#"
S=100 print(m)
R=Call(R,S) Display('[email protected]')
print(R,'@',S)
S=Call(S) Q6. Predict the output of the Python code given below:
print(R,'@',S) What is the output of the following Python code
x=”hello world”
Q3. Ravi has written a function to print Fibonacci series print(x[:2] , x[:-2],x[-2:])
for first 10 elements. His code is having errors. Rewrite print(x[6] , x[2:4])
the correct code and underline the corrections made. print(x[2:-3] , x[-4:-2])
some initial elements of
Fibonacci series are: Q7. Find and write the output of the following python
def fibonacci() code:
first=0 def Change(P ,Q=10):
second=1 P=P*Q
print((“first no. is “, first) Q=Q+P
print(“second no. is , second) print( P,"#",Q)
for a in range (1,9): return (Q)
third=first+second A=5
print(third) B=10
first,second=second,third A=Change(A)
fibonacci() B=Change(A,B)
print(A,"#",B)
Q8. (a)Find and write the output of the following python code:

def encrypt(s):
k=len(s)
m=""
for i in range(0,k):
if(s[i].isupper( )):
m=m+str(i)
elif s[i].islower( ):
m=m+s[i].upper()
else:
m=m+'*'
print(m)
encrypt('Kvs@Hyderabad')

Q9. (a) Given is a Python string declaration:


str="Kendriya Vidyalaya Sangathan"
Write the output of: print(str[9:17])

(b) Write the output of the code given below:


lst1 = [10, 15, 20, 25, 30]
lst1.insert( 3, 4)
lst1.insert( 2, 3)
print (lst1[-5])

Q10. Predict the output of the Python code given


below:
a=20
def call():
global a
b=20
a=a+b
return a

print(a)
call()
print(a)

You might also like