Share 60 output based questions
Share 60 output based questions
x="hello world"
print(x[:2],x[:-2],x[-
2:]) print(x[6],x[2:4])
print(x[2:-3],x[-4:-2])
Q15. Find and write the output of the following python code :
def Changer(P,Q=10):
P=P/Q Q=P%Q
print (P,"#",Q)
return P
A=200
B=20
A=Changer(A,B)
print (A,"$",B)
B=Changer(B)
print (A,"$",B)
A=Changer(A)
print (A,"$",B)
Q16. Find and write the output of the following python code:
Data = ["P",20,"R",10,"S",30]
Times = 0
Alpha = ""
Add = 0
for C in range(1,6,2):
Times= Times + C
Alpha= Alpha + Data[C-1]+"$"
Add = Add + Data[C]
print (Times,Add,Alpha)
Q22. t1=("sun","mon","tue","wed")
print(t1[-1])
Q24. t3=("sun","mon","tue","wed","thru","fri") if
"sun" in t3:
for i in range (0,3):
print(t2[i])
else:
for i in range (3,6):
print(t2[i])
Q25. t6=('a','b')
t7=('p','q')
t8=t6+t7
print(t8*2)
Q26. t9=('a','b')
t10=('p','q') t11=t9+t10
print(len(t11*2))
Q27. t12=('a','e','i','o','u')
p, q, r, s, t=t12
print("p= ",p)
print("s= ",s)
print("s + p", s + p)
Q28. t13=(10,20,30,40,50,60,70,80)
t14=(90,100,110,120)
t15=t13+t14
print(t15[0:12:3])
Q31. Find the error in following code. State the reason of the error.
aLst = { ‘a’:1 ,’ b’:2, ‘c’:3 }
print (aLst[‘a’,’b’])
list1 = [1, 2, 3, 4, 5]
list2[0] =0;
print("list1= : ", list1)
1. d1 ={"john":40, "peter":45}
2. d2 ={"john":466, "peter":45}
3. d1 > d2
Q34. What will be the error of the following code Snippet and give output?
Lst =[1,2,3,4,5,6,7,8,9]
Lst[::2]=10,20,30,40,50,60
Print[Lst]
C. [4, 3] D. [4, 3, 2, 1]
Def Sum(a=1,b)
return a+b
print (“The sum =” Sum(7, -1)
def calcSquare(a):
a = power (a, 2)
return a
n=5
result = calcSquare(n)
print (result)
Q48. a=10
def call( ):
global a
a=15
b=20
print(a)
call( )
>>>A[5:15:2]