50+ Class 12 CS Find output of Python Code Important Questions

Share with others

Class 12 CS Find output of Python Code Important Questions

Class 12 CS Find output of Python Code Important Questions

Find output of Python Code
Find output of Python Code

Q1. What will be the output of the following code snippet?

a=10
b=20
c=-5
a, b, a = a+c, b-c, b+c
print(a, b, c)

Q2. What is the result of the following code in python?

S=”ComputerScience”
print(S[2]+S[-4]+S[1:-7])

Q3. What possible outputs(s) will be obtained when the following code is executed?

import random
VALUES = [10, 20, 30, 40, 50, 60, 70, 80]
BEGIN = random.randint(1,3)
LAST = random.randint(BEGIN, 4)
for x in range(BEGIN, LAST+1):
     print(VALUES[x], end = "-")

a) 30-40-50-

b) 10-20-30-40-

c) 30-40-50-60-

d) 30-40-50-60-70-

Q4. Predict the output of the following code:

def ChangeLists(M , N):
     M[0] = 25
     N = [2, 3]
L1 = [-11, -21]
L2 = [14, 23]
ChangeLists(L1, L2)
print(L1[0],"#", L2[0])

Q5. Write the output of the following code:

L1=[10, 90, 30, 40, 50]
START=1
S=0
for C in range (START, 4):
     S=S+L1[C]
     print(C,":")
S=S+L1[0]*10
print(S)
Write the output of : print(st.count(‘PLI’, 2,12))

Q6. Given is a Python string declaration:
str = ‘SIMPLEQUESTIONS’
Write the output of : print(str.count(‘E’, 2, 12))

Q7. Write the output of the code given below:

D = {‘A’ : ’AJAY’ , ‘GRADE’ : ’A’}
print(list(D.values( )))

Q8. Write the output of the code given below:

x = 25
def modify(s, c=2):
   global x
   for a in s:
       if a in 'QWEiop':
           x //= 5
           print(a.upper(),'@',c*x)
       else:
          x += 5
          print(a.lower(),'#',c+x)
string = 'We'
modify(string,10)
print(x, '$', string)

Q9. What will be the output of the following statement:

