0% found this document useful (0 votes)
11 views13 pages

PB Python Ec Sem-1 T3 2024

Ushdhdbd Jsjdjcch

Uploaded by

hahshdhjdjdjdj3
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
11 views13 pages

PB Python Ec Sem-1 T3 2024

Ushdhdbd Jsjdjcch

Uploaded by

hahshdhjdjdjdj3
Copyright
© © All Rights Reserved
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/ 13

L.J Institute of Engineering and Technology, Ahmedabad.

Python Question Bank (SEM-I-2024 ME,EC,CL,CH Engineering)


Note :
This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit MCQ
Sr No Question_Text Marks Option A Option B Option C Option D
Number Answer
390 6 Write any program to demonstrate Tuples in Python 7
391 6 Write a Python program to check if a string is palindrome 4
or not
392 6 Write a Python program to Find length of a string in 4
python.
393 6 Write a Python function that accepts a string and calculate 7
the number of uppercase letters and lowercase letters.

394 6 Write a Program to take a Tuple of Numbers from the 4


Keyboard and Print its Sum and Average?
395 6 Write a Program to Accept some String from the Keyboard 4
and display its Characters by Index wise (both Positive and
Negative Index)
396 6 Write a Program to access each Character of String in 4
Forward and Backward Direction by using while Loop?
397 6 Write a Python program to demonstrate the negative index 4
in a Tuple
398 6 Write a Python program to demonstrate the slicing of a 4
Tuple
399 6 Write a python program to reverse internal content of each 4
word.
400 6 Write a Python program that accepts a string and calculate 4
the number of vowels and consonants present in that
string.
401 6 Write a Python program that demonstrate a function that 3
accepts a string from user and calculate the number of
uppercase letters and lowercase letters in the given string.

402 6 Write a Python program to find the sum of all elements 2


which are divisible by 5 in the list.
403 6 Which of the following is a Python tuple? B 1 [1, 2, 3] (1, 2, 3) {1, 2, 3} {}
404 6 Suppose t = (1, 2, 4, 3), which of the following is incorrect? B 1 print(t[3]) t[3] = 45 print(max(t)) print(len(t))

405 6 What will be the output of the following Python code? C 1 (1, 2) (1, 2, 4) (2, 4) (2, 4, 3)
>>>t=(1,2,4,3)
>>>t[1:3]
406 6 What will be the output of the following Python code? C 1 (1, 2) (1, 2, 4) (2, 4) (2, 4, 3)
>>>t=(1,2,4,3)
>>>t[1:-1]
407 6 What will be the output of the following Python code? A 1 (1, 2, 1, 2) [1, 2, 1, 2] (1, 1, 2, 2) [1, 1, 2, 2]
>>>t = (1, 2)
>>>2 * t
408 6 What will be the output of the following Python code? B 1 True False Error None
>>>t1 = (1, 2, 4, 3)
>>>t2 = (1, 2, 3, 4)
>>>t1 < t2
409 6 What will be the output of the following Python code? D 1 1 2 5 Error
>>>my_tuple = (1, 2, 3, 4)
>>>my_tuple.append( (5, 6, 7) )
>>>print len(my_tuple)
410 6 What is the data type of (1)? B 1 Tuple Integer List Both tuple and
integer
411 6 If a=(1,2,3,4), a[1:-1] is _________ D 1 Error, tuple slicing [2,3] (2,3,4) (2,3)
doesn’t exist

412 6 What will be the output of the following Python code? A 1 True False Error, < operatorError, < operator
>>> a=(1,2,(4,5)) is not valid foris valid for tuples
>>> b=(1,2,(3,4)) tuples but not if there
>>> a<b are sub-tuples
413 6 What will be the output of the following Python code? C 1 (‘Check’,’Check’,’C * Operator not (‘CheckCheckChec Syntax error
>>> a=("Check")*3 heck’) valid for tuples k’)
>>> a

Page 1 of 13
L.J Institute of Engineering and Technology, Ahmedabad.
Python Question Bank (SEM-I-2024 ME,EC,CL,CH Engineering)
Note :
This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit MCQ
Sr No Question_Text Marks Option A Option B Option C Option D
Number Answer
414 6 What will be the output of the following Python code? D 1 Now, a=(1,2,4) Now, a=(1,3,4) Now a=(3,4) Error as tuple is
>>> a=(1,2,3,4) immutable
>>> del(a[2])
415 6 What will be the output of the following Python code? C 1 Too many The method sum() 12 9
>>> a=(2,3,4) arguments for doesn’t exist for
>>> sum(a,3) sum() method tuples
416 6 Is the following Python code valid? C 1 No because tuple Yes, first element Yes, the entire No, invalid syntax
>>> a=(1,2,3,4) is immutable in the tuple is tuple is deleted for del method
>>> del a deleted
417 6 What type of data is: a=[(1,1),(2,4),(3,9)]? B 1 Array of tuples List of tuples Tuples of lists Invalid type
418 6 What will be the output of the following Python code? C 1 Invalid syntax for [0,2] (0,1) (0,2)
>>> a=(0,1,2,3,4) slicing
>>> b=slice(0,2)
>>> a[b]
419 6 Which of the following creates a tuple? A 1 tuple1=("a","b") tuple1[2]=("a","b" tuple1=(5)*2 None of the
) above
420 6 Choose the correct option. C 1 In Python, a tuple In Python, a tuple In Python, a tuple In Python, a tuple
can contain only can contain only can contain both can contain either
integers as its strings as its integers and string or integer
elements. elements. strings as its but not both at a
elements. time.

