0% found this document useful (0 votes)
96 views5 pages

Output 2

kbgyig

Uploaded by

anilkoranga.pc
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)
96 views5 pages

Output 2

kbgyig

Uploaded by

anilkoranga.pc
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/ 5

Q1. Predict the output of the following code.

def swap(P ,Q):


P,Q=Q,P
print( P,"#",Q)
return (P)
R=100
S=200
R=swap(R,S)
print(R,"#",S)
Q2. Consider the following function headers. Identify the correct statement and state
reason
1) def correct(a=1,b=2,c): 2) def correct(a=1,b,c=3):
3) def correct(a=1,b=2,c=3): 4) def correct(a=1,b,c):
Q3. What possible outputs(s) are expected to be displayed on screen at the time of
execution of the program from the following code? Also specify the maximum AND
minimum values that can be assigned to the variable Num when P = 7.
import random as r
val = 35
P=7
Num = 0
for i in range(1, 5):
Num = val + r.randint(0, P - 1)
print(Num, " $ ", end = "")
P=P–1
(a) 41 $ 38 $ 38 $ 37 $ (b) 38 $ 40 $ 37 $ 34 $
(c) 36 $ 35 $ 42 $ 37 $ (d) 40 $ 37 $ 39 $ 35 $
Q4. Predict the output of the following code.
def MYFUNCTION():
a=10
global vr
vr=0
vr+=a
print(vr,end=' ')
vr=12
MYFUNCTION()
print(vr)
Q5. Write a function GENERATE_INDEX(L), where L is the list of elements passed as
argument to the function. The function returns another list named ‘NewIndex’ that stores
the indices of all even Elements of L. For example: If L contains [22,7,9,24,6,5]
The NewIndex will have - [0, 3, 4]
Q6. Predict the output of the following code.
s="Python"
def MODIFY(T):
T="World"
print(T,end="#")
return T[:-3:-1]
print(MODIFY(s))

Q7. Predict the output of the following code.


def change (s):
m=""
for i in range(len(s)):
if s[i].isupper():
m+=s[i].lower()
elif s[i].islower():
m+=s[i].upper()
elif s[i].isdigit():
m+=s[i-1]
else:
m = m +'#'
print(m)
change("Abc2@xYz")

Q8. Predict the output of the Python code given below:


def runme(x=1, y=2):
x = x+y
y+=1
print(x, '$', y)
return x,y
a,b = runme()
print(a, '#', b)
runme(a,b)
print(a+b)
Q9. Predict the output of the Python code given below:
def Indirect(Temp=20):
for I in range(10,Temp+1,5):
print(I,", ",end=" ")
print()
def Direct (Num):
Num+=10
Indirect(Num)
Number=20
Direct(Number)
Indirect()
Q10. Predict the output of the Python code given below:

def Calc ( U):


if U%2= =0:
return U+10
else:
return U*2

def Pattern (M, B=2):


for CNT in range (0,B):
print(Calc(CNT),M)
print()
Pattern(‘*’)
Pattern(‘#’,4)
Pattern(‘@’,3)

Q9. Write a function LShift(Arr,n) in Python, which accepts a list Arr of numbers and n is a
numeric value by which all elements of the list are shifted to left. Sample Input Data of the
list .
Arr= [ 10,20,30,40,12,11], n=2
Output Arr = [30,40,12,11,10,20]
Question:

Write a Python function that takes a list and returns a new list with unique
elements of the first list.
Sample List : [1,2,3,3,3,3,4,5]
Unique List : [1, 2, 3, 4, 5]

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


value = 100
def display (N):
global value
value = 150
if N%7 == 0:
value = value + N
else:
value = value - N
print (value, end = '#')
display (50)
print (value)
Q11. What will be the output of the following code?

def Execute(M):
if M%3==0:
return M*3
else:
return M+10;
def Output(B=2):
for T in range (0,B):
print(Execute(T),"*",end="")
print()
Output(4)
Output()
Output(3)

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

def main1():
Moves=[11, 22, 33, 44]
Queen=Moves
Moves[2]+=22
L=len(Moves)
for i in range (L):
print ( "Now@", Queen[L-i-1], "#", Moves [i])
main1()
Q13. What will be the output of the following code?
def disp(str):
m=' '
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"@"
print(m.swapcase())
disp('StudyBag$2024')

Q14 Find the output of the give program :


x="abcdef"
i="a"
while i in x:
print (i,end=" ")
Q15 Find the output of the give program :
def f():
global s
s += ' Is Great'
print(s)
s = "Python is funny"
s = "Python"
f()
print(s)

You might also like