print(5-2**2**2+99//11)

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

for i in "SIMPLE":
    print(i.lower(), end="#")

Q11. What will be the output of the following code:

x=90
def funl(): 
    x = 100 
    def fun2():
        x = 200
        print ("x in fun2()",x)
    print ("Before calling fun2(): " + str(x)) 
    fun2()
    print ("After calling fun2: " + str(x)) 
funl()
print ("x in main: " + str(x))

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

def Diff(N1, N2): 
    if N1>N2: 
        return N1-N2
    else:
        return N2-N1
NUM=[20, 33, 4, 44, 52]
for CNT in range (4,0,-1):
    A=NUM [CNT]
    B=NUM [CNT-1]
    print (Diff(A, B), '#', end='')

Q13. Write the output of the following:

d1={1 : 2, 3 : 4, 5 : 6}
d2=d1.popitem()
print(d2)

Q14. Write the output of the following code

a="Year2022atallthe best"
a=a.split('a')
b=a[0]+"-"+a[1]+"-"+a[3]
print (b)

Find output of Python Code
Find output of Python Code

Q15. Write the output of the following code

D1={"sname":"Aman","age":26}
D1['age']=27
D1['address']="Delhi"
print(D1.items())

Q16. Write the output of the following code

value = 50
def display(N):
    global value
    value = 25
    if N%7==0:
        value=value+N
    else:
        value=value-N
print(value, end="#")
display(20)
print(value)

Q17. Write the output of the following code

def Display(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)
Display('Fun@World2.0')

Q18. What will be the output of the following python dictionary operation?

data = {'A':2000, 'B':2500, 'C':3000, 'A':4000}
print(data)

Q19. Write the output of the following code:

dic1={'r' : 'rose', 'g' : 'girl', 'b' : 'bill'}
for i in dic1:
    print (i,end='')

Q20. Write the correct output of the following code:

for i in "SIMPLE":
    print({i.lower()}, end= "#")

Q21. Write the output of the following code:

def Swap (a,b ) :
    if a>b:
        print("changed ",end="")
        return b,a
    else:
        print("unchanged ",end="")
        return a,b
data=[11,22,16,50,30]
for i in range (4,0,-1):
    print(Swap(data[i],data[i-1]))

Q22. Write the output of the following code:

value = 50
def display(N):
    global value
    value = 25
    if N%7==0:
        value = value + N
    else:
        value = value - N
print(value, end="#")
display(20)
print(value)

Q23. Write the output of the following code:

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

Q24. Write the output of the following code:

m={1:2,3:4,5:6}
n=m.get(1,3)
print(n)

Q25. Write the output of the following code:

s="Agnel@CBSE-2024"
print(s[-2:2:-2])

Q26. Write the output of the following code:

L=[12,23,18,9,17]
for i in range(len(L)):
    if(L[i]%3==0):
        L[i]=0
    else:
        L[i]=1
print(L)

Q27. Write the output of the following code

string="aabbcc"
count=3
while True:
    if string[0]=='a':
         string=string[2:]
    elif string[-1]=='b':
        string=string[:2]
    else:
        count+=1
        break
print(string)
print(count)

Q28. Write the output of the following code

def Compare(N1,N2=10):
         return N1 > N2
NUM= [10,23,14,54,32]
for V in range (4,0,-1):
       A=NUM[V]
       B=NUM[V-1]
       if V > len(NUM)//2:
             print(Compare(A,B),'?', end=' ')
       else:
            print(Compare(B),'#',end=' ')

Find output of Python Code
Find output of Python Code

Q29. Write the output of the following code

a={}
a[1] = 1 
a['2'] = 2
c = 0
for i in a:
    c = c+a[i] 
print(c)

Q30. Write the output of the following code

M1="FATHERS" 
M2="AGNELS"
M3=""
for i in range (0, len (M2)):
    if M1[i]>="A" and M1[i]<="M": 
        M3 = M3+M1[i]
    elif M1 [i]>="N" and M1 [i]<="Z": 
        M3=M3+M2[i]
    else:
        M3=M3+"*"
print (M3)

Q31. Write the output of the following code

a = "Wow! Python! is! amazing!"
a = a.split('!')
b = a[0] + "?" + a[1] + "?" + a[2]
print (b)

Q32. Write the output of the following code

st="ComputerScience@2024"
print(st[2:22:4]*3)

Q33. Write the output of the following code

a=tuple()
a=a + tuple(‘Python’)
print(a)
print(len(a))
b=(10,20,30)
print(len(b))

Q34. Write the output of the following code

a=5
def add(b=2):
    global a
    a=a+b
    print(a,'#',b)
    return a
b=add(a)
print(a,'#',b)
b=add(b)
print(a,'#',b) 

Q35. Write the output of the following code

a="Hello@123"
n =len(a)
b=""
for i in range(0, n):
    if a[i] >= 'a' and a[i] <= 'k':
        b = b + a[i].upper()
    elif (a[i] >= 'l' and a[i] <= 'z'):
        b = b + a[i-1]
    elif a[i].isupper():
        b = b + a[i].lower()
    else:
        b = b + '#'
print(b) 

Q36. Write the output of the following code

L=[12, 24, 36, 48, 60]
for i in range(1,5):
    L[i-1]=L[i]
for i in range(0,5):
    print(L[i],end='$') 

Q37. Write the output of the following code

elements=['apple',200,300,'red','blue','grapes']
print(elements[3 : 5])
print(elements[: : -1])

Q38. Write the output of the following code

def calc(p,q=3):
    ans=1
    for x in range(q):
        ans=ans*p
    return ans
power=calc(3)
print(power,'Anil')
power=calc(3,2)
print(power,'Aman')

Q39. Write the output of the following code

def calculate(str):
    text=' '
    x=range(len(str)-1)
    for i in x:
        if str[i].isupper():
            text+=str[i].lower()
        elif str[i].islower():
            text+=str[i+1]
        else:
            text+='@'
    return text
start='PROGRAM finished'
final=calculate(start)
print(final) 

Q40. Write the output of the following code

s = "Question paper 2024-25"
s= s.split('2')
print(s)

Q41. Write the output of the following code

D={1 : "one", 2 : "two", 3 : "three"}
L=[ ]
for k,v in D.items():
    if 'o' in v:
        L.append(k)
print(L)

Q42. Write the output of the following code

D={‘month’ : ’DECEMBER’, ’exam’ : ’PREBOARD1’}
D[‘month’]=’JANUARY’
D[‘EXAM’]=’PRE2’
print(D.items())

Q43. Write the output of the following code

L=[4,6,7,1,6,9,4]
def fun(L):
    for i in range(len(L)):
        if(L[i]%3==0 and L[i]%2==0):
            L[i]=L[i]+1
    return(L)
k=fun(L)
print(k)

Q44. Write the output of the following code

T = (9, 18, 27, 36, 45, 54)
L=list(T)
L1 = [ ]
for i in L:
    if i%6==0:
        L1.append(i)
T1 = tuple(L1)
print(T1)

Q45. Write the output of the following code

string="aabbcc"
count=3
while True:
    if string[0]=='a':
        string=string[2:]
    elif string[-1]=='b':
        string=string[:2]
    else:
        count+=1
        break
print(string)
print(count)

Q46. Write the output of the following code

fruit_list1 = ['Apple', 'Berry', 'Cherry', 'Papaya']
fruit_list2 = fruit_list1
fruit_list3 = fruit_list1[:]
fruit_list2[0] = 'Guava'
fruit_list3[1] = 'Kiwi'
sum = 0
for ls in (fruit_list1, fruit_list2, fruit_list3):
    if ls[0] == 'Guava':
        sum += 1
    if ls[1] == 'Kiwi':
        sum += 20
print (sum)

Q47. Write the output of the following code

my_dict = { }
my_dict[(1,2,4)] = 8
my_dict[(4,2,1)] = 10
my_dict[(1,2)] = 12
sum = 0
for k in my_dict:
    sum += my_dict[k]
print (sum)
print(my_dict)

Q48. Write the output of the following code

txt = "fun with python"
print(txt.find("th",7,14))

Q49. Write the output of the following code

text = 'ABCD'
number = '1357'
i = 0
s =''
while i < len(text):
    s = s + text[i] + number[len(number)-i-1]
    i = i + 1
print(s)

Q50. Write the output of the following code

def Diff(N1,N2):
    if N1>N2:
        return N1-N2
    else:
        return N2-N1
num=[10,23,14,54,32]
for cnt in range(4,0,-1):
    a=num[cnt]
    b=num[cnt-1]
print(Diff(a,b),'#',end='&')

Q51. Write the output of the following code

List1 = list("Examination")
List2 =List1[1:-1]
new_list = []
for i in List2:
     j=List2.index(i)
    if j%2==0:
          List1.remove(i)
print(List1)

Q52. Write the output of the following code.

Text = 'CsipLearninghub@123'
L= ""
for i in range(len(Text)):
    if Text[i].isupper():
        L=L+Text[i].lower()
    elif Text[i].islower():
        L=L+Text[i].upper()
    elif Text[i].isdigit():
        L=L+(Text[i]*2)
    else:
        L=L+'#'
print(L)

Q53. Write the output of the following code

d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45}
d1 > d2