421 6 What will be the output of below Python code? B 1 ("annie") () None Error as slicing is
tupl=("annie","hena","sid") not possible in
print(tupl[-3:0]) tuple.
422 6 Which of the following options will not result in an error C 1 tupl[1]=2 tupl.append(2) tupl1=tupl+tupl tupl.sort()
when performed on tuples in Python where
tupl=(5,2,7,0,3)?
423 6 What will be the output of below Python code? A 1 0 2 1 Error as tuple
tupl=() object has no
tupl1=tupl*2 attribute to len
print(len(tupl1))
424 6 What will be the output of below Python code? C 1 ([2,3],"abc",0,9) ([1,3],"abc",0,9) ([2,1],'abc',0,9) Error
tupl=([2,3],"abc",0,9)
tupl[0][1]=1
print(tupl)
425 6 Which of the following two Python codes will give same D 1 i, ii ii, iv i, iv i, iii
output?
(i) print(tupl[:-1])
(ii) print(tupl[0:5])
(iii) print(tupl[0:4])
(iv) print(tupl[-4:])
If tupl=(5,3,1,9,0)
426 6 What will be the output of the following Python code? D 1 (11,12,13,14,15,16 (12,13,14,15,16,17 (12,13,14,15,16,17 (12,14,16)
t = (11,12,13,14,15,16,17,18) ,17,18) ,18) )
print(t[1:7:2])
427 6 What will be the output of the following Python code? C 1 (6,7,8,9,10,11,12) (12,11,10,9,8,7,6) (12,10,8) (12,10,8,6)
t = (6,7,8,9,10,11,12)
print(t[-1:1:-2])
428 6 What will be the output of the following Python code? A 1 INTERNAL SENIGNE ENGINES ITRA OBSINEGNS
s = "INTERNAL COMBUSTION ENGINES" COMBUSTION NOITSUBMOC
print(s[::]) ENGINES LANRETNI
429 6 What will be the output of below Python code? D 1 ([5,6,7],'python',[ ([5,6,7],'python',[ ([5,6,7],'python') ([5,6,7],'python',[
t=([5,6,7],"python",[11,12,13]) 11,12,13]) 19,12,13]) 11,12,19])
t[2][2]=19
print(t)
430 6 What will be the output of below Python code? B 1 0 3 6 5
s="armanravipavanshiva"
print(s.find('a',2,15))
431 6 What will be the output of below Python code? D 1 Refrigeration and REFRIGERATION refrigeration and Refrigeration And
s="Refrigeration and Air conditioning" air conditioning AND AIR air conditioning Air Conditioning
print(s.title()) CONDITIONING

Page 2 of 13
L.J Institute of Engineering and Technology, Ahmedabad.
Python Question Bank (SEM-I-2024 ME,EC,CL,CH Engineering)
Note :
This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit MCQ
Sr No Question_Text Marks Option A Option B Option C Option D
Number Answer
432 6 What will be the output of the following python code? D 1 3 4 5 AttributeError
t = (1,2,3,4)
t.append((5,6,7))
print(len(t))
433 6 What will be the output of the following python code? C 1 1 () 0 t1*2
t1 = ( )
t2 = t1*2
print(len(t1))
434 6 What will be the output of the following python code? C 1 ''Indian cricket ''Ida rce em'' ''Ii ietm'' ''Iaree''
s = ''Indian cricket team'' team''
print(s[::3])
435 6 What will be the output of the following python code? D 1 6 10 5 IndexError
t = (10,20,30,10,40,20)
print(t[6])
436 6 What will be the output of the following python code? A 1 1 count(‘L’) L 3
s = ''LJ engineering and technology''
print(s.count('L'))
437 6 What will be the output of the following python code? A 1 -1 find('Is') find( ) Is
s = ''Learning python is very easy''
print(s.find('Is'))
438 6 What will be the output of the following python code? D 1 (5,10,15,20) (5,77,10,15,20) (77,5,10,15,20) TypeError
t = (5,10,15,20)
t[1] = 77
print(t)
439 6 What will be the output of the following python code? C 1 (2,4) ( -4 ) (4,) (4,6)
t=(2,4,6,8)
print(t[1:-2])
440 6 What will be the output of the following python code? D 1 ''Aman2'' "AmanAman'' '2Aman'' TypeError
print(''Aman'' * ''2'')
441 6 What will be the output of the following python code? D 1 (4,1,3,2) (1,2,3,4) (1,3,2,4) [4,3,2,1]
t = (4,1,3,2)
t1 = sorted(t, reverse = True)
print(t1)
442 6 What will be the output of the following Python code? D 1 AI and ML ['AI','and','ML']
s='AI and ML'
l=s.split()
print(l)
443 6 What will be the output of the following Python code? D 1 (10,13,11,12) (10,13,11) (10,11,12) TypeError
d=(10,11,12)
d[1]=13
print(d)
444 6 What will be the output of the following Python code? A 1 [2,6,7,9] (2,6,7,9) [9,7,6,2] (9,7,6,2)
A=(9,2,6,7)
B=sorted(A,reverse=False)
print(B)
445 6 What will be the output of the following Python code? B 1 10 4 0 24
num="1234"
sum=0
for i in num:
sum=sum+1
print(sum)
446 6 What will be the output of the following Python code? D 1 1,2,3,a,b,c (1,2,3,a,b,c) a,b,c,1,2,3 (1,2,3,'a','b','c')
A=1,2,3
B=("a","b","c")
print(A+B)
447 6 What will be the output of the following Python code? A 1 4 1 2 3
s="Learning Python is very easy"
print(s.count(" ",3,25))
448 6 Select the correct output of the following String operations B 1 7 6 5 4
str1 = "my isname isisis jameis isis bond";
sub = "is";
print(str1.count(sub, 7))

