0% found this document useful (0 votes)
13 views

Answers Python Fundamentals

answers for python fundamental sheet

Uploaded by

Priya Sohal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Answers Python Fundamentals

answers for python fundamental sheet

Uploaded by

Priya Sohal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Answers of Python Revision Tour

1) Math & WHILE is incorrect answer (while in small is a keyword)


2) Typeerror as Dict print as D[‘name’] then it will print Suraj
3) Option C
4) Option B
5) Option D [string is immutable type one cannot change the value of immutable type others
are Tuple and List, Dictionary, and Sets are mutable types]
6) Colours = (‘blue’, ‘green’)
7) Option 2 compare as per ASCII value
8) Floor(5.8)
9) String & Tuple is immutable
10) [‘Mumbai’,’Delhi’]
11) A) 20 [follow precedence table if both operator on same level then follow associativity all
operator associative is left to right except exponential]
b) True

12) Runs = (10,5,0,6,7)

For I in Runs:

If I == 0 :

Print(‘Maiden over’)

Else :

Print(‘not maidan’)

12) Wait#stop#
13) 5Radius is invalid
14) Break & while
15) 1) Math 2) random
16) W = input(‘enter a word’)
If w == ‘hello’ :
Print(‘Ok’)
Else :
Print(‘not ok’)
17) Classroll = {1: ‘Reena’, 2: ‘Rakesh’, 3: ‘Zareen’}
18) Tuple [if write as ‘a’, ‘e’, ’i’ then also data type is tuple even if bracket is not there]
19) $$
$$$$
$$$$$$
20) X = 25
21) True
22) Real is invalid datatype
23) dict_exam.update(dict_result)
24) True
25) a = "Year 2022 at All the best"
a.split(‘2’) => [‘Year ’, ‘0’, ‘’ , “ at All the best”] //split function returns list
a.partition(‘2’) => split in 3 parts 1st will be before 2 observed second will
be character to which partition is done & third is rest string
[‘Year ’, ‘2’, ‘022 at All the best’]
answer is option A (Year . 0. at All the best )

26) Statement 4
27) 14.75
28) @20 otnmx SC@
29) Item function gives output in form of tuple
dict_items([(‘name’,’aman’), (‘age’,27), (‘address’,’delhi’)])
30) SELCcME&Cc
31) pass is invalid
32) tuple
33) (40,60)
34) String
35) / option D
36) Statement b in correct as tupple is inmutable
37) .py is correct
38) #
39) 200 [as T= (100) is not tuple single element tuple is like (100,) so it will be considered as
integer ]
40) Option d 15.0
41) Answer c 2345678
42) Answer is c 36
43) //insert has 2 argument index,element_val so list1(3,4) means on 3rd index value is 4 all other
element will shift option b 3 is right answer
44) Correct answer is 18
45) Correct answer is option b [randint includes boundary value also but random not
include]
46) PYTHOnN#.
47) Option B is correct
48) Option B & C [variable starting with digit is also wrong]
49) [6,82,5]
50) ** option is c
51) Option b is incorrect
52) D= {1:’Monday’,2:’Tuesday’,3:’Wednesday’}
53) 30
54) Abs()
55) List
56) puterSc
57) a) 13 b) False
58) Value = 30
for val in range(0,Value) :
if val % 4 == 0 :
print(val * 4)
elif :
print(val + 3)
else :
print(val + 10)
59) False
60) #THONPROGRAM
61) not(True) and False
62) (A) ('I', 'ter', 'atio', 'al')
63) ce lo
64) (B) False
65) print(my_dict['apple', 'banana'])
66) (B) Removes the first occurrence of value x from the list
67) (D) t=tuple(1)
68) False
69) Mutable object: [1,2] or {1:1,2:2} (Any one) Immutable object: (1,2) or ‘123’ (Any one)
70) (I) Arithmetic operators: +,- (II) Relational operators: >, >=
71) (A), (C) Minimum and maximum possible values of the variable b: 1,6
72) A) L1.count(4) b) L1.sort() c) ) L1.extend(L2) d) L2.reverse()
73) ZeroDivisionError is raised when a statement tries to divide a number by zero.
try:
a=int(input("Enter an integer: "))
print("Reciprocal of the number =",1/a)
except ZeroDivisionError:
print("Division by Zero is not allowed")
except:
print("Some Error Ocurred")
74) NameError is raised when an undefined identifier is used in the program
try:
a=eval(input("Enter an integer: "))
print("Reciprocal of the number =",1/a)
except NameError:
print("Some name is not defined")
except:
print("Some Error Ocurred")
75) 35 11 33
76) Answer is a & b as division operator returns in float
77) No output /Infinite as I declared as string it will check if is in that string or not
78) A) 2 b) 1
79) A = {1, [2,3,4]} so output is 3
80) 012 [pass transfer control to next statement]
81) No output
82) [1,2,3,5]
83) [1,3,4,5] //index function gives the index of the element index of 3 is 2 so 2 will be removed
84) Book[3] = ‘Crime Thriller’ b) Library.update(Book) c) [‘5’,’6’] d) option b
85) a) 8 b) True [in case of integer end operator any none zero value considered as True if first
operator is truthy so value depends upon second operand value so returns 8]
86) 16
87) String
88) [3,5,7,8,2] //in insert functionfirst parameter is index where value needs to be inserted if
index not exists then insert at end
89) 2 //pop will retutn the deleted value at a particular index so 3 is index no which needs to
deleted & it will return the value at this
90) [5,4,3,2,1,5,4,3,2,1]
91) [44,33,44,66] //sorted function not makes changes in original list
92) [1,2,3,4] // L2 = L1: This assigns L2 to refer to the same list object as L1. Both L1 and L2 point
to the same list in memory. L1.sort(): This sorts the list in place, modifying the list that L1 and
L2 refer to.
93) 1
4
7
94) Infinite loop
95) : The above code will produce KeyError, the reason being that there is no key same as the list
[‘a’,’b’] in the dictionary
96) Tuple

You might also like