Q54. Write the output of the following code

a = "amanamanaman"
a = a.partition("a")
print(a)

Find output of Python Code
Find output of Python Code

MCQ of Computer Science Chapter Wise

1. Functions in Python

2. Flow of Control (Loop and Conditional statement)

3. 140+ MCQ on Introduction to Python

4. 120 MCQ on String in Python

5. 100+ MCQ on List in Python

6. 50+ MCQ on Tuple in Python

7. 100+ MCQ on Flow of Control in Python

8. 60+ MCQ on Dictionary in Python


Important Links

100 Practice Questions on Python Fundamentals

120+ MySQL Practice Questions

90+ Practice Questions on List

50+ Output based Practice Questions

100 Practice Questions on String

70 Practice Questions on Loops

70 Practice Questions on if-else

Important MCQ of Series



Disclaimer : I tried to give you the best “Class 12 CS Find output of Python Code Important Questions” of , but if you feel that there is/are mistakes in the questions or answers of “Class 12 CS Find output of Python Code Important Questions” given above, you can directly contact me at csiplearninghub@gmail.com. Reference for the notes is NCERT book as well as from Pre board papers of different KV’s.


Class 12 CS Find output of Python Code Important Questions

Class 12 CS Find output of Python Code Important Questions

Class 12 CS Find output of Python Code Important Questions

Class 12 CS Find output of Python Code Important Questions

Class 12 CS Find output of Python Code Important Questions

Class 12 CS Find output of Python Code Important Questions

Class 12 CS Find output of Python Code Important Questions

Class 12 CS Find output of Python Code Important Questions

Class 12 CS Find output of Python Code Important Questions

Class 12 CS Find output of Python Code Important Questions

Class 12 CS Find output of Python Code Important Questions

Class 12 CS Find output of Python Code Important Questions

Class 12 CS Find output of Python Code Important Questions

Class 12 CS Find output of Python Code Important Questions

Class 12 CS Find output of Python Code Important Questions


Share with others

Leave a Reply

error: Content is protected !!