Page 3 of 13
L.J Institute of Engineering and Technology, Ahmedabad.
Python Question Bank (SEM-I-2024 ME,EC,CL,CH Engineering)
Note :
This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit MCQ
Sr No Question_Text Marks Option A Option B Option C Option D
Number Answer
449 6 What will be the output of the following code? D 1 4 (1,2,3) (1,2) (1,)
a = (1,2,3,4,5)
print(a[:-4])
450 6 Guess the correct output of the following code? C 1 Pytho on Pytho yth Pytho on yth Pytho on Pytho on Pytho
Pytho Pytho Pytho Pytho
str1 = "Python"
print(str1[1:4], str1[:5], str1[4:], str1[0:-1], str1[:-1])
451 6 s = 'foo' A 1 True False False True True False True
t = 'bar'
print('barf' in 2 * (s + t))
#print('frab' in 2 * (s + t))
What is the output of the above code?
452 6 What is the output of the following A 1 (30, 40, 50) (10, (30, 40, 50) (10, (20, 30, 50) (10, (20, 40, 50) (10,
myTuple = (10, 20, 30, 40, 50, 60, 70, 80) 20, 30, 40) (40, 50, 20, 40) (40, 50, 60, 20, 30, 40) (30, 40, 20, 30) (30, 40, 50,
print(myTuple[2:5], myTuple[:4], myTuple[3:]) 60, 70, 80) 70) 50, 60, 70, 80) 60, 70, 80)

453 6 What will be the output of the following code? C 1 (50,40,30) (10,20,30) (10,20) (30,40,50)
a = (10,20,30,40,50)
print(a[:-3])
454 6 What will be the output if the code is executed as shown B 1 False True True False False True
below?
a=(10,11,(14,15))
b=(10,11,(13,5))
print(a>b)
455 6 What will be the value of new a if we perform the following D 1 (9,10,11,12,13) (11,12,14,15) (11,12,13,15) TypeError
code on it?
a = (11,12,13,14,15)
del(a[-2])
456 6 What will be the output of below Python code? A 1 4 1 2 3
tupl=(1,2)
tupl2=tupl*2
print(len(tupl2))
457 6 What will be the output for following python code? A 1 (8, 9) (1, 2) (2, 3) (4, 5)
a=(1,2,3,4,5,6,7,8,9,10)
print(a[7:-1])
458 6 What will be the output for following python code? D 1 14 15 17 18
tupl=(1,2,3,[5,6],"hi",(5,6,7))
tupl1=()
tupl1=tupl*2
print(len(tupl1)+len(tupl))
459 6 What will be the output of the following python code? D 1 [1, 2, 5, 6] [5, 2, 1, 6] [2, 1, 6] [6, 5, 2, 1]
t = (5,2,1,6)
t1 = sorted(t, reverse = False^False^True)
print(t1)
460 7 Write a Python program to display elements of list by index 4
wise.
461 7 Write a Python program to print the even numbers from a 4
given list.
462 7 Write a Python Program to print the largest even number 4
in a list.
463 7 Write a Python Program to print the largest odd number in 4
a list.
464 7 Write a Python program to swap first and last element of 4
the list.
465 7 Write a Python program to find the sum of all the elements 4
in the list.
466 7 Write a Python function to sum all the numbers in a list 4

467 7 Write a Python program to add all items of one list to 3


another list.
468 7 Write a Python program of Reversing a List. 3
469 7 Write a Python program to Merging two Dictionaries 4
470 7 Write a Python program for Words Frequency in String 4
Shorthands.
Page 4 of 13
L.J Institute of Engineering and Technology, Ahmedabad.
Python Question Bank (SEM-I-2024 ME,EC,CL,CH Engineering)
Note :
This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit MCQ
Sr No Question_Text Marks Option A Option B Option C Option D
Number Answer
471 7 Write a Python program to calculate the sum of the 4
positive and negative numbers of a given list of numbers
using lambda function.
472 7 Write a Python program to rearrange positive numbers in a 4
given list using Lambda.
473 7 Write a Python program to count the even, odd numbers in 7
a given list of integers using Lambda.
474 7 Write a Python program to add two given lists using map 7
and lambda.
475 7 Write a Python program to find numbers divisible by 4
nineteen or thirteen from a list of numbers using Lambda.

476 7 Write a Python Program to print the smallest even number 3


in a list.
477 7 Write a Python program to rearrange positive and negative 3
numbers in a given list using Lambda.
478 7 Write a Python program to find the largest even and 4
smallest odd number from the List entered by user.
479 7 Write a Python program to filter a given list to determine if 3
the values in the list have a length of 6 using Lambda
function.
Example:
Input :
['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday',
'Saturday', 'Sunday']
Output:
Monday
Friday
Sunday
480 7 Write a python Program to filter only Even Numbers from 3
the List by using filter() Function (With Lambda Function).

481 7 What will be the output of the following Python code? D 1 {110, 50, 60} {100, 50, 60} {100, 110, 60} {100, 70, 110, 80}
(Output may be in random order but you have to choose
correct elements from given options)
x={50,60,70,80}
y={70,80,100,110}
print(x^y^x)
482 7 Python supports the creation of anonymous functions at A 1 lambda pi anonymous None of the
runtime, using a construct called __________ mentioned
483 7 What will be the output of the following Python code? A 1 48 14 64 None of the
y=6 mentioned
z = lambda x: x * y
print(z(8))
484 7 What will be the output of the following Python code? C 1 15 555 125 None of the
lamb = lambda x: x ** 3 mentioned
print(lamb(5))

