The document consists of a Python revision assignment with various questions that test knowledge on Python expressions, code outputs, data types, and logical operations. It includes multiple-choice questions, true/false statements, and code evaluation tasks. The assignment aims to assess the understanding of fundamental Python concepts and syntax.
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)
6 views4 pages
assignment on python revision tour
The document consists of a Python revision assignment with various questions that test knowledge on Python expressions, code outputs, data types, and logical operations. It includes multiple-choice questions, true/false statements, and code evaluation tasks. The assignment aims to assess the understanding of fundamental Python concepts and syntax.
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/ 4
ASSIGNMENT :PYTHON REVISION TOUR I and II
1. State True/False: The python expression 3.2+2 is evaluated as 3*2+2
2. Observe and find output of the following python code: str1 = "Python" str2 = "Programming" print(str1[:2] + str2[-4:]) a. Pyming b. Pythming c. Pyogramming d. Pythonming
3. Evaluate the following expression and find correct value of y:
y = 3 * 4 + 2**3 // 2 - (7 % 3)
4. What will be the output of following python code:
s = 'Programming' print(s.split("m")) a. ['Progra', '', 'ing'] b. ['Progra', 'ing'] c. ['Progra', 'm', 'ing'] d. ['Progra', 'ming']
5. What will be the output of following python code:
s = “yoBananaBoy” print(s[: :-1 ])
6. What will be the output of following python code:
t1 = 1,2,3 t2 = (1,2,3) print(t1 is t2) a. True b. 1 c. False d. 0
7. What would the following code print:
fruits = {'apple': 5, 'banana': 3, 'orange': 2, 'grape': 4} print(fruits.get('mango')) a. 0 b. None c. Error d. 5 8. Consider the given list L: L = list('All is well in ') What python code should be written for inserting the word 'Havana' at the end of the list as separate characters? a. L.extend('Havana') b. L.append(list('Havana')) c. both a and b d. None of the above
9. What will be the output of following python code:
l2= [1,2,3,'[4,5]'] print(type(l2[-1])) a. error b. <class ‘list’> c. <class ‘string> d. <class ‘NoneType’>
10. Identify the output of the following code snippet
text = “Comma(,) is a punctuator” text = text.split(‘,’) print(text) a) [ ‘Comma(,)’, ‘is’, ‘a’, ‘punctuator’ ] b) [ ‘Comma(’, ‘) is a punctuator’ ] c) [ ‘Comma(‘, ‘,’, ‘) is a punctuator’ ] d) Error
11. Which of the following expressions evaluates to True
a) False or not False and False b) False and not False or False c) True or not True and False d) True and not True or not True
12.What will be the output of the following code?
msg = ‘Transcendental’ print(msg[ 10 : -10 : -2 ]) a) 'nde' b) 'ndesaTltenc' c) '' d) error 13.Which statement(s) will result in error? t1=(11,22,33) t2=(44,) #statement1 t2+=t1 #statement2 t4=t1*2+t2*2 #statement3 t4[0]=45 #statement4 a) statement 4 b) statement 2&4 c) statement 3&4 d) All
14.Which statement will result in error
item={‘Cake’:20, ‘Pastry’:30, ‘Burger’:15} a) item[‘Patties’]=30 b) item.update((‘Patties’,30)) c) item.update({‘Patties’:30}) d) item.setdefault(‘Patties’,30)
15. What does list.pop(x) method do in Python?
a) removes and return element x b) removes first occurrence of element x c) removes and return element at index x d) only returns element at index x but does not remove it
16. State True or False
“continue keyword skips remaining part of an iteration in a loop” 17. Select the correct output of the code: >>> St=”Computer” >>> print(St[4:]) (a) “Comp” (b) “pmoC” (c) “uter” (d) “mput”
18. 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 19. Given the following dictionaries dict_stud = {"rno" : "53", "name" : ‘Rajveer Singh’} dict_mark = {"Accts" : 87, "English" : 65} Which statement will merge the contents of both dictionaries? (a) dict_stud + dict_mark (b) dict_stud.add(dict_mark) (c) dict_stud.merge(dict_mark) (d) dict_stud.update(dict_mark)
20. Given a tuple tupl=(10,20,30,40,50,60,70,80,90)
What will be the output of print (tupl[3:7:2])? (a) (40,50,60,70,80) (b) (40,50,60,70) (c) [40,60] (d) (40,60)
21. Consider a declaration L=(1,’Python’,’3.14’)
Which of the following represents the data type of L? (a) list (b) tuple (c) dictionary (d) string
22. What will the following expression be evaluated to in Python?
print(2**3**2) a) 64 b) 256 c) 512 d) 32 23. 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 24. State True or False: “In a Python loops can also have else clause” 25. 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
(Ebook) Becoming an Outstanding Languages Teacher by Steve Smith ISBN 9781032222103, 9781032222097, 9782022003986, 2022003985, 1032222107, 1032222093 - The latest ebook edition with all chapters is now available