The document contains a series of programming questions and code snippets related to Python, focusing on syntax corrections, output predictions, and function definitions. It includes multiple-choice questions and coding tasks aimed at assessing knowledge of Python programming concepts. The questions are sourced from CBSE exams, indicating their educational context.
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 ratings0% found this document useful (0 votes)
59 views2 pages
Output Ques PYQ
The document contains a series of programming questions and code snippets related to Python, focusing on syntax corrections, output predictions, and function definitions. It includes multiple-choice questions and coding tasks aimed at assessing knowledge of Python programming concepts. The questions are sourced from CBSE exams, indicating their educational context.
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
XII CS if (s[i] >='a' and s[i] <= 'm'):
OUTPUT BASED QUESTIONS [PYQs] m = m + s [i].upper()
Q1. Observe the following code carefully and elif (s[i]>= 'O'and s[i]<= 'z'): rewrite it after removing all syntactical errors. m = m +s [i-1] Underline all the corrections made. 2 [2024C] elif (s[i].isupper()): m = m + s[i].lower() (a) else: def 1func(): m = m + '@' a=input("Enter a number")) print (m) if a>=33 print("Promoted to next class") Q5. Predict the output: [CBSE 2024] ELSE: def callon(b=20,a=10): print("Repeat") b=b+a a=b-a (b)CBSE 2024 print(b,’#’,a) def EvenOdd() return b for i in range(5): x=100 num=int(input(‘Enter a number’) y=200 if num/2==0: x=callon(x,y) print(‘Even’) print(x,’@’,y) else: y=callon(y) print(‘Odd’) print(x,’@’,y) (c) CBSE 2023 C Q6. Predict the outptut: define EOCOUNT(L): LS=[‘HIMALAYA’,’NILGIRI’,’ALASKA’ even_no=odd_no=0 ,’ALPS’] for i in range(0,len(L)) D={} if L[i]%2=0: for S in LS: even_no+=1 if len(s)%4==0: Else: D[S]=len(S) odd_no+=1 for K in D: print(even_no, odd_no) print(K,D[K],sep=’#’) Q2. Predict the output of the following code : 2 d={"IND":"DEL","SRI:"COL","CHI":" Q7. Predict the output: 3 [CBSE2024] BEI"} S=’Racecar Car Radar’ str1="" L=S.split() for i in d: for W in L: str1=strl+str(d[i])+"@" X=W.upper() str2=str1[:–1] if x==x[::-1] print (str2) for I in X: Q3 Predict the output of the following code : 2 print(I,end=’*’) def Total (Num=10): else: Sum=0 for I in W: for C in range(1,Num+1): print(I end=’#’) if C%2!=0: print() continue Sum+=C Q8. Predict the output of the return Sum code:[2] CBSE 2023C print(Total(4),end="$") text=’LearningCS’ print(Total(),sep="@") L=len(text) Ntext=’’ for i in range(0,L): Q4. Predict the output of the Python code given if text[i].islower(): below : 3 ntext=ntext+text[i].upper() s="India Growing" elif text[i].isalnum(): n = len(s) ntext=ntext+text[i-1] m="" else: for i in range (0, n) : ntext=ntext+’&&’ print(ntext)
Q9.Predict the output:[2] CBSE Q13. CBSE 2023
2023 C What possible output from the a=15 given options is expected to be def update(x): displayed when the following global a python code is executed? a+=2 import random if c%2==0: Signal=[‘Red’,’Yellow’,’Green’] a*=x for k in range(2,0,-1): else: R=random.randrange(k) a//=x Print(Signal[R],end=’#’) a=a+5 (a) YELLOW#RED# print(a,end=’$’) (b) RED#GREEN# update(5) (c) GREEN#RED# print(a) (d) YELLOW#GREEN#
Q10. Q14. What possible output are
(a )Given is a Python String expected? CBSE 2023 C Declaration: CBSE 2023 C import random NAME=’Learning Python is Fun’ S=[‘Pen’,’Pencil’,’Eraser’,’Bag’, Write the output of: ’Book’] print(NAME[-5:-10:-1]) For I in range (1,2): (b) Write the output of the code f=random.randint(i,3) given below: s=random.randint(i+1,4) Dict1={1:[‘Rohit’,20],2:[‘Siya’,9 Print(S[f],S[s],sep=’:’) 0]} (a) Pencil:Book Dict2={1:[‘Rahul’,95],5:[‘Rajan’, (b) Pencil:Book 80]} Eraser:Bag Dict1.update(dict2) (c) Pen:Book print(dict1.values()) Bag:Book (d) Bag;Eraser Q11. Write the output:CBSE2023C Q15. Identify the correct output(s) of the g=0 following code. Also write the minimum and the def fun1(x,y): maximum possible values of the variable b. 2025 global g SP g=x+y import random return g a="Wisdom" def fun2(m,n): b=random.randint(1,6) global g for i in range(0,b,2): g=m-n print(a[i],end='#') return g (A) W# (B) W#i# (C) W#s# (D) W#i#s# k=fun1(2,3) fun2(k,7) Q16 Predict the output[3] 2025 SP print(g) d = {"apple": 15, "banana": 7, Q12. Which of the following will "cherry": 9} never be obtained when given code str1 = "" for key in d: is executed? [CBSE 2024 C] str1=str1+str(d[key])+"@"+ “\n” Import random str2 = str1[:-1] Shuffle=random.randrange(10)+1 print(str2) Draw=10*random.randrange(5) Q17. Predict the output print(‘Shuffle’,Shuffle,end=’#’) line=[4,9,12,6,20] print(‘Draw’,Draw) For I in line: (a) Shuffle 1 # Draw 0 for j in range(1,I%5): (b) Shuffle 10 # Draw 10 print(j,’#’,end=””) (c) Shuffle 10 # Draw 0 print() (d) Shuffle 11#Draw 50