485 7 Lambda contain return statements? B 1 TRUE FALSE anonymous None of the
mentioned
486 7 Lambda is a statement B 1 TRUE FALSE Unsupported None of the
mentioned
487 7 Lambda contains block of statements. B 1 TRUE FALSE Unsupported None of the
mentioned
488 7 What will be the output of the following Python code? B 1 Arthur Sir Sir Arthur Arthur None of the
def writer(): mentioned
title = 'Sir'
name = (lambda x: title + ' ' + x)
return name
who = writer()
print(who('Arthur'))

Page 5 of 13
L.J Institute of Engineering and Technology, Ahmedabad.
Python Question Bank (SEM-I-2024 ME,EC,CL,CH Engineering)
Note :
This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit MCQ
Sr No Question_Text Marks Option A Option B Option C Option D
Number Answer
489 7 What will be the output of the following Python code? C 1 27 6 9 None of the
L = [lambda x: x ** 2, 81 9 27 mentioned
lambda x: x ** 3, 343 12 81
lambda x: x ** 4]
for f in L:
print(f(3))
490 7 What will be the output of the following Python code? C 1 9997 9999 9996 None of the
min = (lambda x, y: x if x < y else y) mentioned
print(min(101*99, 102*98))
491 7 Which of the following commands will create a list? D 1 list1 = list() list1 = [] list1 = list([1, 2, 3]) All of the
mentioned

492 7 What is the output when we execute list(“hello”)? A 1 [‘h’, ‘e’, ‘l’, ‘l’, ‘o’] [‘hello’] [‘llo’] [‘olleh’]

493 7 Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is A 1 5 4 None Error


len(listExample)?
494 7 Suppose list1 is [2445,133,12454,123], what is max(list1)? C 1 2445 133 12454 123

495 7 Suppose list1 is [3, 5, 25, 1, 3], what is min(list1)? D 1 3 5 25 1


496 7 Suppose list1 is [1, 5, 9], what is sum(list1)? C 1 1 9 15 Error
497 7 Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following D 1 print(list1[0]) print(list1[:2]) print(list1[:-2]) All of the
is correct syntax for slicing operation? mentioned
498 7 Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]? C 1 Error None 25 2
499 7 Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]? A 1 [2, 33, 222, 14] Error 25 [25, 14, 222, 33, 2]

500 7 What will be the output of the following Python code? D 1 A Daman Error n
>>>names = ['Amir', 'Bear', 'Charlton', 'Daman']
>>>print(names[-1][-1])
501 7 What will be the output of the following Python code? B 1 11 12 21 22
names1 = ['Amir', 'Bear', 'Charlton', 'Daman']
names2 = names1
names3 = names1[:]
names2[0] = 'Alice'
names3[1] = 'Bob'
sum = 0
for ls in (names1, names2, names3):
if ls[0] == 'Alice':
sum += 1
if ls[1] == 'Bob':
sum += 10
print(sum)
502 7 Suppose list1 is [1, 3, 2], What is list1 * 2? C 1 [2, 6, 4] [1, 3, 2, 1, 3] [1, 3, 2, 1, 3, 2] [1, 3, 2, 3, 2, 1]
503 7 Suppose list1 = [0.5 * x for x in range (0, 4)], list1 is: C 1 [0, 1, 2, 3] [0, 1, 2, 3, 4] [0.0, 0.5, 1.0, 1.5] [0.0, 0.5, 1.0, 1.5,
2.0]
504 7 What will be the output of the following Python code? B 1 True False ERROR None of the
>>>list1 = [11, 2, 23] mentioned
>>>list2 = [11, 2, 2]
>>>list1 < list2
505 7 To add a new element to a list we use which command? B 1 list1.add(5) list1.append(5) list1.addLast(5) list1.addEnd(5)

506 7 To insert 5 to the third position in list1, we use which B 1 list1.insert(3, 5) list1.insert(2, 5) list1.add(3, 5) list1.append(3, 5)
command?
507 7 To remove string “hello” from list1, we use which A 1 list1.remove(“hell list1.remove(hello list1.removeAll(“h list1.removeOne(“
command? o”) ) ello”) hello”)
508 7 Suppose list1 is [3, 4, 5, 20, 5], what is list1.index(5)? D 1 0 1 4 2
509 7 Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is D 1 0 4 1 2
list1.count(5)?
510 7 Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after D 1 [3, 4, 5, 20, 5, 25, [1, 3, 3, 4, 5, 5, 20, [25, 20, 5, 5, 4, 3, [3, 1, 25, 5, 20, 5,
list1.reverse()? 1, 3] 25] 3, 1] 4, 3]
511 7 What will be the output of the following Python code? A 1 ['Welcome', 'to', (“Welcome”, “to”, {“Welcome”, “to”, “Welcome”, “to”,
>>>"Welcome to Python".split() 'Python'] “Python”) “Python”} “Python”

