The document contains a series of Python programming questions and code snippets for an assignment. It includes true or false statements, code output predictions, and questions about Python syntax and operations. The questions cover various concepts such as string manipulation, loops, and logical expressions.
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)
24 views
ASSIGNMENT1
The document contains a series of Python programming questions and code snippets for an assignment. It includes true or false statements, code output predictions, and questions about Python syntax and operations. The questions cover various concepts such as string manipulation, loops, and logical expressions.
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
ASSIGNMENT-1
REVISION TOUR OF PYTHON
Q1. State True or False: “In a Python loops can also have else clause” Q2. What is the output of the following code? Text = 'Happy hour12-3' 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) (A)hAPPY#HOUR1122#33 (B)Happy#hOUR12#3 (C)hAPPY#HOUR112233 (D)Happy Hour11 22 33 # Q3. Consider the given expression: 17%5==2 and 4%2>0 or 15//2==7.5 Which of the following will be correct output if the given expression is evaluated? (A)True (B) False (C)None (D)Null Q4. Select the correct output of the code: s = "Question paper 2022-23" s= s.split('2') print(s) (A). ['Question paper ', '0', '', '-', '3'] (B). ('Question paper ', '0', '', '-', '3') (C). ['Question paper ', '0', '2', '', '-', '3'] (D). ('Question paper ', '0', '2', '', '-','3') Q5. What will be the output of following code if a = “abcde” a [1:1 ] == a [1:2] type (a[1:1]) == type (a[1:2]) Q6 Select the correct output of the code: a = "foobar" a = a.partition("o") print(a) (A) ["fo","","bar"] (B) ["f","oo","bar"] (C) ["f","o","bar"] (D) ("f","o","obar") Q7. State True or False “continue keyword skips remaining part of an iteration in a loop” Q8. Select the correct output of the code: >>> St=”Computer” >>> print(St[4:]) (A) “Comp” (B) “pmoC” (C) “uter” (D) “mput” Q9. print(True or not True and False) Choose one option from the following that will be the correct output after executing the above python expression. (A) False (B) True (C) or (D) not Q10. What will the following expression be evaluated to in Python? print(2**3**2) (A) 64 (B) 256 (C) 512 (D) 32 Q11. Which of the following statement(s) would give an error after executing the following code? S="Welcome to class XII" #Statement 1 print(S) #Statement 2 S="Thank you" #Statement 3 S[0]= '@' #Statement 4 S=S+"Thank you" #Statement 5 (A) Statement 3 (B) Statement 4 (C) Statement 5 (D) Statement 4 and 5 Q12. Which of the following can be used as valid identifier(s) in Python? (i) Total (ii) @selute (iii) Que$tion (iv) great (v) 4thSem (vi) li 1 (vii) No# (viii) _Data Q13. What will be the output of following code: str = "PUBLIC SCHOOLS FOR GENERAL PUBLIC" str=str.replace('PUBLIC','*') print(str) Q14. What will be the output of following expression? (5<10 ) and (10< 5) or (3<18) and not 8<18 (a) True (b) False (c) Error (d) No output Q15. Identify the output of the following code snippet: text = "The_quick_brown_fox" index = text.find("quick") result = text[:index].replace("_", "") + text[index:].upper() print(result) (A) Thequick_brown_fox (B) TheQUICK_BROWN_FOX (C) TheQUICKBROWNFOX (D) TheQUICKBROWN_FOX