512 7 What will be the output of the following Python code? D 1 [‘abcd’] [‘a#b#c#d’] [‘a b c d’] ['a', 'b', 'c', 'd']
>>>list("a#b#c#d".split('#'))
Page 6 of 13
L.J Institute of Engineering and Technology, Ahmedabad.
Python Question Bank (SEM-I-2024 ME,EC,CL,CH Engineering)
Note :
This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit MCQ
Sr No Question_Text Marks Option A Option B Option C Option D
Number Answer
513 7 What will be the output of the following Python code? C 1 [1, 3, 4] [1, 4] [4, 3] [1, 3]
>>>list1 = [1, 3]
>>>list2 = list1
>>>list1[0] = 4
>>>print(list2)
514 7 What will be the output of the following Python code? C 1 1 Error 2 None of the
names1 = ['Amir', 'Bala', 'Chales'] mentioned
if 'amir' in names1:
print(1)
else:
print(2)
515 7 What will be the output of the following Python code? B 1 4 5 8 12
numbers = [1, 2, 3, 4]
numbers.append([5,6,7,8])
print(len(numbers))
516 7 To which of the following the “in” operator can be used to D 1 Lists Dictionary Set All of the
check if an item is in it? mentioned
517 7 What will be the output of the following Python code? D 1 2 4 5 8
list1 = [1, 2, 3, 4]
list2 = [5, 6, 7, 8]
print(len(list1 + list2))
518 7 Which of the following statements create a dictionary? D 1 d = {} d = {“john”:40, d = {40:”john”, All of the
“peter”:45} 45:”peter”} mentioned
519 7 What will be the output of the following Python code? C 1 1 4 5 8
def addItem(listParam):
listParam += [1]
mylist = [1, 2, 3, 4]
addItem(mylist)
print(len(mylist))
520 7 What will be the output of the following Python code? A 1 [‘carrot’, ‘celery’, [‘carrot’, ‘celery’, [‘carrot’, [‘celery’, ‘carrot’,
veggies = ['carrot', 'broccoli', 'potato', 'asparagus'] ‘broccoli’, ‘potato’, ‘broccoli’, ‘celery’, ‘broccoli’,
veggies.insert(veggies.index('broccoli'), 'celery') ‘potato’, ‘asparagus’] ‘potato’, ‘potato’,
print(veggies) ‘asparagus’] ‘asparagus’] ‘asparagus’]
521 7 a=[10,23,56,[78]] C 1 [10,34,56,[95]] [10,23,56,[78]] [10,23,56,[95]] [10,34,56,[78]]
b=list(a)
a[3][0]=95
a[1]=34
print(b)
522 7 What will be the output of the following Python code? A 1 [3, 7, 8, 6, 1, 2] Syntax error [3,[7,8],6,1,2] [3,4,6,7,8]
lst=[3,4,6,1,2]
lst[1:2]=[7,8]
print(lst)
523 7 What will be the output of the following Python code? B 1 [1,2,3,4] [1, 2, 3, 4] Syntax error [1,2,3]
a=[1,2,3] [1,2,3,4] None [1,2,3,4]
b=a.append(4)
print(a)
print(b)
524 7 What will be the output of the following Python code? B 1 [‘Bangalore’, [‘Bangalore’, [‘Bangalore’, [‘Bangalore’,
places = ['Bangalore', 'Mumbai', 'Delhi'] ‘Pune’, ‘Mumbai’, ‘Delhi’] ‘Pune’, ‘Delhi’] ‘Mumbai’,
places2 = places[:] ‘Hyderabad’] ‘Hyderabad’]
places2[2]="Hyderabad"
print(places)
525 7 What will be the output of the following Python code B 1 “john”, 40, 45, john 40 d = (40:”john”,
snippet? and “peter” peter 45 45:”peter”)
d = {"john":40, "peter":45}
for i in d:
print(i)
526 7 What will be the output of the following Python code A 1 True False None ERROR
snippet?
d = {"john":40, "peter":45}
print("john" in d)

Page 7 of 13
L.J Institute of Engineering and Technology, Ahmedabad.
Python Question Bank (SEM-I-2024 ME,EC,CL,CH Engineering)
Note :
This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit MCQ
Sr No Question_Text Marks Option A Option B Option C Option D
Number Answer
527 7 What will be the output of the following Python code B 1 True False None ERROR
snippet?
d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45}
d1 == d2
528 7 What will be the output of the following Python code D 1 True False None ERROR
snippet?
d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45}
d1 > d2
529 7 What will be the output of the following Python code A 1 40 45 “john” “peter”
snippet?
d = {"john":40, "peter":45}
d["john"]
530 7 Suppose d = {“john”:40, “peter”:45}, to delete the entry for C 1 d.delete(“john”:4 d.delete(“john”) del d[“john”] del d(“john”:40)
“john” what command do we use? 0)

531 7 Suppose d = {“john”:40, “peter”:45}. To obtain the number B 1 d.size() len(d) size(d) d.len()
of entries in dictionary which command do we use?

532 7 What will be the output of the following Python code A 1 ['john', 'peter'] [“john”:40, (“john”, “peter”) (“john”:40,
snippet? “peter”:45] “peter”:45)
d = {"john":40, "peter":45}
print(list(d.keys()))
533 7 Which of these about a dictionary is false? B 1 The values of a The keys of a Dictionaries aren’t Dictionaries are
dictionary can be dictionary can be ordered mutable
accessed using accessed using
keys values
534 7 Which of the following is not a declaration of the C 1 {1: ‘A’, 2: ‘B’} dict([[1,”A”],[2,”B {1,”A”,2”B”} {}
dictionary? ”]])
535 7 What will be the output of the following Python code A 1 1A2B3C 123 ABC 1:”A” 2:”B” 3:”C”
snippet?

a={1:"A",2:"B",3:"C"}
for i,j in a.items():
print(i,j,end=" ")
536 7 What will be the output of the following Python code B 1 {1: ‘A’, 2: ‘B’, 3: C {1: 3, 2: 3, 3: 3} No method called
snippet? ‘C’} setdefault() exists
a={1:"A",2:"B",3:"C"} for dictionary
print(a.setdefault(3))

537 7 What will be the output of the following Python code A 1 {1: ‘A’, 2: ‘B’, 3: NONE ERROR [1,3,6,10]
snippet? ‘C’, 4: ‘D’}
a={1:"A",2:"B",3:"C"}
a.setdefault(4,"D")
print(a)
538 7 What will be the output of the following Python code? C 1 {1: ‘A’, 2: ‘B’, 3: Method update() {1: ‘A’, 2: ‘B’, 3: {4: ‘D’, 5: ‘E’}
a={1:"A",2:"B",3:"C"} ‘C’} doesn’t exist for ‘C’, 4: ‘D’, 5: ‘E’}
b={4:"D",5:"E"} dictionaries
a.update(b)
print(a)
539 7 What will be the output of the following Python code? B 1 Error, copy() {1: ‘A’, 2: ‘B’, 3: {1: ‘A’, 2: ‘D’, 3: “None” is printed
a={1:"A",2:"B",3:"C"} method doesn’t ‘C’} ‘C’}
b=a.copy() exist for
b[2]="D" dictionaries
print(a)
540 7 Which of the following isn’t true about dictionary keys? C 1 More than one Keys must be Keys must be When duplicate
key isn’t allowed immutable integers keys encountered,
the last
assignment wins

Page 8 of 13
L.J Institute of Engineering and Technology, Ahmedabad.
Python Question Bank (SEM-I-2024 ME,EC,CL,CH Engineering)
Note :
This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit MCQ
Sr No Question_Text Marks Option A Option B Option C Option D
Number Answer
541 7 What will be the output of the following Python code? A 1 123 ‘A’ ‘B’ ‘C’ 1 ‘A’ 2 ‘B’ 3 ‘C’ Error, it should
a={1:"A",2:"B",3:"C"} be: for i in
for i in a: a.items():
print(i,end=" ")

542 7 What will be the output of the following Python code? D 1 Syntax error dict_items([(‘A’), dict_items([(1,2,3) dict_items([(1,
>>> a={1:"A",2:"B",3:"C"} (‘B’), (‘C’)]) ]) ‘A’), (2, ‘B’), (3,
>>> a.items() ‘C’)])
543 7 Which of the statements about dictionary values is false? C 1 More than one The values of the Values of a Values of a
key can have the dictionary can be dictionary must dictionary can be
same value accessed as be unique a mixture of
dict[key] letters and
numbers
544 7 What will be the output of the following Python code C 1 method del del deletes the del deletes the del deletes the
snippet? doesn’t exist for values in the entire dictionary keys in the
>>> a={1:"A",2:"B",3:"C"} the dictionary dictionary dictionary
>>> del a
545 7 What will be the output of the following Python code D 1 Error, dictionary ‘Numbers’: {1: 56, {‘Numbers’: {1: {‘Numbers’: {1:
snippet? in a dictionary 3: 7} 56}, ‘Letters’: {4: 56, 3: 7}, ‘Letters’:
numbers = {} can’t exist ‘B’}} {4: ‘B’}}
letters = {}
comb = {}
numbers[1] = 56
numbers[3] = 7
letters[4] = 'B'
comb['Numbers'] = numbers
comb['Letters'] = letters
print(comb)
546 7 What will be the output of the following Python code A 1 0 NONE 3 An exception is
snippet? thrown
test = {1:'A', 2:'B', 3:'C'}
test = {}
print(len(test))
547 7 What will be the output of the following Python code D 1 Exception is {‘b’: [2], ‘a’: 1} {‘b’: [2], ‘a’: [3]} {'a': 1, 'b': [2, 3, 4]}
snippet? thrown
a={}
a['a']=1
a['b']=[2,3,4]
print(a)
548 7 What will be the output of the following Python code? B 1 [2,3,4] 3 2 An exception is
a={} thrown
a[2]=1
a[1]=[2,3,4]
print(a[1][1])
549 7 What will be the output of the following Python code? A 1 An exception is ‘‘ 1 0
>>> a=dict() thrown since the
>>> a[1] dictionary is
empty
550 7 Which of these about a set is not true? D 1 Mutable data Set elements are Data type with Immutable data
type unique unordered values type

551 7 Which of the following is not the correct syntax for creating A 1 set([[1,2],[3,4]]) set([1,2,2,3,4]) set((1,2,3,4)) {1,2,3,4}
a set?
552 7 What will be the output of the following Python code? C 1 7 Error, invalid 4 8
nums = set([1,1,2,3,3,3,4,4]) syntax for
print(len(nums)) formation of set
553 7 Which of the following statements is used to create an B 1 {} set() [] ()
empty set?
554 7 What will be the output of the following Python code? A 1 True False {1,2} Invalid operation
>>> a={5,4}
>>> b={1,2,4,5}
>>> a<b

Page 9 of 13
L.J Institute of Engineering and Technology, Ahmedabad.
Python Question Bank (SEM-I-2024 ME,EC,CL,CH Engineering)
Note :
This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit MCQ
Sr No Question_Text Marks Option A Option B Option C Option D
Number Answer
555 7 If a={5,6,7}, what happens when a.add(5) is executed? B 1 a={5,5,6,7} a={5,6,7} Error as there is Error as 5 already
no add function exists in the set
for set data type
556 7 What will be the output of the following Python code? C 1 {4,5,6,2,8} {4,5,6,2,8,6} Error as Error as the
>>> a={4,5,6} unsupported duplicate item 6 is
>>> b={2,8,6} operand type for present in both
>>> a+b sets sets
557 7 What will be the output of the following Python code? A 1 {4,5} {6} Error as Error as the
>>> a={4,5,6} unsupported duplicate item 6 is
>>> b={2,8,6} operand type for present in both
>>> a-b set data type sets
558 7 What will be the output of the following Python code? D 1 {5,6,7,8,10,11} {7,8} Error as {5,6,10,11}
>>> a={5,6,7,8} unsupported
>>> b={7,8,10,11} operand type of
>>> a^b set data type
559 7 What will be the output of the following Python code? A 1 Error as {5,6,5,6,5,6} {5,6} Error as
>>> s={5,6} unsupported multiplication
>>> s*3 operand type for creates duplicate
set data type elements which
isn’t allowed
560 7 What will be the output of the following Python code? A 1 True False ERROR NONE
>>> a={5,6,7,8}
>>> b={7,5,6,8}
>>> a==b
561 7 Choose the correct option with respect to Python. B 1 Both tuples and Tuples are Both tuples and Tuples are
lists are immutable while lists are mutable. mutable while
immutable. lists are mutable. lists are
immutable.
562 7 What will be the output of the following Python code? C 1 [15,17,19] [15,16,17,18,19] [19,17,15] [19,18,17,16,15]
l = [11,12,13,14,15,16,17,18,19,20]
print(l[8:2:-2])
563 7 What will be the output of the following Python code? D 1 0 6 4 IndexError
n = [10,15,20,25,10,35,10,45,50]
print(n.pop(10))
564 7 What will be the output of the following Python code? D 1 Guest guest KISHAN Kishan
d = {12:"Rahul",14:"Gopi",16:"Kishan",18:"Jay"}
print(d.get(16,"Guest"))
565 7 What will be the output of the following Python code? B 1 [5,15,30,50,75,105 105 [5] [5,105]
from functools import* ]
l = [5,10,15,20,25,30]
sum = reduce(lambda x,y:x+y,l)
print(sum)
566 7 Which of the following sentence is not correct for C 1 Dictionary is a Hetrogeneous Duplicate keys Dictionaries are
dictionary? group of objects objects are and values are mutable.
as key-value pairs. allowed for both allowed.
keys and value.
567 7 What will be the output of the following Python code? B 1 [2,77,4,5,6] [2,3,4,5,6] [2,77,3,4,5,6] [2,3,4,5,6,77]
x = [2,3,4,5,6]
y = x.copy()
y[1] = 77
print(x)
568 7 What will be the output of the following Python code? C 1 [4,3,2,2,3,4] [4,3,2,3,4] [16,27,16] [8,9,8]
l1 = [4,3,2]
l2 = [2,3,4]
l3 = list(map(lambda x,y:x**y,l1,l2))
print(l3)
569 7 What will be the output of the following Python code? A 1 [1,1.5,2,2.5,3,3.5,4 [1,1.5,2,2.5,3,3.5,4 5 [1.5,2,2.5,3,3.5,4,4
n = [1,1.5,2,2.5,3,3.5,4,4.5,5] ,4.5] ,4.5,5] .5,5]
n.pop()
print(n)
570 7 What will be the output of the following Python code? B 1 {600,700,800} {400,500} {100,200,300} {100,200,300,400,
x = {100,200,300,400,500} 500}
y = {400,500,600,700,800}
print(x&y)
Page 10 of 13
L.J Institute of Engineering and Technology, Ahmedabad.
Python Question Bank (SEM-I-2024 ME,EC,CL,CH Engineering)
Note :
This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit MCQ
Sr No Question_Text Marks Option A Option B Option C Option D
Number Answer
571 7 What will be the output of the following python code? D 1 [1,2,3] [1,2,3,4] [4,1,2,3] TypeError
a = [1,2,3]
c=a+4
print( c )
572 7 What will be the output of the following python code? C 1 2 4 0 -1
n = [1,2,3,3,4,2,2,1,1,1]
print(n.count(5))
573 7 What will be the output of the following python code? D 1 [5,10,15,20] [5,10,15,20,1,77] [77,5,10,15,20] [5,77,10,15,20]
l = [5,10,15,20]
l.insert(1,77)
print(l)
574 7 What will be the output of the following python code? C 1 [2,4,6,8] [4,6,8,10] 10 2
x = [2,4,6,8,10]
print(x.pop())
575 7 What will be the output of the following python code? D 1 {1,2,3,4} {1,2,3,4,3,4,5,6} {1,2,3,4,5,6} {1,2,5,6}
x = {1,2,3,4}
y = {3,4,5,6}
print(x^y)
576 7 What will be the output of the following python code? D 1 [1,11,21,31,41] [1,15,21,31,41] [1,10,21,31,41] [1,10,20,31,41]
x = [1,11,21,31,41]
y = x[:]
z=y
x[1] = 15
y[1] = 10
z[2] = 20
print(z)
577 7 What will be the output of the following python code? C 1 {10:100,20:200,30 400 100 10
d = {10:100,20:200,30:300} :300,4:400}
print(d.get(10,400))
578 7 What will be the output of the following python code? D 1 {1:''Raj'',2:''Yash'', {1,2,3} {} SyntaxError
d = {1:''Raj'',2:''Yash'',3:''Vra''j} 3:''Vraj''}
for k,v in d.items():
print(k,end=” ”)
579 7 What will be the output of the following python code? C 1 {1,2,3,4} {1,2,3,4,3,4,5,6} {3,4} {6,5,4,3,2,1}
x = {1,2,3,4}
y = {3,4,5,6}
print(x&y)
580 7 What will be the output of the following python code? D 1 {10:''Ram'',20:''Sh ''Pavan'' ''10,Pavan'' Ram
d = {10:''Ram'',20:''Shyam''} yam'',10:''Pavan''}
print(d.setdefault(10,''Pavan''))
581 7 What will be the output of the following python code? D 1 [12,4,6,8,10,2] [4,6,8,10] [2,4,6,8,10] [12,4,6,8,10]
l = [2,4,6,8,10,12]
first = l.pop(0)
last = l.pop(-1)
l.insert(0,last)
print(l)
582 7 What will be the output of the following Python code? C 1 {1,2,3} {A,B,C} [1,2,3] {"A","B","C"}
dict1 = {"A":1, "B":2,"C":3}
print(list(dict1.values()))
583 7 What will be the output of the following Python code? B 1 0 1 2 3
a=2
b=3
c=4
d = lambda x: b-a*c**x
print(d(0))
584 7 What will be the output of the following Python code? B 1 ["a", "z",1.5,7,9] [37,'d',1.5,7,9] [-4,-5,1.5,7,9] [37,-4,1.5,7,9]
x = ["a", "z",1.5,7,9]
y=x
x[-4] = "d"
x[-5]=37
print(y)

Page 11 of 13
L.J Institute of Engineering and Technology, Ahmedabad.
Python Question Bank (SEM-I-2024 ME,EC,CL,CH Engineering)
Note :
This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit MCQ
Sr No Question_Text Marks Option A Option B Option C Option D
Number Answer
585 7 What will be the output of the following Python code? B 1 Sum 60 L [10,20,30]
from functools import*
L=[10,20,30]
Sum=reduce(lambda a,b:a+b,L)
print(Sum)
586 7 What will be the output of the following Python code? D 1 10 5 4 ValueError
A=["a",1.75,2,"c",4,5,10]
print(A.index(6))
587 7 What will be the output of the following Python code? A 1 {} [] () empty dictionary
K={1:30,2:31,3:32}
K.popitem()
K.popitem()
K.popitem()
print(K)
588 7 What will be the output of the following Python code? D 1 {1,2,7,8,9,10} {3,4,5} {7,8,9,10} {1,2,3,4,5}
A={1,2,3,4,5}
B={1,2,7,8,9,10}
A.symmetric_difference(B)
print(A)
589 7 What will be the output of the following Python code? C 1 s {10,20,30,40} {20} KeyError
s={10,20,30,40}
s.discard(10)
s.discard(40)
s.discard(30)
s.discard(50)
print(s)
590 7 What will be the output of the following Python code? C 1 L1 [0,3,6,9] [1,2,4,5,7,8,10] [0,1,2,3,4,5,6,7,8,9
L=[0,1,2,3,4,5,6,7,8,9,10] ,10]
L1=list(filter(lambda l:l%3!=0,L))
print(L1)
591 7 What is the output of the following set operation? D 1 {"Yellow", {"Blue", "Green", {"Blue", "Red", {'Red', 'Black',
sampleSet = {"Yellow", "Orange", "Black"} "Orange", "Black"} "Red"} "Yellow", 'Yellow', 'Green',
sampleSet.update(["Blue", "Green", "Red"]) "Orange", "Black"} 'Orange', 'Blue'}
print(sampleSet)
592 7 What is the output of the following code? C 1 1 ['Amit', 23, 21] False True
D={1: ['Amit',23,21], 2: ['Suman',45,34], 3: 'Ravi', 4: 'Anuj'}
print("Amit" in D)

593 7 If array_nums is the list entered by user then what does D 1 Rearrange even Rearrange Print Fibonacci Error
the following function do? and odd numbers positive and numbers
result = sorter(array_nums, key = lambda i: 0 if i == 0 else - of the said List negative numbers
1 / i) of the said List

594 7 What is the output of the following list comprehension? A 1 ['Hello Dear', ['Hello Bye, 'Hello ['Hello Dear', [Dear Hello', 'Bye
resList = [x+y for x in ['Hello ', 'Good '] for y in ['Dear', 'Bye']] 'Hello Bye', 'Good Dear, 'Good Dear', 'Hello Bye', 'Good Hello ', 'Good
print(resList) Dear', 'Good Bye'] 'Good Bye'] Bye, 'Good Bye'] Dear', 'Good Bye']

595 7 What is the output of the following code? A 1 {'A': 'Apple', 'B': {1 : ''One'' , 2 : {1 : ''One'' , 2 : {'A' : 'Apple', 'B' :
A = {1 : 'One', 2 : 'Two' , 3 : 'Three'} 'Bat', 'C': 'Cat', 'D': ''Two'' , 3 : ''Two'' , 3 : 'Bat' , 'C' : 'Cat' ,
B = {'A': 'Apple', 'B' : 'Bat' , 'C' : 'Cat' , 'D' : 'Doll'}A.update(B) 'Doll'} ''Three''} ''Three'' , 'A' : 'D' : 'Doll' , 1 :
#print(B.values()) 'Apple' , 'B' : 'Bat' , ''One'' , 2 : ''Two'' ,
print(B) 'C' : 'Cat' , 'D' : 3 : ''Three''}
'Doll'}
596 7 What will be the output of the following Python code? A 1 D C B A
names = ['Anshu', 'Bharat', 'Chintu', 'Dev']
print(names[-1][-3])
597 7 What will be the output of the following Python code? D 1 a,b,c,d abcd “a b c d” Error
print(list("a*b*cd".splited('*')))

Page 12 of 13
L.J Institute of Engineering and Technology, Ahmedabad.
Python Question Bank (SEM-I-2024 ME,EC,CL,CH Engineering)
Note :
This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit MCQ
Sr No Question_Text Marks Option A Option B Option C Option D
Number Answer
598 7 What will be the output of the following Python code? D 1 2022 Covid Covid 2022 2022 Covid
def f():
title = '2022'
name = (lambda x: title + ' ' + x)
return name
who = f()
print(who('Covid'))

Page 13 of 13

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy