0% found this document useful (0 votes)
5 views74 pages

PB Python-I Sem III 2024

The document is a practice book for the FCSP-1 course at L.J Institute of Engineering and Technology, containing multiple-choice questions (MCQs) related to Python programming. Each question includes options and the correct answer marked, covering various topics such as data types, operators, and basic programming constructs. It serves as a reference for students preparing for their examinations, though it notes that the actual test may not be entirely based on this book.
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)
5 views74 pages

PB Python-I Sem III 2024

The document is a practice book for the FCSP-1 course at L.J Institute of Engineering and Technology, containing multiple-choice questions (MCQs) related to Python programming. Each question includes options and the correct answer marked, covering various topics such as data types, operators, and basic programming constructs. It serves as a reference for students preparing for their examinations, though it notes that the actual test may not be entirely based on this book.
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/ 74

L.J Institute of Engineering and Technology, Ahmedabad.

FCSP-1 Practice Book (SEM-III )_ODD-2024


Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

1 1 Which character is used in Python to make a single line comment? D 1 / // ! #


2 1 What will be the output of print(type(2**5)) in python? A 1 <class 'int'> <class 'float'> <class 'double'> <class 'integer'>
3 1 What will be the output of print(type("LJU")) in python? C 1 <class 'int'> <class 'float'> <class 'str'> <class 'char'>
4 1 What will be the output of print(type(3*5/5)) in python? B 1 <class 'int'> <class 'float'> <class 'double'> <class 'integer'>
5 1 If x=3.123, then int(x) will give ? B 1 1 3 4 3.12
Which one of the following is correct way of declaring and initialising a variable, x with value 5? int x
6 1 C 1 int x=5 x=5 declare x=5
x=5
7 1 Which of the following is an invalid statement? B 1 abc = 1,000,000 a b c = 1000 2000 3000 a,b,c = 1000, 2000, 3000 a_b_c = 1,000,000
8 1 Which of the following is invalid? D 1 _x = 1 __x = 1 __x__ = 1 None of the mentioned
9 1 Which of the following cannot be a variable? B 1 __in__ in it __it__
10 1 Which of the following is an invalid variable? B 1 char_1 1st_char oopec _
What happens when '2' == 2 is executed?
11 1 B 1 True False ValueError TypeError
What will be the output of this program?
12 1 _ = '1 2 3 4 5 6' D 1 SyntaxError: EOL while scanning string literal SyntaxError: invalid syntax NameError: name '_' is not defined 123456
print(_)
The following is displayed by a print function call. Select all of the function calls that result in this output.
print('''tom print('tom
tom
13 1 C 1 \nsam print(”’tomsamharry”’) print(‘tom\nsam\nharry’) sam
sam
\nharry''') harry')
harry
What will be the output of the following program on execution? None python
14 1 print(print(print("python"))) B 1 None None python Error
python None
15 1 Which is the correct operator for power(Xy)? B 1 X^y X**y X^^y None of the mentioned
16 1 What is the answer to this expression, 34 % 3 is? B 1 7 1 0 5
What will be the output of the following program on execution?
a=0
b=6
17 1 B 1 0 6 True False
x=(a or b) or ((a and a) or (a and b))
print(x)
What will be the output of the following program on execution?
a=0
b=6
18 1 D 1 0 6 True False
x=(a or b) or ((a and a) or (a and b))
y=not(x)
print(y)
What will be the output of this program?
19 1 B 1 True ** False / True 1.0 0 Error
print(True ** False / True)
What is the average value of the following Python code snippet?
1. >>>grade1 = 80
20 1 D 1 84.5 86 84.0 85.0
2. >>>grade2 = 90
3. >>>average = (grade1 + grade2) / 2
Which of the following error occurs when you execute the following Python code?
21 1 C 1 Type Error Value Error Name Error Syntax Error
apple = mango
What is the output of this expression, 3*1**3?
22 1 B 1 1 3 9 27
Select option that will print:
23 1 A 1 print(‘hello-‘ + ‘how-are-you’) print(‘hello’, ‘how’, ‘are’, ‘you’) print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4) print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)
hello-how-are-you
In python we do not specify types, it is directly interpreted by the compiler, so consider the following operation to be
performed.
24 1 D 1 A = 27 // 5 A = int(27 / 5) A = 27 % 5 All of the mentioned
>>>A = 27 ? 5
objective is to make sure A has an integer value.
Which of the following is not a comparison operator in Python?
25 1 C 1 >= <= = !=
What will be the output of the following program on execution?
a=4
b=6
26 1 C 1 1.5 2 2.5 3
c=3
print(a+b*c/a-b)

What will be the value of the following Python expression?


27 1 A 1 10 8 9 7
8+2%3
What will be the value of x in the following Python expression?
28 1 B 1 65 66 23 24
x = int(63.55+8/3)
What are the values of the following Python expressions?
2**(3**2)
29 1 D 1 64, 512, 64 64, 64, 64 512, 512, 512 512, 64, 512
(2**3)**2
2**3**2
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of this program?


30 1 C 1 15.0 7.0 11.0 10.0
print(6 + 5 - 4 * 3 / 2 % 1)
What will be the output of this program?
31 1 C 1 Error 22 7 18
print(int(6 == 6.0) * 3 + 4 % 5)
What will be the value of X in the following Python expression?
32 1 D 0.5 30.0 30.8 28.4 27.2
X = 2+9*((3*12)-8)/10
What will be the output of the following Python code?
new= (1 and "True") and ('False' or Train)
33 1 C 1 This is True NameError – Train not defined This is False Syntax Error – invalid syntax
str= 'This statement is '+ new
print("This is False" if "False" in new else "This is True")
What will be the value of the following Python expression?
34 1 B 0.5 8 9 10 11
8+1%3
What should be the output of the following python code snippet:
x=0.0
35 1 y=48>0 B 1 True False Error No output
z=11<7
print(not(float(x or y or z)))
What will be the output of the following Python function in jupyter notebook?
36 1 D 0.5 a+bc abc a+bc' 'abc'
"a"+"bc"
The following is displayed by a print function call. Select all of the function calls that result in this output.
tom
print('tom print('''tom print('''tom
37 1 D 0.5 print(‘tom\nsam\nharry’) sam \tsam \nsam
sam
harry') \tharry''') \nharry''')
harry
What will be the output of the following program on execution?
38 1 C 0.5 Python is a verysimpleubject Python is a versimplsubject Name Error None of mentioned
x=Str("Python is a very\b simple\bsubject")
print(x)
What will be the output of the following program.
39 1 x = int(43.55+4/6) A 0.5 Name Error 22 43 8
print(X)
What is the output of the following assignment operator
a=10
40 1 D 0.5 12 8 9 Syntax Error
b=a-=2
print(b)
What will be the output of the following program on execution?
a=4
b=6
41 1 B 0.5 64.0 46.0 52.0 192.0
c=3
d=2
print(a+d**b*c/a-b)
What will be the output of this program?
42 1 A 0.5 4 6 22 Error
print(int("6" == 6.0) * 3 + 4 % 5)
What will be the output of the following program on execution?
a=0
b=6
c=9
43 1 C 0.5 0 6 9 10
d=10

x=(a or b) and ((a or c) or (b and d))


print(x)
What will be the value of X in the following Python expression?
44 1 X = 2+9*((3*12)-8)/10 A 0.5 True 0 30 30.8
print(bool(X))
What will be the datatype of the var in the below code snippet?
var = 10
45 1 print(type(var)) B 0.5 int int,str str str,str
var = "Hello"
print(type(var))
What will be the output of this program?
46 1 B 0.5 0 0.0 1.0 Error
print(True * False / True)
What is the output of the following python code:
x=125
47 1 y=13 C 0.5 125/13 10 9 9.62
x//=y
print(x)
What is the output of following python code:
48 1 A 0.5 False True True False True True True False False False True False False True False False
print(bool(0), bool(3.14159), bool(-3), bool(False))
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

a=5
b=10
49 1 B 0.5 522 521 525 5 10 5
c=1
print(a**c, b//a, c%a)
Which of the following is invalid?
50 1 A 0.5 1x=1 x1=1 __x__=1 _x=1
What is the output of this expression, 3**1**3/True?
51 1 C 0.5 1 3 3.0 27
What will be the output of the following program on execution?
a=0
52 1 A 0.5 True 1 0 False
b=5
a or b ==5 or True + 7 -4 * 3
What will be the output of the following program on execution?
a=50
53 1 D 0.5 0 60 50 Error
b=60
print((a and b)/False)
Write a Python program to add 2 Numbers with user input.
54 1 4
Write a Python program to find the area of Circle.
55 1 4
Write a Python program to find the area of Triangle.
56 1 4
Write a Python program to calculate the area of a trapezoid.
57 1 4
Write a Python program to calculate surface volume and area of a cylinder.
58 1 4
Write a Python program to convert Fahrenheit to Celsius and vice versa.
59 1 7
Write a python code to demonstrate calculator functionality.
60 1 7
Write a python program to convert Days into Years, Months and Days. (Ex: if input of Days = 370 then output will be,
61 1 7
years=1, months=0 and days = 5).
Write a Python program to convert hours into minutes and seconds (Ex : input of hours = 6 then output will be, minutes =
62 1 7
360 and seconds = 21600 ).
Write a Python program to find an integer exponent x such that a^x = n.
Input:
a = 2 : n = 1024
Output:
63 1 10 4
Input:
a = 3 : n = 81
Output:
4
Which one of the following if statements will not execute successfully: if (1, 2): if (1, 2): if (1, 2):
64 2 D 1 if (1, 2): print('foo')
print('foo') print('foo') print('foo')
Which of the following are valid if/else statements in Python, assuming x and y are defined appropriately: if x < y: print('foo')
65 2 A 1 elif y < x: print('bar') if x < y: if x > 10: print('foo') if x < y: print('foo') else: print('bar') None of mentioned
else: print('baz')
What does the following code print?
if 4 + 5 == 10:
TRUE
print("TRUE") TRUE FALSE
66 2 C 1 TRUE FALSE
else: FALSE TRUE
TRUE
print("FALSE")
print("TRUE")
What does the following code print?

x = -10 The negative number -10 is not valid here. It will cause an error because every if
67 2 B 1 This is always printed The negative number -10 is not valid here
if x < 0: This is always printed statement must have an else statement.
print("The negative number ", x, " is not valid here.")
print("This is always printed")
Which of the following is true about the code below?

x=3
if (x > 2): x will always equal 0 after this code if x is greater than 2, the value in x will be doubled if x is greater than 2, x will equal 0 after this
68 2 C 1 None of mentioned
x = x * 2; executes for any value of x after this code executes code executes
if (x > 4):
x = 0;
print(x)
Which one of the following is a valid Python if statement?
69 2 A 1 if a>=2 : if (a >= 2) if (a => 22) if a >= 22
What keyword would you use to add an alternative condition to an if statement?
70 2 C 1 else if elseif elif None of the above
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Which of the following will evaluate to true?


I. True and False
71 2 B 1 I II I and II II and III
II. False or True
III. False and (True or False)
Given two variables, num1 and num2, which of the following would mean that both num1 and num2 are positive integers?
72 2 D 1 (num1 == num2) (num1 == num2) or (num1 > 0) (num1 == num2) and (num1 < 0) (num1 == num2) and (num1 > 0)
What is the output from the following code?
a=3
73 2 B 1 True False 0 3
b = (a != 3)
print(b)
Which of the following evaluates to True when a is equal to b or when a is equal to 5?
74 2 C 1 a == b == 5 a = b or a = 5 a == b or a == 5 a = b and a = 5
Which statement will check if a is equal to b?
75 2 B 1 if a = b: if a == b: if a === c: if a == b
Given the nested if-else structure below, what will be the value of x after code execution completes
x=0
a=0
b = -5
if a > 0:
if b < 0:
x=x+5
76 2 D 1 2 0 3 4
elif a > 5:
x=x+4
else:
x=x+3
else:
x=x+4
print(x)
Given the nested if-else below, what will be the value x when the code executed successfully
x=2
a=5
b=5
if a > 0:
if b < 0:
x=x+5
77 2 B 1 0 5 2 3
elif a > 5:
x=x+4
else:
x=x+3
else:
x=x+2
print(x)
What is the output of the following if statement
a, b = 12, 5
if a + b: False True
78 2 B 1 Can't predict None of these
print('True')
else:
print('False')
Which of the following is not used as loop in Python?
79 2 C 1 for loop while loop do-while loop None of the above
A loop becomes infinite loop if a condition never becomes ________.
80 2 B 1 TRUE FALSE Null Both A and C
If the else statement is used with a while loop, the else statement is executed when the condition becomes _______.
81 2 B 1 TRUE FALSE Infinite Null
Python programming language allows to use one loop inside another loop known as?
82 2 C 1 switch foreach nested forall
What will be the output of given Python code?
n=7
c=0
while(n):
if(n>5):
4 5 6 5
83 2 c=c+n-1 B 1
16 11 7 10
n=n-1
else:
break
print(n)
print(c)
How many times will the loop run?
i=2
84 2 A 1 2 3 1 0
while(i>0):
i=i-1
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

How many times will the condition will be checked?


i=2
85 2 B 1 2 3 1 0
while(i>0):
i=i-1
What will be the output of the following Python code?
i=1
while True: 1
1
86 2 if i%3 == 0: C 1 2 Error None of these
2
break 3
print(i)
i+=1
What is the value of the var after the for loop completes its execution
var = 10
for i in range(10):
for j in range(2, 10, 1):
if var % 2 == 0:
87 2 continue B 1 20 21 10 30
var += 1
var+=1
else:
var+=1
print(var)
What will be the output of the following Python code?
88 2 for i in range(0,2,-1): C 1 Hello Hello Hello No Output Error
print("Hello")
89 2 Which of the following is a valid for loop in Python? B 1 for(i=0; i < n; i++) for i in range(0,5): for i in range(0,5) for i in range(5)
Which of the following sequences would be generated by the given line of code?
90 2 C 1 5 4 3 2 1 0 -1 543210 531 None of the above
range (5, 0, -2)
When does the else statement written after loop execute? When break statement is executed in the
91 2 B 1 When loop condition becomes false Else statement is always executed None of the above
loop
What is the output of the following for loop and range() function
92 2 for num in range(-2,-5,-1): D 1 -2, -1, -3, -4 -2, -1, 0, 1, 2, 3, -2, -1, 0 -2, -3, -4,
print(num, end=", ")
What will be the output of the following code?
x = 12
93 2 C 1 12 12 Error None of the above
for i in x:
print(i)
What is the value of x after the following nested for loop completes its execution
x=0
for i in range(10):
94 2 B 1 99 90 100 101
for j in range(-1, -10, -1):
x += 1
print(x)
What is the output of the following range() function
95 2 for num in range(2,-5,-1): C 1 2, 1, 0 2, 1, 0, -1, -2, -3, -4, -5 2, 1, 0, -1, -2, -3, -4 None of these
print(num, end=", ")
What is the value of x
x=0
96 2 while (x < 100): D 1 101 99 None of the above, this is an infinite loop 100
x+=2
print(x)
What is the output of the following nested loop
9
for num in range(10, 14): 11 10 12
10
for i in range(2, num): 12 11 13
97 2 B 1 11
if num%i == 1: 13 12 14
12
print(num) 14 13 15
break
What will be the output of the following Python code?
i=1
while True: 1
1
98 2 if i%3 == 0: A 1 2 Error None of these
2
break 3
print(i)
i += 1
What will be the output of the following Python code?
1 1
i=1
2 3
while True:
1 3 5
99 2 if i%2 == 0: D 1 1
2 4 7
break
5 9
print(i)
6… 11 …
i += 2
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following Python code?


i=2 2
while True: 4
2 2
100 2 if i%3 == 0: B 1 6 Error
4 3
break 8
print(i) 10..
i += 2
What will be the output of the following Python code?
i=1
1 1
while False:
3 2
101 2 if i%2 == 0: D 1 1 None of these
5 3
break
7.. 4..
print(i)
i += 2
What will be the output of the following Python code?
True = False
102 2 while True: D 1 TRUE FALSE None Error
print(True)
break
What will be the output of the following Python code?
103 2 B 1 0 No output Error None of mentioned
for i in range(0):
print(i)
What will be the output of the following Python code?
104 2 C 1 0.0 1.0 01 Error None of mentioned
for i in range(2.0):
print(i)
What will be the output of the following Python code?
0
105 2 B 1 0.0 1.0 Error None of mentioned
for i in range(int(2.0)): 1
print(i)
What will be the output of the following Python code?
106 2 for i in range(float('inf')): D 1 0.0 0.1 0.2 0.3 … 0123… 0.0 1.0 2.0 3.0 … None of mentioned
print (i)
What will be the output of the following Python code?
0
for i in range(5): 0
1 0 1
if i == 5: 1
2 1 2
break 2
107 2 A 1 3 2 3
else: 3
4 3 4
print(i) 4
5 4 5
else: Here
Here
print("Here")
What will be the output of the following Python code?
0
for i in range(10): 0
1 0 1
if i == 5: 1
2 1 2
break 2
108 2 C 1 3 2 3
else: 3
4 3 4
print(i) 4
5 4 5
else: Here
Here
print("Here")
What will be the output of the following Python code snippet?
0
1
x=2 0
109 2 B 1 2 0 Error
for i in range(x): -2
3
x -= 2
4
print (x)
What will be the output of the following Python code snippet? 0
0
x=2 1
0 3 1
110 2 for i in range(x): C 1 2
1 4 2
x += 1 3
3
print (x) 4..
What will be the output of the following Python code?

i=0
while i < 5: 0
0
print(i) 1
111 2 A 1 1 Error None of these
i += 1 2
2 0
if i == 3:
break
else:
print(0)
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following Python code?

i=0 0 0
0 1
while i < 3: 1
112 2 C 1 1 2 Error
print(i) 3
2
2
i += 1 0 0
else:
print(0)
What will be the output of the following Python code?
0
1
x=2 0
113 2 B 1 2 0 error
for i in range(x): -2
3
x -= 2
4…
print (x)
114 2 The continue statement can be used in? D 1 while loop for loop do-while Both A and B
What is the output of following python code?

int("Enter value of x:")


115 2 for in range[0, 10]: D 1 They are unequal They are equal 0,1,2,3,4,5,6,7,8,9 SyntaxError
print("They are equal")
else:
print( "They are unequal")
What is the output of following python code?

116 2 a=5 A 1 yes no ZeroError SyntaxError


b = 5.0
print('yes') if (a == b) else 'no'
What is the output of following python code?

a=b=0
117 2 if (a = b): D 1 yes 0 ZeroError SyntaxError
print(0)
else:
print('otherwise')
What is the output of following python code?

Step = 3
for e in range(0, step):
118 2 B 1 3 NameError ZeroError SyntaxError
if e%2==0:
print('hello')
else:
print('goodbye')
What will be the output of the following Python code?
x = 123
119 2 C 0.5 123 123 Type Error Key Error
for i in x:
print(i)
What is the output of the following snippet?
theSum = 0
120 2 for count in range(2, 11, 2): C 1 25 20 30 23
theSum += count
print(theSum)
What will be the output of the following snippet?
a = True
b = False
c = False

if not a or b:
121 2 print (1) C 1 1 2 3 4
elif not a or not b and c:
print (2)
elif not a or b or not b and a:
print (3)
else:
print (4)
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following Python code?


var = 10
for i in range(5):
for j in range(2, 3, 1):
if var%2 == 0:
122 2 break B 1 19 20 21 14
var += 1
var+=1
else:
var+=1
print(var)
What will be output of following code?
A=70
if A>90:
print('Grade A')
elif A>70 and A<90:
print('Grade B')
123 2 D 1 Grade A Grade B Grade C Fail
elif A>50 and A<70:
print('Grade C')
elif A>35 and A<50:
print('Grade D')
else:
print('Fail')
What will be output of following code?
seconds=3650
if seconds>=3600:
hour=seconds//3600
seconds %= 3600
print(hour,"hours",end=" ")
124 2 A 1 1 hours 50 seconds 1 hours 0 minutes 50 seconds 1 hours 50 minutes 0 hours 0 minutes 3650 seconds
if seconds>=60:
minute=seconds//60
seconds %= 60
print(minute,"minutes",end=" ")
if seconds>0:
print(seconds,"seconds")
What will be output of following code?
A=0
for i in range(4):
if i%2==0:
pass
125 2 C 1 4 3 2 0
else:
continue
break
A+=1
print(A)
What will be the output of the following code snippet?
count = 0
while(True):
if count % 3 == 0:
126 2 A 1 0 3 6 9 12 15 0123 0369 0 3 6 9 12
print(count, end = " ")
if(count > 15):
break;
count += 1
What is the output of the following code?
a = True
b = False
c = True

if not a or b:
127 2 print ("a") B 1 a b c d
elif not a or not b and c:
print ("b")
elif not a or b or not b and a:
print ("c")
else:
print ("d")
What does the following code print?
if 5 + 5 == 10:
print("TRUE") TRUE TRUE
128 2 D 0.5 TRUE FALSE
else: FALSE TRUE
print("FALSE")
print("TRUE")
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Which of the following will evaluate to true?


I. True and False
129 2 II. False or True D 0.5 I II I, II II, IV
III. False and (True or False)
IV. True and (True or False)
What is the output of the following nested loop
for num in range(26, 30):
for i in range(2, num):
130 2 C 0.5 26,27,28 26,27,28,29 26,27,28,29, 27,29
if num%i == 1:
print(num, end=’,’)
break
What is the value of the var after the for loop completes its execution:
var = 10
for i in range(10):
for j in range(2, 10, 1):
if var % 2 == 0:
131 2 var += 1 D 1 20 21 30 31
continue
var+=1
else:
var+=1
print(var)
What should be the output of the following python code snippet:
a=5
b=7
c=2

if a>b:
132 2 a,b = b,a C 1 2,5,7 7,5,2 2 5 7, 7 5 2,
if a>c:
a,c = c,a
if b>c:
b,c = c,b

print(a,b,c,end=",")
What is the value of x after the following nested for loop completes its execution
x=0
for i in range(1,10):
133 2 A 0.5 81 90 80 99
for j in range(-1, -10, -1):
x += 1
print(x)
What is the value of x
x=0
134 2 while (x < 100): D 0.5 98 99 100 102
x+=3
print(x)
What will be the output of the following program.

if (9 < 0) and (0 < -9):


print("hello")
135 2 A 0.5 Indentation error hello good bad
elif (9 > 0) or False:
print("good")
else:
print("bad")
What is the output of the following code?
c=1
s=0
while c<=8:
136 2 A 1 28 30 21 35
c=c-1
s=s+c
c=c+2
print(s)
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Which of the following lines contains an error?

137 2 B 1 line 2 line 6 line 5 No error

While executing tis code, which line will produce an error:

138 2 D 1 line 5 line 7 line 9 line 12

What is the output of the following code?


val = 154
while(not(val)):
139 2 val**=2 A 0.5 77 11 154 11858
else:
val//=2
print(val)
What is the output of the following code?
n=10
i=1
while(i<=n):
k=0
if(n%i==0):
j=1
140 2 A 1 2 5 10 100 20
while(j<=i):
if(i%j==0):
k=k+1
j=j+1
if(k==2):
print(i,end=" ")
i=i+1
What will be the output of Python code?

i,j=1,4
while True:
141 2 if(i%7==0 or j%9==0): C 1 59 67 69 79
break
i+=1
j+=1
print(i,j)
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of given Python code?


n=5
c=0
while(n):
if(n>5):
142 2 c=c+n-1 A 1 54 50 5 11 40
n=n-1
else:
c=c+n-1
break
print(n, c)
What will be the output of the following program on execution?
143 2 for i in range(1,0,-1): A 0.5 hello 0 -1 no output
print("hello")
What will be the output of the following program on execution?
for x in range(0,15):
if(x%3==0):
continue
144 2 if(x%5==0): A 0.5 124 0124 01 23456 1 23456
continue
if(x%7==0):
break
print(x,end=" ")
What will be the output of the following program on execution?
for i in range (1,11):
145 2 sum=0 A 0.5 10 11 55 0
sum+=i
print(sum)
What will be the output of the following program on execution?
n=6
for i in range(4,n,1):
146 2 if i==5: A 0.5 no output 4 5 n
break
else:
print(n)
What will be the output of the following program on execution?
n=1
for i in range(1,n,1):
147 2 A 0.5 hi hello no output value errror
print("hello")
else:
print("hi")
What will be the output of the following program on execution?
for i in range(1,11):
x=0
x+=i
while(x<15):
148 2 A 1 15 17 16 14
if i%2==0:
x+=1
else:
x+=2
print(x)
What will be the output of the following program on execution?
x=10
if x<15:
print("h",end=" ")
elif x>12:
print("i",end=" ")
149 2 A 1 h Name H name hi hi name
else:
print("student",end=" ")
if x<9:
print("name",end=" ")
else:
print("Name",end="")
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following program on execution?


x=0
count=0
while x<15:
if x%2==0:
x+=1
continue
150 2 A 1 15 15 5 05 00
if x%3==0:
x+=1
continue
if count==5:
break
count+=1
print(x,count)
What will be the output of the following program on execution?
x=0
count=0
for x in range(10):
while x<15:
if x<0:
pass
elif x%2==0:
151 2 x+=1 A 1 11 5 10 5 16 5 14 5
continue
elif x%3==0:
x+=1
continue
elif count==5:
break
count+=1
print(x,count)
Write a program to determine a given number is ‘odd’ or ‘even’ and print the following message “Number is ODD” or
152 2 3
“Number is Even”.
Write a program to check if the input number is positive, negative or zero.
153 2 3

Write a program to find the maximum number among the three input numbers.
154 2 7

Write a program to check if year is a leap year or not (Nested If).


155 2 7

Write a program to find sum of first N natural numbers given by user.


156 2 4

Write a program to find average of first N natural numbers given by user.


157 2 4

Write a python program to read three numbers (a,b,c) and check how many numbers between ‘a’ and ‘b’ are divisible by
158 2 4
‘c’.
Write a Python program that prints all the numbers from 0 to 6 except 3 and 6.
159 2 4

Write a Python program to print the multiplication table of given number by user.
160 2 4

Write a program to find the factorial of a number provided by the user.


161 2 4

Write a python program to display the Fibonacci sequence up to n-th term.


162 2 4

Write a program to take 10 values from keyboard using loop and print their average on the screen
163 2 4

Write a program to reverse a number.


164 2 7

Write a program to check whether a number is Armstrong number or not.


165 2 7

Write a program to check if a number is prime or not.


166 2 7

Write a program to print prime numbers between given interval from user
167 2 7

Draw a pattern using a python program:


*
168 2 * * 7
* * *
* * * *
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Draw a pattern:
* * * *
169 2 * * * 7
* *
*
Draw a pattern using a python program:
*
170 2 * * 7
* * *
* * * *
Draw a pattern:
* * * *
171 2 * * * 7
* *
*
Draw a pattern using a python program:
1 2 3 4 5
1 2 3 4
172 2 7
1 2 3
1 2
1
Draw a pattern using a python program:
1
173 2 1 2 3
1 2 3
1 2 3 4
Draw a pattern using a python program:
1
174 2 2 2 3
3 3 3
4 4 4 4
Draw a pattern using a python program:
*
175 2 # # 4
* * *
# # # #
Draw a pattern using a python program:
1
176 2 0 1 4
1 0 1
0 1 0 1
Draw a pattern using a python program:
1
177 2 1 2 4
1 2 3
1 2 3 4
Draw a pattern using a python program:
1
178 2 2 2 4
3 3 3
4 4 4 4
Draw a pattern using a python program:
*
179 2 # # 4
* * *
# # # #
Gross Pay, Annual Income and Income Tax Calculator
Write a Python Program to make the gross pay, annual income and income tax calculator using following data.
The gross pay consists of Basic Pay, House Rent Allowance (hra), Dearness Allowance (dra), other allowances and
professional tax and provident fund.
Gross Pay= Basic Pay+ House Rent Allowance (hra) + Dearness Allowance (dra) +other allowances +Transport Allowance
(TA)– Professional tax –Employees’ Provident fund (EPF)
Basic Pay for different grade levels are indicated in table given.
The Professional tax remains constant and that is equal to 200 Rs. for each grade levels and each month.
House Rent Allowance (hra) varies as per the city- For Class 1 Cities it is 0.3 times of Basic Pay of each grade levels, for Class
2 Cities it is 0.2 times of Basic Pay of each grade levels, for Class 3 Cities it is 0.1 times of Basic Pay of each grade levels,
Dearness Allowance (dra)= 0.5 times of Basic Pay of each grade levels, Other allowances are given in table which varies
according to different grade levels, Provident Fund= 0.11 times of Basic Pay for each grade levels, Transport Allowance
remains constant as 900 Rs. for each levels.
For different grade pays:
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

The gross pay calculated is only for one month.


After calculating Gross Pay of each employee calculate the annual pay for employee by multiplying gross pay calculated, by
12.
So, Annual Pay of an employee=Gross Pay of an employee*12
From Annual Pay of an Employee Calculate the income tax as per the slabs of India Income Tax 2022-23 given below.
Tax Slabs for AY 2022-23

180 2 9

Input & Output:


Enter the grade_level (A,B,C,D,E or F:)A
city 1 is a tier 1 (metro), city 2 is tier 2 and city 3 is tier 3
Enter the city (1,2 or 3)1
Gross Pay of an Employee is: 110100.0
Annual income of an employee is: 1321200.0
Income Tax to be paid by an employee is: 142800.0

Write a python program to print all numbers between 1 and 100 (including 1 and 100) that are both, Disarium and
Harshad numbers.

A number is said to be a Disarium number when the sum of its digit raised to the power of their respective positions
becomes equal to the number itself.
For example, 175 is a Disarium number as follows:
11+ 72 + 53 = 1+ 49 + 125 = 175

181 2 5
A harshad number is a number that is divisible by the sum of its digits. E.g., the number 18 is a harshad number, because
the sum of the digits 1 and 8 is 9 (1 + 8 = 9), and 18 is divisible by 9.

Grading scheme:
2 marks for writing correct code for checking Disarium number
2 marks for writing correct code for checking Harshad number
1 mark for writing correct code for only printing those numbers that are both, Disarium and Harshad numbers.
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Ask the user to enter 10 test scores. Write a program to do the following:
a)If user enters score greater than 100, then give warning to user that entered score is more than 100 and take that
input again from user. b)Print out the highest and lowest scores.
c)Print out the average of the scores. d)Print out the second largest score.
e)Drop the two lowest scores and print out the average of the rest of them.
Note: Use of Python Data structures like string, list, tuple etc. and their inbuilt function is not allowed.
For Ex.
If Input is like following:
Enter Test Score: 80
Enter Test Score: 65
Enter Test Score: 98
Enter Test Score: 70
Enter Test Score: 93
182 2 Enter Test Score: 130 6
Entered score is more than hundred, so enter again
Enter Test Score: 95
Enter Test Score: 50
Enter Test Score: 40
Enter Test Score: 75
Enter Test Score: 72

Output should be:


Highest Score is: 98
Lowest Score is: 40
Average Test Score is: 73.8
Second Largest Score is: 95
Average after dropping the two lowest scores: 81.0
Write a program to encode a number by changing the digits in the given positive integer by user. The rule for changing the
digits in number will be:
If the digit in number is between 0 to 8 than replace the number with 1 to 9 respectively. (incrementing each digit by +1).
If the digit is 9, then replace it with 0.
To encode a number, replace digits in following manner:
For example:
Input: 31590218
Output: The number after encoding is: 42601329
For example:
Input: 9259
Output: The number after encoding is: 360
For example:
Input: 65217001
183 2 Output: The number after encoding is: 76328112 5
Original Digit in Number New Digit after Encoding
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 0
Note: Use of Python Data structures like string, list, tuple etc. and their inbuilt function is not allowed.

Write a python program to swap first and last digits of a number using loop.
184 2 5
(for example: input = 123456 then output=623451)
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Print the following pattern using loop

185 2 4

Write a program to implement the calculator for the date of Easter.


The following algorithm computes the date for Easter Sunday for any year between 1900 to 2099.
Ask the user to enter a year. Compute the following:
1.a = year % 19
2.b = year % 4
3.c = year % 7
4.d = (19 * a + 24) % 30
186 2 5.e = (2 * b + 4 * c + 6 * d + 5) % 7 6
6.dateofeaster = 22 + d + e
Special note: The algorithm can give a date in April. You will know that the date is in April if the calculation gives you an
answer greater than 31. (You’ll need to adjust) Also, if the year is one of four special years (1954, 1981, 2049, or 2076)
then subtract 7 from the date.
Eg:
Input: Year : 2022
Expected Outcome: 2022-04-17 (i.e. 17th April 2022)
Write a Python program to compute the greatest common divisor (GCD) of two positive integers.
The greatest common divisor (GCD) of two nonzero integers a and b is the greatest positive integer d such that d is a
187 2 divisor of both a and b; that is, there are integers e and f such that a = de and b = df, and d is the largest such integer. The 4
GCD of a and b is generally denoted gcd(a, b).
For example, the greatest common factor of 15 and 10 is 5, since both the numbers can be divided by 5.
Write a python program that prompts the user to enter numbers and stops only when the use enter “QUIT” . After this
print sum and average of the numbers, minimum and maximum number from given numbers entered by user.
Note: you are not allowed to use any built in structures like, list ,tuple etc. or any builtin function like min, max etc.
For Example: Input: 4,1,5,”QUIT”
Output:
188 2 Sum=10 4
Average=3.333
Minimum number=1
Maximum number=5
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

189 2 6

Write a program that enters a single digit integer number and produces all possible 6-digit numbers for which the product
of their digits is equal to the entered number.
Example: "number" → 2
•111112 → 1 * 1 * 1 * 1 * 1 * 2 = 2
190 2 •111121 → 1 * 1 * 1 * 1 * 2 * 1 = 2 4
•111211 → 1 * 1 * 1 * 2 * 1 * 1 = 2
•112111 → 1 * 1 * 2 * 1 * 1 * 1 = 2
•121111 → 1 * 2 * 1 * 1 * 1 * 1 = 2
•211111 → 2 * 1 * 1 * 1 * 1 * 1 = 2
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Write a Python program that prompts the user to enter numbers and stops only when the user enters “stop”. After this,
print the minimum even, maximum even, average of even number, minimum odd, maximum odd, average of odd number
from among all the numbers entered by the user.
Note: You are not allowed to use any built-in structures like lists, tuples, etc. or any built-in functions like max, min, sum
Example: input and output
enter number or q for'stop:'-1
enter number or q for'stop:'-5
191 2 5
enter number or q for'stop:'9
enter number or q for'stop:'2
enter number or q for'stop:'4
enter number or q for'stop:'6
enter number or q for'stop:'stop
Output:
for even 6 2 4.0 (max, min, avg)
for odd 9 -5 1.0 (max, min, avg)
What is the output of the following function call?
def fun1(name, age=20):
192 3 A 1 Emma 25 Emma 20 Emma, 25 Emma, 20
print(name, age)
fun1('Emma', 25)
What will be the output of the following Python code?
a=10
b=20
def change():
global b 10 45 10
193 3 A 1 Syntax Error
a=45 56 56 20
b=56
change()
print(a)
print(b)
What will be the output of the following Python code?
def display(b, n):
while n > 0:
194 3 A 1 zzz zz An exception is executed Infinite Loop
print(b,end="")
n=n-1
display('z',3)
What will be the output of the following Python code?
def fun(x,y,z):
195 3 A 1 432 24000 430 No output
return x + y + z
print(fun(2,30,400))
What will be the output of the following Python code?
def func():
global value
196 3 value = "Local" A 1 Local Global None Error
value = "Global"
func()
print(value)
What will be the output of the following Python code?
def say(message, times = 1):
Hello Hello Hello Hello
197 3 print(message * times) A 1
WorldWorldWorldWorldWorld World 5 World,World,World,World,World HelloHelloHelloHelloHello
say('Hello')
say('World', 5)
What will be the output of the following Python code?
def sub(a,b):
-100 100 100 -100
198 3 print(a-b) A 1
100 100 -100 -100
sub(100,200)
sub(200,100)
What will be the output of the following Python code?
x = 50
def func(x):
x is 50 x is 50 x is 50
print('x is', x)
199 3 A 1 Changed local x to 2 Changed local x to 2 Changed local x to 2 None of the mentioned
x=2
x is now 50 x is now 2 x is now 100
print('Changed local x to', x)
func(x)
print('x is now', x)
What will be the output of the following Python code?
def C2F(c):
212 212.0 567
200 3 return c * 9/5 + 32 B 1 None of the mentioned
32 32.0 98
print(C2F(100))
print(C2F(0))
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following Python code?


def function1(var1=5, var2=7):
var2=9
201 3 B 1 5 7 3 9 10 12 Error
var1=3
print (var1, " ", var2)
function1(10,12)
What will be the output of the following Python code?
def maximum(x, y):
if x > y:
return x
202 3 elif x == y: B 1 2 3 The numbers are equal None of the mentioned
return 'The numbers are equal'
else:
return y
print(maximum(2, 3))
What will be the output of the following Python code?
def power(x, y=2):
r=1
for i in range(y): 212 9 567
203 3 B 1 None of the mentioned
r=r*x 32 27 98
return r
print(power(3))
print(power(3,3))
What will be the output of the following Python code?
x = 50
def func():
global x x is 50 x is 50 x is 50
204 3 print('x is', x) B 1 Changed global x to 2 Changed global x to 2 Changed global x to 50 None of the mentioned
x=2 Value of x is 50 Value of x is 2 Value of x is 50
print('Changed global x to', x)
func()
print('Value of x is', x)
What is the output of the add() function call?
def add(a, b):
205 3 return a+5, b+5 C 1 15 8 (8,7) Syntax Error
result = add(3, 2)
print(result)
What will be the output of the following Python code?
def change(i = 1, j = 2):
i=i+j An exception is thrown because of conflicting
206 3 C 1 12 33 32
j=j+1 values
print(i, j)
change(j = 1, i = 2)
What will be the output of the following Python code?
def cube(x):
207 3 return x*x*x C 1 9 3 27 30
x = cube(3)
print(x)
What will be the output of the following Python code?
def func(a, b=5, c=10):
a is 7 and b is 3 and c is 10 a is 3 and b is 7 and c is 10 a is 3 and b is 7 and c is 10
print('a is', a, 'and b is', b, 'and c is', c)
208 3 C 1 a is 25 and b is 5 and c is 24 a is 5 and b is 25 and c is 24 a is 25 and b is 5 and c is 24 None of the mentioned
func(3, 7)
a is 5 and b is 100 and c is 50 a is 50 and b is 100 and c is 5 a is 100 and b is 5 and c is 50
func(25, c = 24)
func(c = 50, a = 100)
What will be the output of the following Python code?
def function1(var1,var2=5):
var1=2
Error as var2 is not defined while calling the Does not give any error as var2 is a default
209 3 var3=var1*var2 C 1 10 15
function argument
return var3
var1=3
print(function1(var1,var2))
What will be the output of the following Python code?
def printMax(a, b):
if a > b:
print(a, 'is maximum')
210 3 elif a == b: C 1 3 4 4 is maximum None of the mentioned
print(a, 'is equal to', b)
else:
print(b, 'is maximum')
printMax(3, 4)
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following Python code?


i=0
def change(i):
211 3 i=i+1 C 1 1 Nothing is displayed 0 An exception is thrown
return i
change(1)
print(i)
What is the output of the following function call?
def fun1(num):
212 3 return num + 25 D 1 25 5 30 NameError
fun1(5)
print(num)
What will be the last line of the output of the following Python code if test_fib(6) is called?
def fib(x):
global num_fib_calls
num_fib_calls += 1
if x == 0 or x == 1:
return 1
else:
213 3 return fib(x-1) + fib(x-2) D 1 fib called 5 times fib called 10 times fib called 20 times fib called 25 times

def test_fib(n):
for i in range(n+1):
global num_fib_calls
num_fib_calls = 0
print('fib of', i, '=', fib(i))
print('fib called', num_fib_calls, 'times.')
What will be the output of the following Python code?
def f(p, q, r):
global s
p = 10
q = 20
214 3 A 1 10 20 30 40 10 20 30 4 1 2 3 40 1234
r = 30
s = 40
print(p,q,r,s)
p,q,r,s = 1,2,3,4
f(5,10,15)
If number of arguments in function definition and function call does not match, then which type of error is returned?
215 3 D 1 NameError ImportError funError TypeError
What will be the output of the following Python code?
def power(x, y=3):
r=1
for i in range(y):
216 3 C 0.5 33 99 27 27 9 27
r=r*x
return r
print(power(3),end=" ")
print(power(3,3))
Select which is true for Python function:
i) A function is a code block that only executes when called and always returns a value.
217 3 C 1 only i only ii I & ii I & iii
ii) A function only executes when it is called and we can reuse it in a program.
iii) Python doesn’t support nested function
What will be the output of the following Python code?
def function1(var1=7,var2=5):
var1=2
var3=var1*var2
218 3 A 0.5 12 10 18 25
return var3
var2=6
var1=3
print(function1(var1,var2))
What will be the output of the following Python code?
def fun(a=5,b=10,c):
219 3 D 0.5 400 1 5 25 2 5 400 2 30 Error
print(a**2,b//a,c**1)
fun(20,c=30)
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following python code?


car=20
bike=10
cycle=30
def new_Pur():
global bike,cycle
220 3 B 0.5 30 15 35 30 25 55 30 25 35 20 25 55
car=30
bike=20
cycle=50
new_Pur()
print(car+10," ",bike+5," ",cycle+5)

What will be the output of the following Python code?


def f():
print(x,end=" ")
return y
def f():
221 3 A 1 4 None 54 45 5
print(y,end=" ")
return
x=5
y=4
print(f())
Create a pair of functions to convert Fahrenheit to Celsius temperature values and vice versa. Where C = (F - 32) * (5 / 9)
222 3 3

Write a Python function to calculate the factorial of a given number.


223 3 3

Write a Python function to check whether a number is in a given range.


224 3 3

Write a Python function to display the Fibonacci sequence till the given user input n.
225 3 4

Write a Python function to find the Max of TWO numbers.


226 3 3

Write a Python program to accept two numbers and check it for odd or even number
227 3 3

Write a Python program to check whether the given no is Armstrong or not using user defined function.
228 3 3

Write a python program to demonstarte a function to print the number 1 to 5.


229 3 3

Write a Python Program to demonstarte a Simple Calculator using python functions


230 3 3

Write a Python program to demonstrate the function of finding sum and average of first n natural numbers.
231 3 3

Write a Python program to demonstrate the function of finding multiplication of first n natural numbers.
232 3 3

Write a Python program to find reverse of given number using user defined function.
233 3 3

Write your own python program for computing square roots that implements Newton’s Method. Use of inbuilt function,
math library or x**0.5 is not allowed.

Newton Method is a category of guess-and-check approach. You first guess what the square root might be and then see
how close your guess is. You can use this information to make another guess and continue guessing until you have found
the square root (or a close approximation to it). Suppose x is the number we want the root of and guess is the current
guessed answer. The guess can be improved by using (guess+ x/guess)/2 as the next guess.
234 3 5
The program should -
1.Prompt the user for the value to find the square root of (x) and the number of times to improve the guess.
2.Starting with a guess value of x/2, your program should loop the specified number of times applying Newton’s method
and report the final value of guess.

What arithmetic operators cannot be used with strings?


235 4 A 1 - + * All of the mentioned
Name the function which is used to find length of string.
236 4 B 1 length( ) len( ) slen( ) strlen( )
What will be the output of above Python code?
237 4 str1="6/4" C 1 1 6/4 str1 1.5
print("str1")
What will be the output of below Python code?
238 4 str1="Programming" B 1 ogram gramm rammin ogramming
print(str1[3:8])
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will the below Python code will return? It returns the first index position of the It returns the last index position of the
It returns the first index position of the first It returns the last index position of the last
239 4 str1="save paper,save trees" B 1 last occurance of "save" in the given first occurance of "save" in the given
occurance of "save" in the given string str1. occurance of "save" in the given string str1.
str1.find("save") string str1. string str1.
Which of the following will give "Aryan" as output?
240 4 D 1 print(str1[-9:-12]) print(str1[-12:-7]) print(str1[-13:-6]) print(str1[-13:-8])
str1="Vishv,Aryan,Devarsh"
What will following Python code return?
241 4 str1="LJ University" A 1 13 12 11 14
print(len(str1))
What will be the output of the following Python statement?
242 4 B 1 cde cdef bcdef def
"abcdef"[2:8]
What will be the output of the following Python statement?
243 4 D 1 Error Output equivalent to print ‘new\nline’ new line newline
print('new' 'line')
What will be the output of the following Python code?
str1="hello world"
244 4 C 1 hello world dlrow olleh hello world
str1[::-1]

What will be the output of the following Python code?

x = ['ab', 'cd']
245 4 A 1 [‘ab’, ‘cd’] [‘AB’, ‘CD’] [None, None] none of the mentioned
for i in x:
i.upper()
print(x)
What will be the output of the following Python code?

x = 'abcd'
246 4 C 1 abcd 0123 error None of mentioned
for i in range(len(x)):
i.upper()
print (x)
What will be the output of the following Python code?
247 4 A 1 True False None Error
print('abcd1234'.isalnum())
Select the correct output of the following String operations.
str1 = "my isname isisis jameis isis bond"
248 4 C 1 5 7 6 4
sub = "is"
print(str1.count(sub, 5))
What is the output of the following string comparison.
True True False False
249 4 print("John" > "Jhon") B 1
True False True False
print("Emma" < "Emm")
Select the correct output of the following String operations.
250 4 str1 = 'Welcome' D 1 WelcoLJIET Welcome LJIET WelcomeLJIET WelcomLJIET
print (str1[:6] + 'LJIET')
Guess the correct output of the following code?
251 4 str1 = "LJIET" A 1 JIE LJIET T LJIE LJIE JIE LJIET T LJI LJI JIE LJIET T LJIET LJIET JIE LJIET T LJIE LJI
print(str1[1:4], str1[:5], str1[4:], str1[0:-1], str1[:-1])
Which of the following is a Python tuple?
252 4 B 1 [1, 2, 3] (1, 2, 3) {1, 2, 3} {}
Which of the following creates a tuple?
253 4 B 1 tuple1=(5)*2 tuple1=("a","b") tuple1[2]=("a","b") None of the above
What type will be printed when the following code executes?
254 4 aTuple = ("Orange") D 1 list tuple array str
print (type(aTuple))
What will the following code return?
def practice(tup):
a, b, c = tup
255 4 B 1 Orange 30 White ("Orange", 30, "White")
return b
aTuple = "Orange", 30, "White"
practice(aTuple)
Suppose t = (1, 2, 4, 3), which of the following is incorrect?
256 4 B 1 print(t[3]) t[3] = 45 print(max(t)) print(len(t))
What will be the output of the following Python code?
257 4 t=(1,2,4,3) C 1 (1, 2) (1, 2, 4) (2, 4) (2, 4, 3)
t[1:3]
What will be the output of the following Python code?
258 4 t=(1,2,4,3) C 1 (1, 2) (1, 2, 4) (2, 4) (2, 4, 3)
t[1:-1]
What will be the output of the following Python code?
259 4 t = (4,6) A 1 (4,6, 4, 6) [4,6,4,6] (4,4,6,6) [4,4,6,6]
2*t
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following Python code?


tuple1=(2,3,4)
260 4 B 1 (4,6,8) (2,3,4,2,3,4) (2,2,3,3,4,4) Error
tuple3=tuple1*2
print(tuple3)
What will be the output of the following Python code?
t1 = (1, 2, 4, 3)
261 4 B 1 True False Error None
t2 = (1, 2, 3, 4)
t1 < t2
What will be the output of the following Python code?
my_tuple = (1, 2, 3, 4)
262 4 D 1 1 2 5 Error
my_tuple.append( (1,2,3) )
print len(my_tuple)
What is the data type of (1)?
263 4 B 1 Tuple Integer List Both tuple and integer
If a=(1,2,3,4), a[1:-1] is _________
264 4 D 1 Error, tuple slicing doesn’t exist [2,3] (2,3,4) (2,3)
What will be the output of the following Python code?
a=(1,2,(4,5)) Error, < operator is valid for tuples but
265 4 A 1 False True Error, < operator is not valid for tuples
b=(1,2,(3,4)) not if there are sub-tuples
a<b
What will be the output of the following Python code?
266 4 a=("Check")*3 C 1 (‘Check’,’Check’,’Check’) * Operator not valid for tuples ‘CheckCheckCheck’ Syntax error
a
What will be the output of the following Python code?
267 4 a=(2,3,4) C 1 Too many arguments for sum() method The method sum() doesn’t exist for tuples 12 9
sum(a,3)
Is the following Python code valid?
268 4 a=(1,2,3,4) C 1 No because tuple is immutable Yes, first element in the tuple is deleted Yes, the entire tuple is deleted No, invalid syntax for del method
del a
What will be the output of the following Python code?
a=(0,1,2,3,4)
269 4 C 1 Invalid syntax for slicing [0,2] (0,1) (0,2)
b=slice(0,2)
a[b]
Choose the correct option for Tuple.
In Python, a tuple can contain only In Python, a tuple can contain only strings as its In Python, a tuple can contain both integers In Python, a tuple can contain either
270 4 C 1
integers as its elements. elements. and strings as its elements. string or integer but not both at a time.
What will be the output of below Python code?
271 4 tupl=("annie","hena","sid") B 1 ("annie") () None Error as slicing is not possible in tuple.
print(tupl[-3:0])
Which of the following options will not result in an error when performed on tuples in Python where
272 4 C 1 tupl[1]=2 tupl.append(2) tupl1=tupl+tupl tupl.sort()
tupl=(5,2,7,0,3)?
Which of the following options will result in an error when performed on tuples in Python where tupl=(1, 21 , 17,
273 4 D 1 tupl.append(2) tupl.pop(1) tupl.remove(21) All of the mentioned
50, 33)?
What will be the output of below Python code?
tupl=() Error as tuple object has no attribute to
274 4 A 1 0 2 1
tupl1=tupl*2 len
print(len(tupl1))
What will be the output of below Python code?
tupl=([2,3],"abc",0,9) ([2,3],"abc",0,9) ([1,3],"abc",0,9) ([2,1],"abc",0,9)
275 4 C 1 Error
tupl[0][1]=1
print(tupl)
Which of the following two Python codes will give same output?
(i) print(tupl[:-1])
(ii) print(tupl[0:5]) i, ii ii, iv i, iv
276 4 D 1 i, iii
(iii) print(tupl[0:4])
(iv) print(tupl[-4:])
If tupl=(5,3,1,9,0)
Which of the following would complete val = to set val to 20 by slicing aTuple.
277 4 aTuple = ("Orange", (10, 20, 30), (5, 15, 25)) A 1 val = aTuple[1][1] val = aTuple[1:2](1) val = aTuple[2][1] val = aTuple[1:2][1]
val =
What is the output of the following.
(30, 40, 50) (10, 20, 30, 40) (40, 50, 60, (30, 40, 50) (10, 20, 30, 40) (40, 50, 60, 70,
278 4 aTuple = (10, 20, 30, 40, 50, 60, 70, 80) C 1 (30, 40, 50) (10, 20, 30) (40, 50, 60) None of the these
70) 80)
print(aTuple[2:5], aTuple[:4], aTuple[3:])
What will be the output of the following Python code?
t = (1, 2, 4, 3, 8, 9)
279 4 D 1 149 239 124 148
for i in range(0, len(t), 2):
print(t[i],end=" ")
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Find the output of the given Python program


t1 = (1,2)
280 4 t2 = (2,1) A 1 False True Error None
x = (t1 == t2)
print(x)
What will be the output of the following python code?
281 4 str1="Hello World! Hello Hello" B 1 1 2 3 4
str1.count("Hello",12,25)
What is the output of the following code?
a="Hello Welcome to the Python" Value Error -1 1 Syntax Error
281 4 B 1
print(a.find("z")) -1 Value Error Syntax Error 1
print(a.index("z"))
S = "1234567890"
282 4 S = S[-3] + S[2:4] + S[-2:-5] + S[ : -4:-2] + S[1: :2] A 1 80408040 86068606 14701470 None
print(S[ : : 3] * 2)
What will be the output of the following code?
283 4 t1=(1,2,3,4,5,6,7) C 1 1 2 7 4
print(t1[t1[1]+t1[-4]])
What will be the output of the following piece of code?
def check(s):
if len(s) <= 1:
284 4 return True B 1 True False s k
else:
return s[0] == s[-1] and check(s[1:-1])
print(check('saippuakivkauppias'))
What will be the output of below Python code?
t=()
285 4 t1=t*10 A 1 0 1 2 3
print(len(t1))

What will be the output of the following Python code?


def tup(T):
print(T[T.index(5)], end = " ")
286 4 print(T[T[T[6]-3]-6]) C 1 5 Index Error 40 58 Syntax Error
T = (1, 2, 3, 4, 5, 6, 7, 8)
tup(T)

What will be the output of the following Python code?


s="Th*is is$ nothi&&ng b#ut excerc(is)e"
287 4 change=str.maketrans("(",",","@#$%^&*_-)") A 1 Th*is is$ nothi&&ng b#ut excerc(is)e This is nothing but excerc,ise This is nothing but exercise NameError: name ‘str’ not defined
s.translate(change)
print(s)
Which of the following will give "Simon" as output?
288 4 str1="John,Simon,Aryan" A 1 print(str1[-11:-6]) print(str1[-7:-12]) print(str1[-11:-7]) print(str1[-11:-5])

What will be the output of the following program?


s = "ball"
r = ""
289 4 for i in s: D 1 LLB BALL Error LLAB
r = i.upper() + r
print(r)

What will be the output of the following program?

290 4 s = 'I love my INDIA' A 1 AomyDIAIe myINDIA AomyDIIe myINDIA AomyDIAIe myINDI AomyDAIe myINDIA
print(s[-1]+s[3:4]+s[7:9]+s[-3:-1]+s[-1:-3:-1]+s[5:9]+s[10:] )
What is the output of following python code –

291 4 m = (1,[1,2],3,4) C 1 List set tuple dict


m[1][1] = 5
type(m)
When using find(), If str is not present in string then what is returned?
292 4 C 1 0 1 -1 NameError
What is the output for following code:
s="blog"
293 4 C 1 g$o$l$b g$o$l$b$ g$o$l$ glob
for i in range(-1,-len(s),-1):
print(s[i],end="$")
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What is the output for following code:


294 4 B 1 ['A', 'B', 'C', 'D', 'E'] ['A', 'B', 'C#D#E'] ['A#', 'B#', 'C#', 'D#', 'E'] Error
print("A#B#C#D#E".split("#",2))
What is the output for following code:
295 4 for i in range (len("python"),12,2): B 1 python pto yhn pyth
print("python"[i-6],end="")
What will be the output of the following Python code?
x = 'abcd'
296 4 for i in x: A 0.5 abcd 0123 ABCD Error
i.isupper()
print (x)
What will be the output of the following Python code?
297 4 t=(1,2,4,3,6,8,4) C 0.5 (2,4,3,6,8) (2,1) () (4,8)
t[1:-1:-1]
What will be the output of the following Python code?

my_tuple = (1, 2, 3, 4)
298 4 D 0.5 4 7 5 Error
my_tuple.append( (1,2,3) )
print (len(my_tuple))

What will be the output of the following Python code?

def enc(st):
encoded=""
c=1
ld=st[0]
for i in range (1,len(st)):
if ld==st[i]:
c=c+1
299 4 else: B 1 A3B2A1C2A2 3A2B1A2C2A 10 Error
encoded=encoded+str(c)+ld
c=0
ld=st[i]
c=c+1
encoded=encoded+str(c)+ld
return encoded
st="AAABBACCAA"
print(enc(st))

What will be the output of the following Python code?


s="aa"
300 4 A aa a error True
s.strip("a")
print(s)
What will be the output of the following Python code?
s="1234ABCvhghbbv"
301 4 D vvv 1234vhghvvv 1234vhg 1234ABCvhghvvv
v=s.maketrans("abc","vvv")
print(s.translate(v))
What is returned by the following function?
shift=1
n=12345
302 4 B 1 12345 23451 34512 54321
s=str(n)
x=s[shift:]+s[:shift]
print(x)
What will following Python code return?
303 4 str1="LJ’University" A 0.5 13 12 15 2
print(len(str1))
What will be the output of below Python code?
tupl=()
304 4 A 0.5 0 2 1 10
tupl1=tupl*2
print(len(tupl1))
What will be the output of the following program on execution?
A=(5,3,2)
305 4 C 1 6 9 12 3
B=(5,3,2)
print(len(A+B*3))
Write a Python program to check if a string is palindrome or not.
306 4 3
Write a Python program to Find length of a string in python.
307 4 3
Write a Python function to find length of a string in python without using len function.
308 4 3
Write a Python function that accepts a string and calculate the number of uppercase letters and lowercase letters.
309 4 3
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Write a Python program to demonstrate the negative index in a Tuple


310 4 3
Write a program to remove I'th character from string in python.
311 4 3
Write a program to create a string made of first,middle and last character.
312 4 3
Write a program to find all occuences of a sub string in a given string by ignoring the case.
313 4 3
Write a program to calculate the sum and average of the digits present in a string.
314 4 3
Write a program to reverse a given string
315 4 3
Write a Python program to print even length words in a string.
316 4 3
Write a Python program to Uppercase Half String from the given string.
317 4 3
Write a Python program to capitalize the first and last character of each word in a string
318 4 3
Write a program to Create a string made of the middle three characters
319 4 3
Write a program to check if two strings are balanced. For example, strings s1 and s2 are balanced if all the
320 4 3
characters in the s1 are present in s2. The character’s position doesn’t matter.
Write a program to Split a string on hyphens
321 4 3
Write a program to print maximum and minimum elements in given Tuple.
322 4 3
Write a Program to print even numbers from given Tuple.
323 4 3
Write a program to print sum of even numbers and sum of odd numbers from elements given in tuple.
324 4 4
Write a Python program using function to shift the decimal digits n places to the left, wrapping the extra digits around. If
shift > the number of digits of n, then reverse the string.
Note:
Function will take two parameters:
1. The number
2. How much shift user want

Example:
Input: n=12345 shift=1
325 4 Output: Result=23451 3

Input: n=12345 shift=3


Output: Result=45123

Input: n=12345 shift=5


Output: Result=12345

Input: n=12345 shift=6


Output: Result=54321
Write a Python programme that accepts a string and calculate the number of uppercase letters, lowercase letters and
number of digits.
For example,

Input: Hello Pyth@n is 100% easy

326 4 3
Output:

Uppercase letters : 2
Lowercase letters : 14
Digits : 3
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Write a python program to check the validity of a Password.


Primary conditions for password validation:

1. Minimum 8 characters.
2. The alphabet must be between [a-z]
3. At least one alphabet should be of Upper Case [A-Z]
4. At least 1 number or digit between [0-9]
5. At least 1 character from [ _ or @ or $]

Examples:
327 4 Input: Ram@_f1234 3
Output: Valid Password

Input: Rama_fo$ab
Output: Invalid Password
Explanation: Number is missing

Input: Rama#fo9c
Output: Invalid Password
Explanation: Must consist from _ or @ or $

Write a Python program to return another string similar to the input string, but with its case inverted.
For example, input of “Mr. Ed” will result in “mR. eD” as the output string.
328 4 Note: Use of built in swapcase function is prohibited. 3

Dr. Prasad is opening a new world class hospital in a small town designed to be the first preference of the
patients in the city. Hospital has N rooms of two types – with TV and without TV, with daily rates of R1 and R2
respectively.

However, from his experience Dr. Prasad knows that the number of patients is not constant throughout the year,
instead it follows a pattern. The number of patients on any given day of the year is given by the following formula

(6-M)^2 + |D-15| ,
where M is the number of month (1 for jan, 2 for feb …12 for dec) and D is the date (1,2…31).

All patients prefer without TV rooms as they are cheaper, but will opt for with TV rooms only if without TV rooms
are not available. Hospital has a revenue target for the first year of operation. Given this target and the values of
N, R1 and R2 you need to identify the number of TVs the hospital should buy so that it meets the revenue target.
Assume the Hospital opens on 1st Jan and year is a non-leap year.
Constraints

Hospital opens on 1st Jan in an ordinary year


5 <= Number of rooms <= 100
500 <= Room Rates <= 5000
0 <= Target revenue < 90000000
Input Format:
•First line provides an integer N that denotes the number of rooms in the hospital.
•Second line provides the rates of rooms with TV (R1).
•Third line provides the rates of rooms without TV (R2).
•Fourth line provides the revenue target.
Output:
Minimum number of TVs the hospital needs to buy to meet its revenue target. If it cannot achieve its target,
4 9
print the total number of rooms in the hospital.
Test Case
Example-1 :
Input
20
1500
1000
7000000
Output
14
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Explanation
Using the formula, the number of patients on 1st Jan will be 39, on 2nd Jan will be 38 and so on. Considering
there are only twenty rooms and rates of both type of rooms are 1500 and 1000 respectively, we will need 14 TV
sets to get revenue of 7119500. With 13 TV sets Total revenue will be less than 7000000
Example-2 :
Input
10
1000
1500
329 10000000

Output
10
Explanation
In the above example, the target will not be achieved, even by equipping all the rooms with TV. Hence, the
answer is 10 i.e. total number of rooms in the hospital.

Write a Python program to create a Caesar encryption.


Note: In cryptography, a Caesar cipher, also known as Caesar's cipher, the shift cipher, Caesar's code or Caesar
shift, is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in
which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For
example, with a right shift of 3, A would be replaced by D, E would become H, and so on. The method is named
after Julius Caesar, who used it in his private correspondence.

330 4 For Example: 3

Input Text : LJIET ENG


Shift : 3
Cipher: OMLHW HQJ

Write a program to check if two strings are balanced. For example, strings s1 and s2 are balanced if all the
characters in the s1 are present in s2 and length of s1 & s2 should be same. The character’s position doesn’t
matter.

331 4 Example : 4

s1 = hello
s2 = olleh
Balanced
list1 = list() list1 = [] list1 = list([1, 2, 3]) All of the mentioned
332 5 Which of the following commands will create a list? D 1

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

334 5 Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is len(listExample)? A 1 5 4 None Error

335 5 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]
What will be the output of the following Python code?
names1 = ['Amir', 'Bala', 'Chales']
if 'amir' in names1:
336 5 C 1 1 Error 2 None of the mentioned
print(1)
else:
print(2)
What will be the output of the following Python code?
list1 = [1, 2, 3, 4]
337 5 D 1 2 4 5 8
list2 = [5, 6, 7, 8]
print(len(list1 + list2))
Which of the following would give an error?
338 5 D 1 . list1=[] list1=[]*3 list1=[2,8,7] None of the above
Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following is correct syntax for slicing operation?
339 5 D 1 print(list1[0]) print(list1[:2]) print(list1[:-2]) All of the mentioned
Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]?
340 5 C 1 Error None 25 2
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]?


341 5 A 1 [2, 33, 222, 14] Error 25 [25, 14, 222, 33, 2]
What will be the output of the following Python code?
A
342 5 names = ['Amir', 'Bear', 'Charlton', 'Daman'] D 1 Daman Error n
print(names[-1][-1])
Which of the following Python code will give different output from the others? for i in range(0,5): for j in [0,1,2,3,4]: for k in [0,1,2,3,4,5]: for l in range(0,5,1):
343 5 C 1
print(i) print(j) print(k) print(l)
What will be the output of the following Python code?
names1 = ['Amir', 'Bear', 'Charlton', 'Daman']
names2 = names1
names3 = names1[:]
names2[0] = 'Alice'
names3[1] = 'Bob'
344 5 sum = 0 B 1 11 12 21 22
for ls in (names1, names2, names3):
if ls[0] == 'Alice':
sum += 1
if ls[1] == 'Bob':
sum += 10
print(sum)
What will be the output of the following Python code?
names1 = ['Amir', 'Bear', 'Charlton', 'Daman']
names2 = names1
names3 = names1
names2[0] = 'Alice'
names3[1] = 'Bob'
sum = 0
345 5 B 1 12 33 32 20
for ls in (names1, names2, names3):
if ls[0] == 'Alice':
sum += 1
if ls[1] == 'Bob':
sum += 10
print(sum)

What will be the output of the following Python code?


lst=[3,4,6,1,2]
346 5 A 1 [3, 7, 8, 6, 1, 2] Syntax error [3,[7,8],6,1,2] [3,4,6,7,8]
lst[1:2]=[7,8]
print(lst)
What will be the output of below Python code?
347 5 list1=[8,0,9,5] A 1 [5,9,0,8] [8,0,9] [8,0,9,5] [0,9,5]
print(list1[::-1])

348 5 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]

349 5 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)
What will be the output of the following Python code?
numbers = [1, 2, 3, 4]
350 5 B 1 4 5 8 12
numbers.append([5,6,7,8])
print(len(numbers))
What will be the output of the following Python code?
a=[1,2,3]
[1,2,3,4] [1, 2, 3, 4] [1,2,3]
351 5 b=a.append(4) B 1 Syntax error
[1,2,3,4] None [1,2,3,4]
print(a)
print(b)
What is returned by the following function?
def list_transformation():
alist = [4, 2, 8, 6, 5]
Error, you cannot concatenate inside an
352 5 blist = [ ] C 1 [4, 2, 8, 6, 5] [4, 2, 8, 6, 5, 5] [9, 7, 13, 11, 10]
append.
for item in alist:
blist.append(item+5)
return blist
What will the following code print?
def mystery(num_list):
out = []
for num in num_list:
353 5 C 1 [10, 15, 20] [20, 15] [15, 20] [20, 15, 10]
if num > 10:
out.append(num)
return out
print(mystery([5, 10, 15, 20]))

354 5 Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1.count(5)? D 1 0 4 1 2


L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following Python code?


x = [1, 2, 3]
355 5 y = [7, 8, 9] A 1 [1, 2, 3, 7, 8, 9] [1, 2, 3, 7, 9] [7, 8, 9] [1, 2, 3]
x.extend(y)
print(x)
What will be the output of the following Python code?
x = [1, 2, 3]
356 5 y = "789" D 1 [1, 2, 3, 7, 8, 9] [1, 2, 3] ['7', '8', '9'] [1, 2, 3, '7', '8', '9']
x.extend(y)
print(x)
What will be the value of ‘result’ in following Python program?
list1 = [1,2,3,4]
list2 = [2,4,5,6]
list3 = [2,6,7,8]
357 5 A 1 [1, 3, 5, 7, 8] [1, 7, 8] [1, 2, 4, 7, 8] error
result = list()
result.extend(i for i in list1 if i not in (list2+list3) and i not in result)
result.extend(i for i in list2 if i not in (list1+list3) and i not in result)
result.extend(i for i in list3 if i not in (list1+list2) and i not in result)

358 5 Suppose list1 is [3, 4, 5, 20, 5], what is list1.index(5)? D 1 0 1 4 2

359 5 To insert 5 to the third position in list1, we use which command? B 1 list1.insert(3, 5) list1.insert(2, 5) list1.add(3, 5) list1.append(3, 5)
What will be the output of the following Python code?
veggies = ['carrot', 'broccoli', 'potato', 'asparagus'] [‘carrot’, ‘celery’, ‘broccoli’, ‘potato’, [‘carrot’, ‘broccoli’, ‘celery’, ‘potato’, [‘celery’, ‘carrot’, ‘broccoli’, ‘potato’,
360 5 A 1 [‘carrot’, ‘celery’, ‘potato’, ‘asparagus’]
veggies.insert(veggies.index('broccoli'), 'celery') ‘asparagus’] ‘asparagus’] ‘asparagus’]
print(veggies)
What will be the result after the execution of above Python code?
list1=[3,2,5,7,3,6]
361 5 A 1 [3,2,5,3,6] [2,5,7,3,6] [2,5,7,6] [3,2,5,7,3,6]
list1.pop(3)
print(list1)

362 5 To remove string “hello” from list1, we use which command? A 1 list1.remove(“hello”) list1.remove(hello) list1.removeAll(“hello”) list1.removeOne(“hello”)

363 5 Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.reverse()? D 1 [3, 4, 5, 20, 5, 25, 1, 3] [1, 3, 3, 4, 5, 5, 20, 25] [25, 20, 5, 5, 4, 3, 3, 1] [3, 1, 25, 5, 20, 5, 4, 3]
What will be the output of below Python code?
numbers = [1, 3, 4, 2]
364 5 A 1 [1, 2, 3, 4] [1, 3, 4] [1, 2, 3] [2, 3, 4]
numbers.sort()
print(numbers)
What will be the output of below Python code?
decimalnumber = [2.01, 2.00, 3.67, 3.28, 1.68]
365 5 D 1 [1.68, 2, 2.01, 3.28, 3.67] [1.68, 2.0, 2.01, 3, 3] [1, 2, 2, 3, 3] [1.68, 2.0, 2.01, 3.28, 3.67]
decimalnumber.sort()
print(decimalnumber)
What will be the output of below Python code?
words = ["Geeks", "For", "Geeks"]
366 5 C 1 ['Geeks','For', 'Geeks'] ['For', 'Geeks'] ['For', 'Geeks', 'Geeks'] [For, Geeks, Geeks]
words.sort()
print(words)
Tup=[2,3,4,[]]
Tup[-1].extend(range(5,35,5))
Tup[-1].append([10,20])
367 5 B 1 22 44 61 71
Tup[-1][-1].append([100,200])
print(len(Tup)+len(Tup[3])+len(Tup[-1][-1])+Tup[-1][-2])

What will be the output of the following Python code snippet?


368 5 d = {"john":40, "peter":45} A 1 TRUE FALSE NONE ERROR
"john" in d
What will be the output of the following Python code snippet?
d1 = {"john":40, "peter":45}
369 5 B 1 TRUE FALSE NONE ERROR
d2 = {"john":466, "peter":45}
d1 == d2
What will be the output of the following Python code snippet?
370 5 d = {"john":40, "peter":45} A 1 40 45 “john” “peter”
d["john"]
What will be the output of the following Python code?
0 a 0a
371 5 d = {0: 'a', 1: 'b', 2: 'c'} A 1 1 b 1b none of the mentioned
for i in d: 2 c 2c
print(i)

372 5 Suppose d = {“john”:40, “peter”:45}. To obtain the number of entries in dictionary which command do we use? B 1 d.size() len(d) size(d) d.len()
What will be the output of the following Python code snippet?
373 5 d = {"john":40, "peter":45} A 1 [“john”, “peter”] [“john”:40, “peter”:45] (“john”, “peter”) (“john”:40, “peter”:45)
print(list(d.keys()))
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

374 5 Which of the following is not a declaration of the dictionary? C 1 {1: ‘A’, 2: ‘B’} dict([[1,”A”],[2,”B”]]) {1,”A”,2”B”} {}
What will be the output of the following Python code?
An exception is thrown since the dictionary
375 5 a=dict() A 1 ‘‘ 1 0
is empty
a[1]
What will be the output of the following Python code?
a={ }
376 5 a[2]=1 B 1 [2,3,4] 3 2 An exception is thrown
a[1]=[2,3,4]
print(a[1][1])

What will be the output of the following Python code snippet?


numbers = {}
letters = {}
comb = {}
numbers[1] = 56
377 5 D 1 Error, dictionary in a dictionary can’t exist ‘Numbers’: {1: 56, 3: 7} {‘Numbers’: {1: 56}, ‘Letters’: {4: ‘B’}} {‘Numbers’: {1: 56, 3: 7}, ‘Letters’: {4: ‘B’}}
numbers[3] = 7
letters[4] = 'B'
comb['Numbers'] = numbers
comb['Letters'] = letters
print(comb)
Which of the following statements create a dictionary?
378 5 D 1 d = {} d = {“john”:40, “peter”:45} d = {40:”john”, 45:”peter”} All of the mentioned
What will be the output of the following Python code?
a={1:"A",2:"B",3:"C"}
123 ‘A’ ‘B’ ‘C’ 1 ‘A’ 2 ‘B’ 3 ‘C’
379 5 for i in a: A 1 Error, it should be: for i in a.items():
print(i,end=" ")

What will be the output of the following Python code?


text = {1: "geeks", 2: "for"}
380 5 B 1 {1: "geeks", 2: "for"} {} [1: "geeks", 2: "for"] []
text.clear()
print(text)
What will be the output of the following Python code?
a={1:"A",2:"B",3:"C"}
Error, copy() method doesn’t exist for
381 5 b=a.copy() B 1 {1: ‘A’, 2: ‘B’, 3: ‘C’} {1: ‘A’, 2: ‘D’, 3: ‘C’} “None” is printed
dictionaries
b[2]="D"
print(a)
What is the output of the following piece of code?
382 5 a={1:"A",2:"B",3:"C"} B 1 1 A 4 Invalid syntax for get method
print(a.get(1,4))
What is the output of the following piece of code?
383 5 a={1:"A",2:"B",3:"C"} C 1 A 5 4 Invalid syntax for get method
print(a.get(5,4))
What will be the output of the following Python code snippet?
a={1:"A",2:"B",3:"C"}
384 5 A 1 1A2B3C 123 ABC 1:”A” 2:”B” 3:”C”
for i,j in a.items():
print(i,j,end=" ")
What will be the output of the following Python code?
385 5 a={1:"A",2:"B",3:"C"} D 1 Syntax error dict_items([(‘A’), (‘B’), (‘C’)]) dict_items([(1,2,3)]) dict_items([(1, ‘A’), (2, ‘B’), (3, ‘C’)])
a.items()
What will be the output of the following Python code?
Dictionary1 = {'A': 'Geeks', 'B': 'For', 'C': 'Geeks'}
386 5 D 1 keys(['A', 'B', 'C']) (['A', 'B', 'C']) dict_keys([A, B, C]) dict_keys(['A', 'B', 'C'])
print(Dictionary1.keys())

What will be the output of the following Python code?


a={1:"A",2:"B",3:"C"}
387 5 b={4:"D",5:"E"} C 1 {1: ‘A’, 2: ‘B’, 3: ‘C’} Method update() doesn’t exist for dictionaries {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’, 5: ‘E’} {4: ‘D’, 5: ‘E’}
a.update(b)
print(a)
What will be the output of the following Python code?
388 5 dictionary = {"raj": 2, "striver": 3, "vikram": 4} C 1 values([2, 3, 4]) ([2, 3, 4]) dict_values([2, 3, 4]) dict([2, 3, 4])
print(dictionary.values())

389 5 Which of the following is not the correct syntax for creating a set? A 1 set([[1,2],[3,4]]) set([1,2,2,3,4]) set((1,2,3,4)) {1,2,3,4}
{}
390 5 Which of the following statements is used to create an empty set? B 1 set() [] ()
What will be the output of the following Python code?
Error as unsupported operand type for set Error as multiplication creates duplicate
391 5 s={5,6} A 1 {5,6,5,6,5,6} {5,6}
data type elements which isn’t allowed
s*3
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following Python code?


a={5,6,7,8}
392 5 A 1 TRUE FALSE ERROR NONE
b={7,5,6,8}
a==b
What will be the output of the following Python code?
a={4,5,6} Error as the duplicate item 6 is present in
393 5 C 1 {4,5,6,2,8} {4,5,6,2,8,6} Error as unsupported operand type for sets
b={2,8,6} both sets
a+b
What will be the output of the following Python code?
a={4,5,6} Error as unsupported operand type for set data Error as the duplicate item 6 is present in
394 5 A 1 {4,5} {6}
b={2,8,6} type both sets
a-b

395 5 Which of these about a frozenset is not true? A 1 Mutable data type Allows duplicate values Data type with unordered values Immutable data type
What will be the output of the following Python code, if s1= {1, 2, 3}?
396 5 A 1 TRUE Error No output FALSE
s1.issubset(s1)
If we have two sets, s1 and s2, and we want to check if all the elements of s1 are present in s2 or not, we can use the
397 5 B 1 s2.issubset(s1) s2.issuperset(s1) s1.issuperset(s2) s1.isset(s2)
function:
What will be the output of the following Python code?
x = {"apple", "banana", "cherry"}
398 5 y = {"google", "microsoft", "apple"} C 1 { 'microsoft', 'google', 'apple', 'cherry'} {'banana', 'microsoft', 'google', 'apple'} {'banana', 'microsoft', 'google', 'apple', 'cherry'} {'banana', 'microsoft', 'google', 'apple'}
z = x.union(y)
print(z)
What will be the output of the following Python code?
s1 = {1, 2, 3}
399 5 C 1 {2} {1, 2, 3} {2, 3} {3}
s2 = {2, 3}
print(s1.intersection(s2))
What will be the output of the following Python code?
x = {"apple", "banana", "cherry"}
400 5 y = {"google", "microsoft", "apple"} D 1 {"apple", "banana", "cherry"} {"google", "microsoft", "apple"} {"google", "microsoft",} {'banana', 'cherry'}
z = x.difference(y)
print(z)
What will be the output of the following Python code?
x = {"apple", "banana", "cherry"}
401 5 y = {"google", "microsoft", "apple"} B 1 {"apple", "banana", "cherry"} {'google', 'banana', 'microsoft', 'cherry'} {"google", "microsoft",} {'banana', 'cherry'}
z = x.symmetric_difference(y)
print(z)
What will be the output of the following Python code?
fruits = {"apple", "banana", "cherry"}
402 5 C 1 {'google', 'banana', 'microsoft', 'cherry'} {'banana', 'cherry'} {'banana', 'apple', 'cherry'} {"google", "microsoft", "apple"}
x = fruits.copy()
print(x)
What will be the output of the following Python code?
s="Python Programming"
403 5 C 1 17 18 12 14
print(len(set(s)))

What will be the output of the following Python code?


y=6
404 5 A 1 48 14 64 None of the mentioned
z = lambda x: x * y
print(z(8))
What will be the output of the following Python code?
lamb = lambda x: x ** 3
405 5 C 1 15 555 125 None of the mentioned
print(lamb(5))

What will be the output of the following Python code?


def writer():
title = 'Sir'
Arthur Sir Sir Arthur Arthur
406 5 name = (lambda x: title + ' ' + x) B 1 None of the mentioned
return name
who = writer()
print(who('Arthur'))
What will be the output of the following Python code?
407 5 min = (lambda x, y: x if x < y else y) C 1 9997 9999 9996 None of the mentioned
print(min(101*99, 102*98))
What will be the output of the following Python code?

def current_date(**kwargs):
408 5 C 0.5 date:2-1-2023 date=2-1-2023 date 02-01-2023
for i in kwargs:
print(i)
current_date(date=2-1-2023)
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following Python code?


def f1(*m):
sum1=len(m)
for i in m:
409 5 A 1 12 11 13 15
sum1+=i
return sum1
x=f1(1,2,3,(4,)==(4,),(5,)==(5))
print(x)
What will be the output of the following Python code?
def F(B,A=3,*C,**D):
sum=A+B
for i in C:
sum=sum+i
410 5 C 1 10 20 23 21
for i in D.values():
sum=sum+i
return sum
print(F(1,5,7,4,3,e=1,f=2))

Given a list L of size N, You need to count the number of special elements in the given list. An element is special if
removal of that element makes the list balanced.
The list will be balanced if sum of even index elements is equal to the sum of odd index elements.

Example Input
Input 1:
A = [2,1,6,4]
Input 2:
A=[5,5,2,5,8]
Example Output
Output 1:
1
411 5 Output 2: 9
2

Explanation 1 :
After deleting 1 from list : [2,6,4]
(2+4) = (6)
Hence 1 is the only special element, so count is 1.

Explanation 2 :
If we delete A[0] or A[1], list will be balanced
(5+5)=(2+8)
So A[0] and A[1] are special elements, so count is 2.

The Syracuse (also called Collatz or Hailstone) sequence is generated by starting with a natural number and repeatedly
applying the following function until reaching 1:
syr(x) = 1/2 if x is even; and
syr(x) = 3x + 1 if x is odd

For example, the Syracuse sequence starting with 5 is: 5, 16, 8, 4, 2, 1.

Use of inbuilt function or math library is not allowed.


412 5 5
This sequence will always go to 1 for every possible starting value.

Write a program that


1.Gets a starting value from the user
2.Prints the Syracuse sequence for that starting value.

What will be the output of the following Python code?

numberGames = {}
numberGames[(1,2,4)] = 8
numberGames[(4,2,1)] = 10
413 5 numberGames[(1,2)] = 12 C 1 30 24 33 31
sum = 0
for k in numberGames:
sum += numberGames[k]
print (len(numberGames) + sum)
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What is the output of the following code?


414 5 L=[['Physics',101],['Chemistry',202],['Maths',303],45,6,'j'] C 1 3 5 6 4
print(len(L))
What will the below Python code do?

set1={2,3}

set2={3,2}

set3={2,1}

if(set1==set2):

print("yes")
yes
415 5 A 1 no,yes no,no yes,yes
else: no

print("no")

if(set1==set3):

print("yes")

else:

print("no")

What is the output of the following code?


416 5 D={1:"Amit",2:"Suman",3:"Ravi",4:"Anuj"} B 1 Amit Suman Ravi Anuj
print(max(D.values()))

What will be the output of the following Python code?


417 5 L = ['Arnold', 'Bootboggler', 'Christi', 'Dickinson'] A 1 n a Dickinson Arnold
print(L[-1][-1])

What will be the output of the following Python code?


D = {1 : 1, 2 : '2', '1' : 2, '2' : 3}
418 5 D['1'] = 2 D 1 Key Error 1 Syntax Error 3
print(D [D [D [ str(D[1]) ] ] ] )

What will be the output of the following Python code?


L1 = [ ]
L1.append([1, [2, 3], 4])
419 5 B 1 12 11 [11] [12]
L1.extend([7, 8, 9])
print(L1[0][1][1] + L1[2])

What will be the output of the following Python code?


L1 = [1, 1.33, 'LJU', 0, 'N', True, 'Y', 1]
val1= 0
val2= ""
for x in L1:
if(type(x) == int or type(x) == float):
420 5 val1 += x A 1 2.33 LJUN 3.33 LJUNTrueY 3.33 LJU 2.33 LJUNY
elif(type(x) == str):
val2 += x
else:
break
continue
print(val1, val2)

What will be the output of the following Python code?


def sum_list(l):
sum=0
for i in range(len(l)):
if l[i]==13 or l[i-1]==13:
continue
421 5 D 1 40 27 9 11
else:
sum+=l[i]
return sum
l= [1,2,13,2,9,13]
print(sum_list(l))
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following Python code?


L1= [1,1,2,4,5,6,2,3,1,3,5]
L2= [8,2,1,3,8,3,7,2,0]
L=L1+L2
S=list(set(list(L))) [0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 5, 5, 6, 7, 8,
422 5 S.sort() A 1 [0, 1, 2, 3, 4, 5, 6, 7, 8] [1, 1, 2, 4, 5, 6, 2, 3, 1, 3, 5, 8, 2, 1, 3, 8, 3, 7, 2, 0] [8, 7, 6, 5, 4, 3, 2, 1, 0]
8]
S.reverse()
S.sort()
L.reverse()
print(S)

What will be the output of the following program?


tuple = {}
tuple[(1,2,4)] = 8
tuple[(4,2,1)] = 10
tuple[(1,2)] = 12
423 5 C 1 22 30 33 31
_sum = 0
for k in tuple:
_sum += tuple[k]
print(len(tuple) + _sum)

What is the output of the following program?


L = list('123456')
L[0] = L[5] = 0
L[3] = L[-2]
L[5]=1
424 5 L[-2]=4 A 1 [0, '2', 1, '5', '5', '5'] [0, '2', 1, '5', '5', '1'] [1, '2', 1, '5', '5', '5'] [0, '2', 4, '5', '5', '5']
L[2]=L[-1]
L[4]=L[3]
L[-1]=L[3]
print(L)

What will be the output of the following Python code?


l1 = ['A', 'B', 'C', 'D','E']
l2 = l1.copy()
l3 = l1[ : :-1]
l2[4] = 'G'
l3[3] = 'H'
l1[4] = l2[4]
l1[3] = l3[3]
425 5 sum = 0 B 1 150 148 59 118
for i in (l1, l2, l3):
if i[4] == 'G':
sum += 7
if i[3] == 'H':
sum += 22
if i[2] == 'C' :
sum += 30
print(sum)
What is the output of following python code –

426 5 A 1 11 12 13 14
dict = {1: 2, 3:4, 4:11, 5:61, 7:81}
print(dict[dict[3]])
What is the output for following code:
list1=[1,2,3,4]
427 5 D 1 4 8 6 TypeError
list2=[5,6,7,8]
print(len(list1+list2-list1+list2))
What will be the output of the following Python code?
def writer():
title = 'Sir'
name = (lambda x: title + ' ' * 2x)
428 5 A 0.5 Error Sir Arthur Sir Arthur ArthurSir ArthurSirArthurSir
return name
who = writer()
print(who('Arthur'))

Following Lambda function series can be used to find __________.


from functools import *
429 5 B 1 sum of first two numbers in a list Fibonacci Series The geometric series Syntax error
Series = lambda n: reduce(lambda x, _: x + [x[-1] + x[-2]], range (n-2) , [0,1])
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following Python code?


names1 = ['A', 'B', 'C', 'D']
names2 = names1
names3 = names1[:]
names2[0] = 'Aa'
names3[1] = 'BB'
430 5 sum = 0 A 1 24 11 12 13
for s in (names1, names2, names3):
if s[0] == 'Aa':
sum += 2
if s[1] == 'BB':
sum += 20
print(sum)

What will be the output of the following Python code?


431 5 l=[[["hello","0hel"],"bh"],"nm"] B 1 [['hello', '0hel']] [['hello', '0hel'], bh'] [['hello’] index error
print(l[0])
What will be the output of the following Python code?
nums = [3, 5, 16, 27]
432 5 D 1 [5,16,27] [3,5,16] [3,5,27] [5,16]
some_nums = list(filter(lambda num: 5 <= num < 27, nums))
print(some_nums)
What will be the output of the following Python code?
x={1,2,3,4,5}
433 5 y={3,4,5,6,7} B 1 {1, 2, 3, 4, 5, 6, 7} {1, 2, 3, 4, 5, 7} {1, 3, 5, 7, 9} {1, 2, 3, 5, 6, 7, 9}
z={1,3,5,7,9}
print( (x|y) & (x|z))

What will be the output of the following Python code?

434 5 l=[1,2,3,5,7,8,9,10] A 0.5 7 8 10 5


m=max(l)
print(l.index(m))
What will be the output of the following Python code?
x = ['ab', 'cd']
435 5 for i in x: A 0.5 [‘ab’, ‘cd’] [‘AB’, ‘CD’] [None, None] ERROR
i.upper()
print(x)
What will be the output of the following Python code?
def f(l):
l.append([1,2,3])
return
436 5 A 1 [1,2,3] [1,2,3,[1,2,3]] [1,3,2] [1,3,2] [1,2,3] [1,2,3,1,2,3] ERROR
l=[1,2,3]
print(l,end=" ")
f(l)
print(l)
What will be the output of the following Python code?
437 5 d={1:"welcome",[1]:{1:2}} A 1 ERROR 1 2 [1]
print(d[[1]])
What will be the output of the following Python code?
438 5 l=[1,2,[[1,2,[1,2],1,2]]] A 1 [1, 2, [1, 2], 1, 2] [1,2] [1,2,1,2] 2
print(l[2][0])
What will be the output of the following Python code?
l=[1,"m",["a",{1:[1,2,3]}]]
439 5 t={(1,2,3):(5)} A 1 ([1, 2, 3], 5) a5 10 7
s=(l[2][1][1],t[(1,2,3)])
print(s)
What will be the output of the following Python code?
l=[1,2,(5)]
440 5 A 1 [1,2,7] [1,2,5] [1,2,(5)] TYPE ERROR
l[2]=7
print(l)
What will be the output of the following program on execution?
def f(*l):
for i in l[0]:
sum=0
441 5 A 1 3 error 2 6
sum+=i
print(sum)
f([1,2,3])

Write a python code to demonstrate any three methods of list


442 5 4

Write a python code to explain map in Python program.


443 5 3
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Write a python code to explain filter in Python program.


444 5 4

Write a Python program to print the even numbers from a given list.
445 5 4

Write a Python Program to print the largest even number in a list.


446 5 4

Write a Python Program to print the largest odd number in a list.


447 5 4

Write a Python program to swap first and last element of the list.
448 5 4

Write a Python program to find the sum of all the elements in the list.
449 5 4

Write a Python function to sum all the numbers in a list


450 5 4

Write a Python program of Reversing a List.


451 5 3

Write a Python program to Merging two Dictionaries


452 5 4

Write a Python program to calculate the sum of the positive and negative numbers of a given list of numbers using lambda
453 5 4
function.
Write a Python program to rearrange positive and negative numbers in a given array using Lambda.
454 5 4

Write a Python program to find numbers divisible by nineteen or thirteen from a list of numbers using Lambda.
455 5 4

Write a Python function to implement linear search algorithm.


Linear search is also called as sequential search algorithm. It is the simplest searching algorithm. In Linear search, we
simply traverse the list completely and match each element of the list with the item whose location is to be found. If the
match is found, then the location of the item is returned; otherwise, the algorithm returns NULL.
The following is linear search algorithm:
Given a list L of n elements with values or records L0 .... Ln−1, and target value T, the following subroutine uses linear
search to find the index of the target T in L.

1. Set i to 0.
2. If Li = T, the search terminates successfully; return i.
3. Increase i by 1.
456 5 3
4. If i < n, go to step 2. Otherwise, the search terminates unsuccessfully.

Input:
Enter the list of numbers: 5 4 3 2 1 10 11 2
The number to search for: 1

Output:
1 was found at index 4.
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Given a list of elements, write a python program to perform grouping of similar elements, as different key-value list in
dictionary. Print the dictionary sorted in descending order of frequency of the elements.
Note: To perform the sorting, use the sorted function by converting the dictionary into a list of tuples. After sorting,
convert the list of tuples back into a dictionary and print it.
Input : test_list = [4, 6, 6, 4, 2, 2, 4, 8, 5, 8]
Output : {4: [4, 4, 4], 6: [6, 6], 2: [2, 2], 8: [8, 8], 5: [5]}
Explanation : Similar items grouped together on occurrences.

Input : test_list = [7, 7, 7, 7]


Output : {7 : [7, 7, 7, 7]}
Explanation : Similar items grouped together on occurrences.

457 5 3

A digital image in a computer is represented by a pixels matrix. Each image processing operation in a computer may be
observed as an operation on the image matrix. Suppose you are given an N x N 2D matrix A (in the form of a list)
representing an image. Write a Python program to rotate this image by 90 degrees (clockwise) by rotating the matrix 90
degree clockwise. Write proper code to take input of N from the user and then to take input of an N x N matrix from the
user. Rotate the matrix by 90 degree clockwise and then print the rotated matrix.
Note: You are not allowed to use an extra iterable like list, tuple, etc. to do this. You need to make changes in the given list
A itself. Your program should be able to handle any N x N matrix from N = 1 to N = 20.

458 5 9

Write a Program to Print Longest Common Prefix from a given list of strings. The longest common prefix for list of strings is
the common prefix (starting of string) between all strings. For example, in the given list [“apple”, “ape”, “zebra”], there is
no common prefix because the 2 most dissimilar strings of the list “ape” and “zebra” do not share any starting characters.
If there is no common prefix between all strings in the list than return -1.

For example,
Input list: ["lessonplan", "lesson","lees", "length"]
459 5 The longest Common Prefix is: le 3

Input list: ["python","pythonprogramming","pythonlist"]


The longest Common Prefix is: python

Input list: ["lessonplan", "lesson","ees", "length"]


The longest Common Prefix is: -1

One of the ways to encrypt a string is by rearranging its characters by certain rules, they are broken up by threes, fours or
something larger. For instance, in the case of threes, the string ‘secret message’ would be broken into three groups. The
first group is sr sg, the characters at indices 0, 3, 6, 9 and 12. The second group is eemse, the characters at indices 1, 4, 7,
10, and 13. The last group is ctea, the characters at indices 2, 5, 8, and 11. The encrypted message is sr sgeemsectea.
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

If the string ‘secret message’ would be broken into four groups. The first group is seeg, the characters at indices 0, 4, 8 and
12. The second group is etse, the characters at indices 1, 5, 9 and 13. The third group is c s, the characters at indices 2, 6
and 10. The fourth group is rma, the characters at indices 3, 7 and 11. The encrypted message is seegetsec srma.

(A). Write a program that asks the user for a string, and an integer determining whether to break things up by threes,
fours, or whatever user inputs. Encrypt the string using above method.

For example,
Input message: This is python, a programming language
Input Key: 4
Output Encrypted Message: T poaomgnghiyn gm geist,prilus h ranaa

Input message: This is python, a programming language


Input Key: 7
Output Message: T ,ggahp r giyaalest ma hpmniorigsnonu

(B). If you get a message which is encoded by the method above then, Write a decryption program for the general case.
Taking input of any encrypted string from user with key number used while breaking message apart during encryption.

For example,
Input Encrypted message: Hloe gl o sogrilw g epntstfii o yotay hee nnh aoiortiimreegehrun nhnse ne
Input Key used during encryption: 5
Output Decrypted Message: Hi hello how are you going to learn python in this semester of engineering

Input Encrypted message: Ig ntot oopid ys lt dehaaao yrn


Input Key used during encryption: 8
Output Decrypted Message: It is a good day to learn python

469 5 9
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

(C). From the output string (Output Decrypted Message) of above program (Part-B), create a Dictionary with Key as First
Character and Value as list of words Starting with that Character from above string. And print that dictionary by sorting it
based on the number of elements in a list of values in descending order.

Note: Consider capital and lower first character of words as same character in this program. For ex. ‘Hi’ and ‘hello’ both will
be considered starting from ‘h’.

For example,
Enter Decrypted Message: Hi hello how are you going to learn python in this semester of engineering
Output: {'h': ['Hi', 'hello', 'how'], 't': ['to', 'this'], 'a': ['are'], 'y': ['you'], 'g': ['going'], 'l': ['learn'], 'p': ['python'], 'i': ['in'], 's':
['semester'], 'o': ['of'], 'e': ['engineering']}

Enter Decrypted Message: It is a good day to learn python


Output: {'i': ['It', 'is'], 'a': ['a'], 'g': ['good'], 'd': ['day'], 't': ['to'], 'l': ['learn'], 'p': ['python']}

Enter Decrypted Message: it is not the time to play games!


Output: {'t': ['the', 'time', 'to'], 'i': ['it', 'is'], 'n': ['not'], 'p': ['play'], 'g': ['games!']}
Write a python program to print all possible combinations from the three Digits and also count unique values inside a list
and also find list product excluding duplicates and also find sum of list’s elements excluding duplicates.

Examples:

To print all possible combinations


Input: [1, 2, 3]
Output:
123
132
213
231
312
321

Count unique values inside a list

input = [1, 2, 3]
No of unique items are: 3

input = [1, 2, 2]
461 5 No of unique items are: 2 9

input = [2, 2, 2]
No of unique items are: 3

List product excluding duplicates

Input: [2, 3, 5]
Duplication removal list product: 30

Input: [2, 2, 3]
Duplication removal list product: 6

Sum of list’s elements excluding duplicates

Input: [1, 3, 5]
Output: 9

Input: [1, 2, 2]
Output: 3
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

•Use appropriate comment lines to divide subprograms.


•Also demonstrate the program with one example test case. (Example test input and output are given)

PART - A

program must print the output as shown below -


Input – [1,2,3,4]
Output – (‘1’,’2’,’3’,’4’)

PART - B

the program must print the output as shown below -


Input – [1,2,3,4]
Output – [10,20,30,40]

PART - C

given input, the program must print the output as shown below -
Input – [1,2,3,4]
Output – 24 (which is 1*2*3*4)
462 5 5

PART - D
Write a Python program satisfying following conditions -

For the given input, the program must print the output as shown below -

Given input string – ‘hello’


countchar(‘l’)
Output : 2

inbuilt functions. It should return -1 if it does not find the character. For the given input, the program must print the
output as shown below -

Given input string – ‘helloe’


findchar(‘e’)
Output : 1
findchar(‘z’)
Output : -1
Write a Python program to calculate the sum of the positive and negative numbers of the below given list of numbers using
lambda function.

463 5 Input : m = [2, 4, -6, -9, 11, -12, 14, -5, 17] 4

Output : Sum of the positive numbers: -32


Sum of the negative numbers: 48
Create a python program which takes password as input and a function which checks whether the given password is valid
or not under following conditions without using the RegEx module in Python language.

464 5 Conditions required for a valid password: 2

1.Password strength should be at least 8 characters long


2.Password should contain at least one uppercase and one lowercase character.
3.Password must have at least one number.
Write a python program with user defined function that reads the words from paragraph and stores them as keys in a
dictionary and count the frequency of it as a value .

For Example:
465 5 3
Input string: “Dog the quick brown fox jumps over the lazy dog”

Output: {'the': 2, 'jumps': 1, 'brown': 1, 'lazy': 1, 'fox': 1, 'over': 1, 'quick': 1, 'dog': 2}


L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Write a python Program to check entered password by user is correct or not. Entered password is correct if it has upper
character, lower character , digits (but not more than 3 digits) ,special character and length is greater than or equal to
eight and less than equal to fifteen. Get the digits from entered password and convert it in to number and then convert it
in to English Word .

Example:
case 1
pw= R@m@3fa1tu9e$
Valid Password
num= 319
466 5 three hundred and nineteen 9

case 2
pw= S@m@6a1tue$
Valid Password
num= 61
sixty-one

case 3
pw= S@m@6a26u8$
Invalid Password
Write a Python Program using function to count number of strings where the string length is 3 or more and the first and
last character are same from a given list of string.

467 5 Example : 2

Input: ['abc','xyz','aba','2112','123451','12345']
Output: 3
Given a list L of size N. You need to count the number of special elements in the given list. An element is special if removal
of that element makes the list balanced. The list will be balanced if sum of even index elements is equal to the sum of odd
elements. Also print the updated lists after removal of special elements.
Example 1:
Input:
L=[5, 5, 2, 5, 8]
468 5 9
Output:
Original List: [5, 5, 2, 5, 8]
Index to be removed is: 0
List after removing index 0 : [5, 2, 5, 8]

Original List: [5, 5, 2, 5, 8]

Write Python Program to create a dictionary with the key as the first character and value as a list of words starting with
that character.
Example:
469 5 Input: Don’t wait for your feelings to change to take the action. Take the action and your feelings will change 3
Output:
{'D': ['Don’t'], 'w': ['wait', 'will'], 'f': ['for', 'feelings', 'feelings'], 'y': ['your', 'your'], 't': ['to', 'to', 'take', 'the', 'the'], 'c':
['change', 'change'], 'a': ['action.', 'action', 'and'], 'T': ['Take']}
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

d={"student0":'Student@0',"student1":'Student@11',"student2":'Student@121',
"student3":'Student@052',"student4":'Student@01278',"student5":'Student@0125', Student6":'Student@042',
"student7":'Student@07800',"student8":'Student@012'}
Write a python program to update the password of any user given the above dictionary(d) which stores the username as
the key of the dictionary and the username's password as the value of the dictionary. print the updated dictionary and
print the username and password according to ascending order of password length of the updated dictionary.
For the password updating of that username follow some instructions.

and password then display “enter correct password and username”. if the user does not enter the correct username and
password in a given three chances then display “enter correct password and username” and “try after 24h”

new password to update the password of that username. If the user enters a new password not follow the below format,
then display “follow the password format”. if the user does not enter the password in a given format in a given three
chances, then display “follow the password format” and “try after 24h”
470 5 9
The check, of whether the new password format is correct or wrong makes the user define a function. That user define a
function to return True or False for password valid or not. That user define function return value used in this program for
new password validation.
oNew password must have the below format:
1. at least 1 number between 0 and 9
2. at least 1 upper letter (between a and z)
3. at least 1 lower letter (between A and Z)
4. at least 1 special character out of @$_
5. minimum length of the password is 8 and the maximum length is 15
6. Do not use space and other special characters. Only uses @$_

If the new password follows the format of the password in a given three chances. then print the updated dictionary and
print the username and password according to ascending order of password length of an updated dictionary. If the
dictionary is not updated then take the old dictionary

Write a Python code which will return the sum of the numbers of the list.
Return 0 for an empty list.
Except the number 13 is very unlucky, so it does not count and number that come immediately after 13 also do not count
in sum.

Example :
471 5 4
[1, 2, 3, 4] = 10
[] = 0
[1, 2, 3, 4, 13] = 10
[13, 1, 2, 3, 13] = 5
[1, 13, 2, 3, 4] = 8

Write a Python program which takes a list and returns a list with the elements "shifted left by number of positions entered
by user".
Example:
Input:
472 5 3
List: [1, 2, 3, 4, 5]
Shift: 2
Output:
[3, 4, 5, 1, 2]
The contents of names.txt is listed here:
Moana
Cinderella
Tiana
Which of the following code blocks will print all of the names in names.txt?
I. names = open("names.txt", "r")
for line in names:
473 6 B 1 I II III I & III both
print(names)
II. names = open("names.txt", "r")
for line in names:
print(line)
III. names = open("names.txt", "r")
for line in names:
print("line")
How many errors are in the code below? It should open the file in read-only mode, read each line and print each line and
then close the file.
def print_contents(file)
474 6 D 1 1 2 3 4
file_obj = open(file)
for line in "file_obj":
print(line_obj)
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

File is created if does not exist. If the file exists, file is truncated( past data is lost). Both reading and writing operation can
475 6 C 1 ’r’ ’w’ ’w+’ ’a+’
take place. What is the text file mode?
476 6 From following which statement reads some bytes from the file and returns it as a string? B 1 readlines() read() readline() readpara()
477 6 From following which statement reads all the lines from the file and returns in the form of list? A 1 readlines() read() readline() readpara()
478 6 From following which statement write a string in file? A 1 write() writeline() writelines() writepara()
479 6 From following which statement writes a list in a file? C 1 write() writeline() writelines() writepara()
What happens if no arguments are passed to the seek function?
480 6 D 1 file position is set to the start of file file position is set to the end of file file position remains unchanged error
How many functions are used in the given code below:?
fileobject=open('F1.txt','r')
str=fileobject.readline()
481 6 while str: D 1 1 2 3 5
print(str)
str=fileobject.readline()
fileobject.close()
How many errors are in the code below? It should open the file in read-only mode,
read each line and print each line and then close the file.
def print_contents(file):
482 6 D 1 0 1 2 3
file_obj = open(file)
for line in "file_obj":
print(line_obj)
Select all true statements when a file is opened using the with statement.

I. The with statement simplifies exception handling


483 6 II. The file is automatically closed after leaving the block, and all the resources that are C 1 only I only II both I and II None of these
tied up with the file are released.
III. File reading and writing are faster using the with statement.

To read 5th line from text file, which of the following statement is true? dt=f.readline(4) dt=f.readlines() dt=f.read(5) dt=f.read(4)
484 6 B 1
print(dt[4]) print(dt[4]) print(dt[3]) print(dt[5])
What will be the output of the following code snippet?
with open("hello.txt", "w") as f:
f.write("Hello World how are you today")

with open('hello.txt', 'r') as f:


485 6 data = f.readlines() A 1 [‘Hello’, ‘World’, ‘how’, ‘are’, ‘you’, ‘today’] Hello World how are you today Hello Error
for line in data:
words = line.split()
print (words)
f.close()

Suppose content of ‘Myfile.txt’ is


Humpty Dumpty sat on a wall
Humpty Dumpty had a great fall
All the king’s horses and all the king’s men
Couldn’t put Humpty together again
486 6 D 1 25 26 27 Error
What will be the output of the following code?
myfile = open(“Myfile.txt”)
record = myfile.readlines().split()
print(len(record))
myfile.close()
What is printed after executing this pythod code?
f=open("abc.txt","w")
x=[1,2,3]
487 6 D 1 “1,2,3” 1,2,3 1 Error
f.writelines(x)
f.close()
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Use the following file to predict the output of the following code:
test.txt content:
aaa
bbb
ccc
ddd
eee
488 6 fff A 1 aaa bbb ccc aaa bbb ccc
ggg

Code:
f=open("test.txt","r")
print(f.readline(3))

Write a function cust_data() to ask user to enter their names and age to store data in customer.txt file.
489 6 4
Write a python program to create and read the city.txt file in one go and print the contents on the output screen.
490 6 4
Write a function count_lines() to count and display the total number of lines from the file. Consider the following lines for
the file – friends.txt.
Friends are crazy, Friends are naughty !
491 6 4
Friends are honest, Friends are best !
Friends are like keygen, friends are like license key !
We are nothing without friends, Life is not possible without friends !
Write a function display_oddLines() to display odd number lines from the text file. Consider the following lines for the file –
friends.txt.
Friends are crazy, Friends are naughty !
492 6 4
Friends are honest, Friends are best !
Friends are like keygen, friends are like license key !
We are nothing without friends, Life is not possible without friends !
Write a Python program to read a text file and do following: 1. Print no. of words 2. Print no. statements
493 6 4
Write a python program that reads a text file and changes the file by capitalizing each character of file.
494 6 3
Write a Python program to copy the contents of a file to another file.
495 6 7
Write a python program to read line by line from a given files file1 & file2 and write into file3.
496 6 4
Write python program to count the number of lines in a file.
497 6 7
Write a python program to search for a string in text files.
498 6 7
Write a “pager” program. Your solution should prompt for a filename, and display the text file 25 lines at a time, pausing
499 6 each time to ask the user to enter the word “continue”, in order to show the next 25 lines or enter the word “stop” to close 4
the file.
Using a file which consists of multiple statements, find all the words from the file that can be made from all the characters
of given user’s string.

Note: If user enters same characters multiple times in a string, then word from file will only be eligible for output if it
contains that character for same or more number of times in it. (if file have apple, greenapple and user’s string is ‘aepe’
then output will only be greenapple. apple is not eligible as it contains e for 1 time only.

For example:
If a given file is:
500 6 4

String entered by user: nas


Output words will be: oranges, bananas, vitamins

String entered by user: isi


Output words will be: vitamins

String entered by user: eee


Output words will be: greenapple
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Write a Python program to reverse the content of a one file and store it in second file and also convert content of second
file into uppercase and store it in third file and also count number of Vowels in third file and also print only 2nd line from
the content of third file.

Examples:
If data file one contains the following data:
Friends are crazy, Friends are naughty !
Friends are honest, Friends are best !

Output 1:
! tseb era sdneirF ,tsenoh era sdneirF
501 6 4
! ythguan era sdneirF ,yzarc era sdneirF

Output 2:
! TSEB ERA SDNEIRF ,TSENOH ERA SDNEIRF
! YTHGUAN ERA SDNEIRF ,YZARC ERA SDNEIRF

Output 3:
Vowels = 22

Output 4:
! YTHGUAN ERA SDNEIRF ,YZARC ERA SDNEIRF
Write a python program to extract a list of all four-letter words that start and end with the same letter from a given text
502 6 4
file.
Write a python program to read a text file “Story.txt” and print only word starting with ‘I’ in reverse order.
503 6 Example: If value in text file is : ‘INDIA IS MY COUNTRY’ 2
Output will be: ‘AIDNI SI MY COUNTRY’
Write a Python program to count words, characters and spaces from text file.

Input:

Python is a Easy Subject


OOPs is One of the most
interesting Topic
504 6 3
Output:

No of space: 10
No of word: 13
No of character: 64

File Filtering. write all lines of a file1, except those that start with a pound sign ( # ), the comment character for Python to
file2. And display data of file2.

Text file1 content:

Friends are crazy, Friends are naughty !


#Friends are honest, Friends are best !
505 6 Friends are like keygen, #friends are like license key ! 3
We are nothing without friends, Life is not possible without friends !

Text file2 shoud be:

Friends are crazy, Friends are naughty !


Friends are like keygen,
We are nothing without friends, Life is not possible without friends !
Write a python program to accept string/sentence from user till the user enters “END”. Each string/sentence entered by
user should be a newline in file. Save all the lines in file and display only those lines which begin with capital letter.

Example:
Enter Something (for quit enter END):Hi Friends
Enter Something (for quit enter END):how are you all
506 6 Enter Something (for quit enter END):I am fine 4
Enter Something (for quit enter END):hope you all are fine
Enter Something (for quit enter END):END
The Line started with Capital Letters:
Hi Friends
I am fine
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Write a program to compare two text files. If they are different, give the line and column numbers in the files where the
first difference occurs.
Example:
File 1: python1.txt
Friends are crazy, Friends are naughty !
Friends are honest, Friends are best !
Friends are like keygen, friends are like license key !
new We are nothing without friends, Life is not possible without friends !
507 6 4
File 2: python2.txt
Friends are crazy, Friends are naughty !
Friends 6re honest, Friends are best !
Friends are like keygen, friends are like license key !
new We are nothing without friends, Life is not possible without friends !
Output:
line number 2 colNo. 9

Write a Python program to count the frequency of words in a file


Example:
File 1: python1.txt
Friends are crazy, Friends are naughty !
Friends are honest, Friends are best !
508 6 2
Friends are like keygen, friends are like license key !
new We are nothing without friends, Life is not possible without friends !
Output:
Friends - 5,are - 7,crazy, - 1,naughty - 1,! - 4,honest, - 1,best - 1,like - 2,keygen, - 1,friends - 2,license - 1,key - 1,new - 1,We -
1,nothing - 1,without - 2,friends, - 1,Life - 1,is - 1,not - 1,possible - 1,
509 7 To use a module in another module, you must import it using an ________ statement A 1 import include 1 AND 2 NONE OF THESE
510 7 Which statement is correct to import all modules from the package B 1 from package import all from package import * from package include all from package include *
511 7 A Python module is a file with the _____ file extension that contains valid Python code. D 1 .pym .pymodule .module .py
512 7 Which of the following returns a string that represents the present working directory? A 1 os.getcwd() os.cwd() os.getpwd() os.pwd()
513 7 Which of the following can be used to create a directory? A 1 os.mkdir() os.creat_dir() os.create_dir() os.make_dir()
514 7 Which of the following can be used to remove a directory? A 1 os.rmdir() os.rem_dir() os.create_dir() os.make_dir()
515 7 __________is used to get the list of all files and directories in the specified directory. C 1 os.rmdir() os.chdir() os.listdir() os.make_dir()
516 7 _______method in Python used to change the current working directory to specified path B 1 os.rmdir() os.chdir() os.listdir() os.make_dir()
517 7 How do you delete a file? C 1 del(fp) fp.delete() os.remove(‘file’) os.delete(‘file’)
if mymod.py file has this code
A=100
def add(a,b):
print("The Sum:",a+b)
def product(a,b): 888
888
518 7 print("The Product:",a*b) and if we import that module as follow then what will be output? C 1 The Sum: 30 error none
The Sum: 30
from mymod import * The Product: 200
print(X)
add(10,20)
product(10,20)

if mymod.py file has this code


A=100
def add(a,b):
print("The Sum:",a+b)
def product(a,b): 100
100
519 7 print("The Product:",a*b) and if we import that module as follow then what will be output? B 1 The Sum: 30 error none
The Sum: 30
from mymod import * The Product: 200
print(A)
add(10,20)
product(10,20)

print(os.listdir("C:\.... file name")) what will be output? get the list of all files and directories in the
520 7 D 1 give error give name of removed file change directory
specified directory.
A .py file containing constants/variables, classes, functions etc. related to a particular task and can be used in other
521 7 A 1 module library classes documentation
programs is called
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

#mod1.py
def change(a):
b=[x*2 for x in a]
print(b)

#mod2.py
def change(a):
522 7 b=[x*x for x in a] C 1 [2,4,6] [2,4,6] [1,4,9] [1, 4, 9] [1, 2, 3]
print(b)

from mod1 import change


from mod2 import change
#main
s=[1,2,3]
change(s)
if calc.py file has this code
def sum(a,b):
print(a+b)
def sub(a,b):
print(a-b)
def mul(a,b):
print(a*b)
15 243 125
def div(a,b):
523 7 C 1 12 12 12 Error
print(a/b)
def power(a,b):
print(a**b)
and if we import that module as follow then what will be output?
import calc
calc.power(5,3)
calc.sum(5,7)

Write a python program to make a module which contain all the basic functions related to string and import that module
524 7 5
in another file and use that fuctions with string given by user.
Write a python program to create a directory and subdirectory. It should print the current working directory path
525 7 2
and list of names of files present in the given directory.
Write a python program to make a module named cal.py which contain all the basic functions related to calculator like
526 7 addition, subtraction, multiplication, and division import that module in another file and use that functions with number 3
inputs given by user.
Write a program to create a module ‘first_word.py’, which returns the first word of any string passed. Show the working of
the module, by calling the module with any suitable example.
527 7 2
Input: ‘This is Python Programming’
Output: ‘This’
Write a python program to copy content of File1 into File2 in which all lines of a file1 or remaining portion of line except
those that have hash sign (#) (means comments).

Input:

# Hello LJ
Wish you happy Republic #Day
Happy 74th Republic Day
What a #Parade at Kartavya Path
528 7 3
Very Happy after watching that parade

Output:

Wish you happy Republic


Happy 74th Republic Day
What a
Very Happy after watching that parade

529 8 Which is not a feature of OOP in general definitions? D 1 Efficient Code Code reusability Modularity Duplicate data
_____ represents an entity in the real world with its identity and behaviour.
530 8 B 1 A method An object A class An operator
What will be the output of the following Python code?
class test:
def __init__(self,a="Hello World"):
self.a=a
The program has an error because The program has an error display function
531 8 C 1 Nothing is displayed “Hello World” is displayed
constructor can’t have default arguments doesn’t have parameters
def display(self):
print(self.a)
obj=test()
obj.display()
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following Python code?


class test:
def __init__(self,a):
self.a=a
Error as one argument is required while Error as display function requires additional
532 8 C 1 Runs normally, doesn’t display anything Displays 0, which is the automatic default value
creating the object argument
def display(self):
print(self.a)
obj=test()
obj.display()
What is Instantiation in terms of OOP terminology?
533 8 D 1 Deleting an instance of class Modifying an instance of class Copying an instance of class Creating an instance of class
Which of the following Python code creates an empty class? class A: class A:
534 8 B 1 class A: It is not possible to create an empty class
return pass
Which of the following is False with respect Python code?
class Student:
def __init__(self,id,age): "std" is the reference variable for object
535 8 C 1 id and age are called the parameters Every class must have a constructor None of the above
self.id=id Student(1,20)
self.age=age
std=Student(1,20)
What will be the output of below Python code?
class Student:
def __init__(self,name,id):
self.name=name
1 1 2 2
536 8 self.id=id B 1
1 2 1 2
print(self.id)
std=Student("Simon",1)
std.id=2
print(std.id)
What will be the output of below Python code?
class A():
def __init__(self,count=100):
self.count=count
100 100 102
537 8 B 1 Error
100 102 102
obj1=A()
obj2=A(102)
print(obj1.count)
print(obj2.count)
Which of the following is correct?
class A:
def __init__(self):
538 8 self.count=5 D 1 5 6 0 Error
self.count=count+1
a=A()
print(a.count)
What will be the output of below Python code?
class A:
def __init__(self,num):
num=3
self.num=num
5 5 3 3
539 8 def change(self): D 1
5 7 3 7
self.num=7
a=A(5)
print(a.num)
a.change()
print(a.num)
What will be the output of the following code?
class Point:

def __init__(self):
p <__main__.Point object> (0,0)
self.x = 0 q <__main__.Point object> (0,0)
540 8 B 1 Nothing seems to have happened with the points
self.y = 0 Nothing seems to have happened with the Nothing seems to have happened with the Nothing seems to have happened with the
points points points
p = Point()
q = Point()

print("Nothing seems to have happened with the points")


L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following snippet? class


Point:

def __init__(self):

self.x = 0
self.y = 0 <__main__.Point object> <__main__.Point object> (0,0)
541 8 C 1 <__main__.Point object> FALSE <__main__.Point object> (0,0)
p = Point() True False False
q = Point()

print(p)
print(q)

print(p is q)
Will this program will print last statement?
try:
items = ['a', 'b']
third = items[1]
This won't print
print("This won't print") got an error This won't print
542 8 C 1 got an error continuing
except Exception: continuing continuing
continuing
print("got an error")

print("continuing")

What will be the output of this following snippet?


try:
items = ['a', 'b']
third = items[2]
print("This won't print") This won't print got an error
got an error
543 8 except Exception as e: C 1 got an error list index out of range continuing
continuing
print("got an error") continuing continuing
print(e)

print("continuing")

Sanjeev has written a program for the file which already exists to read the content from the file. Indicate the line number if
error exists in the given below code:
a=False #Line 1
while not a: #Line 2
544 8 try: #Line 3 A 1 No error Line 1 Line 2 Line 3
f_n = input("Enter file name") #Line 4
i_f = open(f_n, 'r') #Line 5
except: #Line 6
print("Input file not found") #Line 7
What will be output of the following code?
A=25
B=40
try:
L=[]
for i in range(2):
L.append(A)
print(L[3])
L.append(C)
545 8 D 1 Write properly Not in range Both A&B SyntaxError
iff len(L)<5:
print(L)
C=34
except IndexError:
print("Not in range")
except NameError:
print("Not defined")
except SyntaxError:
print("Write properly")
How many except statements can a try-except block have?
546 8 D 1 zero one more than one more than zero
When will the else part of try-except-else be executed?
547 8 C 1 always when an exception occurs when no exception occurs when an exception occurs in to except block
When is the finally block executed? only if some condition that has been specified is
548 8 D 1 when there is no exception when there is an exception always
satisfied
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following Python code?


def foo():
try:
return 1 Error, there is more than one return
549 8 B 1 1 2 3
finally: statement in a single try-finally block
return 2
k = foo()
print(k)
What will be the output of the following Python code?
def foo():
try:
1
print(1) 2
550 8 A 1 2 1 2
finally: 2
None
print(2)
k = foo()
print(k)
What will be the output of the following Python code?
def getMonth(m):
if m<1 or m>12:
551 8 C 1 ValueError Invalid 6 ValueError(“Invalid”)
raise ValueError("Invalid")
print(m)
getMonth(6)
Which of the following statements is true? When there is a deviation from the rules of a
The standard exceptions are automatically All raised standard exceptions must be handled in If any exception is thrown in try block, else
552 8 A 1 programming language, a semantic error is
imported into Python programs Python block is executed
thrown
Which of the following blocks will be executed whether an exception is thrown or not?
553 8 C 1 except else finally assert
What will be the output of below Python code?
f=open("sample2.txt",'w')
f.write("Hello World")
f.close()
try:
m=5
f=open("sample2.txt")
print(m) 5 5 5 Hello World
print(f.read()) Hello World hello world Hello World 5
554 8 C 1
L=[1,2,3] File not found List out index of range List out index of range List index out of range
L[100]
except FileNotFoundError:
print("File not found")
except NameError:
print("Variable not found")
except Exception:
print("List index out of range")

What will be the output of the following code?


try:
a=5
print(a)
555 8 A 1 SyntaxError: invalid syntax NameError This is python AttributeError
print(b
except:
print("This is python")

Create a class called NumberSet that accepts 2 integers as input, and defines two instance variables: num1 and num2,
556 8 which hold each of the input integers. Then, create an instance of NumberSet where its num1 is 6 and its num2 is 10. Save 4
this instance to a variable t
Create a class called Animal that accepts two numbers as inputs and assigns them respectively to two instance variables:
arms and legs. Create an instance method called limbs that, when called, returns the total number of limbs the animal has.
557 8 To the variable name spider, assign an instance of Animal that has 4 arms and 4 legs. Call the limbs method on the spider 5
instance and save the result to the variable name spidlimbs

Write a Python program to create a Vehicle class with max_speed and mileage instance attributes.
558 8 4

Write a Python class named Student with two attributes student_name, marks. Modify the attribute values of the said
559 8 4
class and print the original and modified values of the said attributes.
Write a Python class named Student with two attributes student_id, student_name. Add a new attribute student_class.
560 8 4
Create a function to display the entire attribute and their values in Student class.
Write a Python class named Rectangle constructed by a length and width and a method which will compute the area of a
561 8 4
rectangle.
Write a Python class named Circle constructed by a radius and two methods which will compute the area and the
562 8 4
perimeter of a circle.
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Write a python program to demonstrate the use of try-except-else in Exception handling


563 8 3

Write a python program to demonstrate the use of raise in Exception handling


564 8 3

Write a python program to demonstrate the use of custom exceptions in Exception handling.
565 8 3

Write a program to build a simple Student Management System using Object Oriented Programming in Python which can
perform the following operations:
accept-This method takes details from the user like name, roll number, and marks for two different subjects.
display-This method displays the details of every student.
search-This method searches for a particular student from the list of students. This method will ask the user for roll
number and then search according to the roll number
delete-This method deletes the record of a particular student with a matching roll number.
update-This method updates the roll number of the student. This method will ask for the old roll number and new roll
number. It will replace the old roll number with a new roll number.
The following instructions need to be considered while making a program.
1.Give class name as Student
2.Include methods name as accept, display, search, delete and update. (1 mark for each correct method to be formed).
3.Also form constructor with __init__ () method (2 marks for forming constructor).
4.2 marks for correct object prepared like after deletion of one roll no of student it should update the list with new roll
no. and should display it.
The example is just for understanding but logic should be for any n number of students.For Example:
List of Students
Name : A
RollNo : 1
Marks1 : 100
Marks2 : 100
Name : B
RollNo : 2
Marks1 : 90
Marks2 : 90

566 8 9
Name : C
RollNo : 3
Marks1 : 80
Marks2 : 80
Student Found,
Name : B
RollNo : 2
Marks1 : 90
Marks2 : 90
List after deletion
Name : A
RollNo : 1
Marks1 : 100
Marks2 : 100
Name : C
RollNo : 3
Marks1 : 80
Marks2 : 80
List after updation
Name : A
RollNo : 1
Marks1 : 100
Marks2 : 100
Name : C
RollNo : 2
Marks1 : 80
Marks2 : 80
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

You own a pizzeria named Olly’s Pizzas and want to create a Python program to handle the customers and revenue. Create
the following classes with the following methods:
Class Pizza containing
1.init method: to initialize the size (small, medium, large), toppings (corn, tomato, onion, capsicum, mushroom, olives,
broccoli), cheese (mozzarella, feta, cheddar). Note: One pizza can have only one size but many toppings and cheese. (1.5
marks)
Throw custom exceptions if the selects toppings or cheese not available in lists given above. (1 mark)
2.price method: to calculate the prize of the pizza in the following way:
small = 50, medium = 100, large = 200
Each topping costs 20 rupees extra, except broccoli, olives and mushroom, which are exotic and so cost 50 rupees each.
Each type of cheese costs an extra 50 rupees. (1.5 marks)
567 8 Class Order containing 9
1.init method: to initialize the name, customerid of the customer who placed the order (0.5 marks)
2.order method: to allow the customer to select pizzas with choice of toppings and cheese (1 mark)
3.bill method: to generate details about each pizza ordered by the customer and the total cost of the order. (2 marks)

*Note: A customer can get multiple pizzas in one order.

1.5 marks for creating appropriate objects of these classes and writing correct output.

Write a class called WordPlay. It should have a constructor that holds a list of words. The user of the class should pass the
list of words through constructor, which user wants to use for the class. The class should have following methods:

words_with_length(length) — returns a list of all the words of length length


starts_with(char1) — returns a list of all the words that start with char1
ends_with(char2) — returns a list of all the words that end with char2
palindromes() — returns a list of all the palindromes in the list
only(str1) — returns a list of the words that contain only those letters in str1
avoids(str2) — returns a list of the words that contain none of the letters in str2

Make Required object for WordPlay class and test all the methods.

568 8 9
For Example:

If input list entered by user is: ['apple', 'banana', 'find', 'dictionary', 'set', 'tuple', 'list', 'malayalam', 'nayan', 'grind', 'apricot']

words_with_length (5) should return ['apple', 'tuple', 'nayan', 'grind']


starts_with ('a') should return ['apple', 'apricot']
ends_with ('d') should return ['find', 'grind']
palindromes () should return ['malayalam', 'nayan']
only ('bna') should return ['banana']
avoids ('amkd') should return ['set', 'tuple', 'list']
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Write a python program that has class store which keeps record of code and price of each product. Display a menu of all
products to the user and prompt him to enter the quantity of each item required. generate a bill and display total amount.
Sample Output:
enter no of items: 3
enter code of item: milk
enter cost of item: 30
enter code of item: apple
enter cost of item: 35
enter code of item: gems
enter cost of item: 40
Item Code Price
milk 30
apple 35
569 8 gems 40 9
Enter quantity of each item:
Enter quantity of milk : 2
Enter quantity of apple : 3
Enter quantity of gems : 4

************************Bill**********************
ITEM PRICE QUANTITY SUBTOTAL
milk 30 2 60
apple 35 3 105
gems 40 4 160
**************************************
Total= 325

Write a python program that has a class Point with attributes as the x and y co-ordinates.

1.Add a method ‘distance from origin’ to class Point which returns the distance of the given point from origin. The equation
is

2.Add a method ‘translate’ to class Point, which returns a new position of point after translation
3.Add a method ‘reflect_x’ to class Point, which returns a new point which is the reflection of the point about the x-axis.
4.Add a method ‘distance’ to return distance of the given point with respect to the other point. The formula for calculating
distance between A(x1,y1) and B(x2,y2) is

570 8 9
After creating class blueprint run the following test case -

Test Case – Point (1,2)


Distance from origin - 2.23
Translate method - point (1,2) translated by (1,1) increment will be at (2,3) now
Reflect_x Method - Point (2,3) after given reflection will be at (2,-3)
Distance Method - distance between point (2,-3) and (3,4) is 1.41

A possible collection of classes which can be used to represent a music collection (for example, inside a music player),
focusing on how they would be related by composition. You should include classes for songs, artists, albums and playlists.
For simplicity you can assume that any song or album has a single “artist” value (which could represent more than one
person), but you should include compilation albums (which contain songs by a selection of different artists). The “artist” of
a compilation album can be a special value like “Various Artists”. You can also assume that each song is associated with a
single album, but that multiple copies of the same song (which are included in different albums) can exist.

571 8 Write a simple implementation of this model which clearly shows how the different classes are composed. Write some 9
example code to show how you would use your classes to create an album and add all its songs to a playlist. Class Album
should have a method to add track, class Artist should have methods to add album and add song, class Playlist should also
have a method to add song.
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Stacks and Queues. Write a class SQ that defines a data structure that can behave as both a queue (FIFO) or a stack (LIFO),
There are five methods that should be implemented:

1.make a constructor with a valid parameter


2.shift() returns the first element and removes it from the list. Also, use the custom(raise) exception in this method.
8 3.unshift() "pushes" a new element to the front or head of the list 9
572
4.push() adds a new element to the end of a list
5.pop() returns the last element and removes it from the list
6.remove() returns the maximum element of the list and removes it from the list.
7.Create the object and call all methods of the SQ class.

You need to create a class called Atm. It should have methods to create the pin, to change the pin, to check balance, to
withdraw money, to deposit money. Also, you need to create method called menu to choose from the above given
operations which you want to perform.

create_pin Method:
Ask user to enter the pin to create a new pin. Also ask user to initialize the balance of your account.

change_pin Method:
Pin Validation is required before changing the pin. If Pin entered is wrong then message should be displayed “Enter correct
pin”. if Pin is correct then update the Old Pin with New Pin.

check_balance Method:
Pin Validation is required for checking the balance. It should display the current balance of account.
573 8 9
withdraw Method:
Pin Validation is required before withdrawing money. It should ask user for amount to withdraw. It should also display the
insufficient fund message if withdraw amount is higher than balance else balance should be updated after withdraw.

deposit Method:
Pin Validation is required before deposit of money. It should ask user for amount to deposit. balance should be updated
after deposit.

After completion of every method it should ask for choice(menu() method) to perform new operation. If you don’t want
any operation to perform then you can choose choice of exit to come out from the program

What will be the output of the following Python code?


class Test:
def __init__(self):
self.x = 0
class Derived_Test(Test):
Error because class B inherits A but variable x Error because when object is created,
574 9 def __init__(self): C 1 01 10
isn’t inherited argument must be passed like Derived_Test(1)
self.y = 1
def main():
b = Derived_Test()
print(b.x,b.y)
main()
What will be the output of the following Python code?
class A():
def disp(self):
print("A disp()") Error because when object is created, argument
575 9 D 1 Invalid syntax for inheritance Nothing is printed A disp()
class B(A): must be passed
pass
obj = B()
obj.disp()
Suppose B is a subclass of A, to invoke the __init__ method in A from B, what is the line of code you should write?
576 9 A 1 A.__init__(self) B.__init__(self) A.__init__(B) B.__init__(A)

What will be the output of the following Python code?


class Test:
def __init__(self):
self.x = 0
class Derived_Test(Test):
def __init__(self): Error because class B inherits A but variable Error, the syntax of the invoking method is
577 9 C 1 00 01
Test.__init__(self) x isn’t inherited wrong
self.y = 1
def main():
b = Derived_Test()
print(b.x,b.y)
main()
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following Python code?


class A:
def one(self):
return self.two()

def two(self):
return 'A'
578 9 B 1 AA AB BB BA
class B(A):
def two(self):
return 'B'
obj1=A()
obj2=B()
print(obj1.two(),obj2.two())
What type of inheritance is illustrated in the following Python code?
class A():
pass
class B():
579 9 B 1 Multi-level inheritance Multiple inheritance Hierarchical inheritance Single-level inheritance
pass
class C(A,B):
pass

What type of inheritance is illustrated in the following Python code?


class A():
pass
class B(A):
580 9 A 1 Multi-level inheritance Multiple inheritance Hierarchical inheritance Single-level inheritance
pass
class C(B):
pass

In which of the following does the CricketFan class correctly inherit from the PartyAnimal class?
581 9 B 1 from party import PartyAnimal class CricketFan(PartyAnimal) an = PartyAnimal() CricketFan = PartyAnimal()
What does single-level inheritance mean? A subclass derives from a class which in A single subclass derives from a single Multiple base classes inherit a single derived
582 9 C 1 A single superclass inherits from multiple subclasses
turn derives from another class superclass class
Inheritance follows which approach to problem solving?
583 9 B 1 Bottom -up Top-down bottom-down top-up
What will be the output of the following Python code?
class A:
def __init__(self,x):
self.x = x
def count(self,x):
self.x = self.x+1
class B(A):
def __init__(self, y=0):
584 9 A.__init__(self, 3) B 1 30 31 01 An exception in thrown
self.y = y
def count(self):
self.y += 1
def main():
obj = B()
obj.count()
print(obj.x, obj.y)
main()
The child's __init__() function overrides the inheritance of the parent's __init__() function.
585 9 A 1 TRUE FALSE CAN BE TRUE OR FALSE CAN NOT SAY
What will be the output of the following Python code?
class A:
def test1(self):
print(" test of A called ")
class B(A):
def test(self):
print(" test of B called ")
test of B called test of C called Error, both the classes from which D derives
586 9 class C(A): C 1 test of B called
test of C called test of B called has same method test()
def test(self):
print(" test of C called ")
class D(B,C):
def test2(self):
print(" test of D called ")
obj=D()
obj.test()
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What does the following code output?


class People():

def __init__(self, name):


self.name = name

587 9 def namePrint(self): A 1 Sally Louise Sally Louise Person1


print(self.name)

person1 = People("Sally")
person2 = People("Louise")
person1.namePrint()

You cannot create object of which type of class


588 9 C 1 base derived abstract intermediate
Which of the following best describes polymorphism? Allows for objects of different types and
Ability of a class to derive members of Means of bundling instance variables and methods Focuses on variables and passing of variables to
589 9 D 1 behaviour to be treated as the same general
another class as a part of its own definition in order to restrict access to certain class members functions
type
What will be the output of the following Python code?
class Demo:
def __init__(self):
self.x = 1
def change(self):
self.x = 10
class Demo_derived(Demo):
def change(self):
590 9 B 1 11 2 1 10
self.x=self.x+1
return self.x
def main():
obj = Demo_derived()
print(obj.change())

main()

What will be the output of the following Python code?


class Demo:
def check(self):
return " Demo's check "
def display(self):
print(self.check()) Demo’s check Derived’s
591 9 A 1 Demo’s check Demo’s check Derived’s check Demo’s check Syntax error
class Demo_Derived(Demo): check
def check(self):
return " Derived's check "
Demo().display()
Demo_Derived().display()

What will be the output of the following Python code?


class A:
def __init__(self, x, y):
self.x = x
self.y = y
def __str__(self):
592 9 return 1 C 1 False 1 TRUE An exception is thrown
def __eq__(self, other):
return self.x * self.y == other.x * other.y
obj1 = A(5, 2)
obj2 = A(2, 5)
print(obj1 == obj2)

What will be the output of the following Python code?


class A:
def one(self):
return self.two()
def two(self):
593 9 return 'A' D 1 A An exception is thrown AB B
class B(A):
def two(self):
return 'B'
obj2=B()
print(obj2.two())
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be output for the following code?


import numpy as np
594 9 B 1 0 1 2 3
a = np.array([1,2,3,5,8])
print (a.ndim)
NumPY stands for?
595 9 C 1 Numbering Python Number In Python Numerical Python None Of the above
What will be output for the following code?
import numpy as np
596 9 A 1 [1 2 3 4 5 6] array([1, 2, 3, 4, 5]) (1 2 3 4 5 6) (1,2,3,4,5,6)
a=np.array([1,2,3,4,5,6])
print(a)
What will be output for the following code?
import numpy as np
597 9 A 1 42 [42] ([42]) int
arr = np.array(42)
print(arr)
What will be output for the following code?
import numpy as np
598 9 C 1 1 2 3 4
arr = np.array([1, 2, 3, 4])
print(arr[2])
What will be output for the following code?
import numpy as np
599 9 A 1 2 1 -5 ERROR
arr = np.array([1, 2, -5, 4])
print(arr[-3])
What will be output for the following code?
import numpy as np
600 9 D 1 2 1 -5 ERROR
arr = np.array([1, 2, -5, 4])
print(arr[-5])
What will be output for the following code?
import numpy as np
601 9 C 1 5 3 7 ([3,4])
arr = np.array([1, 2, 3, 4])
print(arr[2] + arr[3])
What will be output for the following code?
import numpy as np
602 9 B 1 6 2 4 10
arr = np.array([[1,2,3,4,5], [6,7,8,9,10]])
print(arr[0, 1])
What will be output for the following code?
import numpy as np
603 9 D 1 4 2 3 8
arr = np.array([[1,2,3,4,5], [6,7,8,9,10]])
print(arr[1, -3])
What will be output for the following code?
import numpy as np
604 9 C 1 12 3 6 9
arr = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]])
print(arr[0, 1, 2])
What will be output for the following code?
import numpy as np
605 9 C 1 6 3 12 9
arr = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]])
print(arr[1, 1, 2])
What will be output for the following code?
import numpy as np
606 9 B 1 [1 2 3 4] [2 3 4 5] [1 2 3 4 5 ] [1 5]
arr = np.array([1, 2, 3, 4, 5, 6, 7])
print(arr[1:5])
What will be output for the following code?
import numpy as np
607 9 A 1 [2 3 4] [1 2 3] [5 6 7] [3 2 1]
arr = np.array([1, 2, 3, 4, 5, 6, 7])
print(arr[1:-3])
What will be output for the following code?
import numpy as np
608 9 A 1 [567] [1 2 3 4] [1 2 3 4 5] [1 5]
arr = np.array([1, 2, 3, 4, 5, 6, 7])
print(arr[4:])
What will be output for the following code?
import numpy as np
609 9 B 1 [4 5 6 7] [1 2 3 4] [1 2 3 4 5 ] [1 5]
arr = np.array([1, 2, 3, 4, 5, 6, 7])
print(arr[:4])
What will be output for the following code?
import numpy as np
610 9 A 1 [10 11 12] [4 5 6] [[10 11 12]] [[[10 11 12]]]
arr = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]])
print(arr[1,1,0:3])
What will be output for the following code?
[[4 5 6]
import numpy as np [[ 7 8 9] [ 7 8 9]
611 9 A 1 [10 11 12] [ 7 8 9]
arr = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]) [10 11 12]] [10 11 12]
[10 11 12]]
print(arr[1,0:3])
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be output for the following code?


import numpy as np
612 9 C 1 (2 4) [2 4] (2, 4) 2D
arr = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])
print(arr.shape)
What will be output for the following code?
import numpy as np
613 9 B 1 (2,4) (1, 2, 4) 3D (0,2,4)
arr = np.array([[[1, 2, 3, 4], [5, 6, 7, 8]]])
print(arr.shape)
What will be output for the following code?
[[ 1 2 3] [ 1 2 3] [[[ 1 2 3]
import numpy as np
[ 4 5 6] [ 4 5 6] [ 4 5 6]
614 9 arr = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) A 1 ERROR
[ 7 8 9] [ 7 8 9] [ 7 8 9]
newarr = arr.reshape(4, 3)
[10 11 12]] [10 11 12] [10 11 12]]]
print(newarr)
What will be output for the following code? [[[ 1 2] [[ 1 2]
[ 1 2]
import numpy as np [ 3 4] [ 3 4]
[[ 1 2 3] [ 3 4]
arr = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) [ 5 6]] [ 5 6]]
[ 4 5 6] [ 5 6]
615 9 newarr = arr.reshape(2, 3, 2) A 1
[ 7 8 9] [ 7 8]
print(newarr) [[ 7 8] [[ 7 8]
[10 11 12]] [ 9 10]
[ 9 10] [ 9 10]
[11 12]
[11 12]]] [11 12]]
What will be output for the following code? [[[1 2]
import numpy as np [3 4]] [[[1 2 3 4]]
[[[1 2 3 4]
616 9 arr = np.array([1, 2, 3, 4, 5, 6, 7, 8]) A 1 [[1 2 3 4 5 6 7 8]]
[5 6 7 8]]]
newarr = arr.reshape(2, 2, -1) [[5 6] [[5 6 7 8]]]
print(newarr) [7 8]]]
What will be output for the following code?
import numpy as np
617 9 arr = np.array([[1, 2, 3], [4, 5, 6]]) A 1 [1 2 3 4 5 6] 6 [4,5,6] [3,6]
newarr = arr.reshape(-1)
print(newarr)
What will be output for the following code?
import numpy as np
arr1 = np.array([1, 2, 3])
618 9 A 1 [1 2 3 4 5 6] [5,7,9] [4,10,18] [6,15]
arr2 = np.array([4, 5, 6])
arr = np.concatenate((arr1, arr2))
print(arr)
What will be output for the following code?
[[[1 2]
import numpy as np [[1 2]
[3 4]]
arr1 = np.array([[1, 2], [3, 4]]) [[1 2 5 6] [3 4]
619 9 A 1 ERROR
arr2 = np.array([[5, 6], [7, 8]]) [3 4 7 8]] [5 6]
[[5 6]
arr = np.concatenate((arr1, arr2), axis=1) [7 8]]
[7 8]]]
print(arr)
What will be output for the following code?
[[[1 2]
import numpy as np [[1 2]
[3 4]]
arr1 = np.array([[1, 2], [3, 4]]) [[1 2 5 6] [3 4]
620 9 B 1 ERROR
arr2 = np.array([[5, 6], [7, 8]]) [3 4 7 8]] [5 6]
[[5 6]
arr = np.concatenate((arr1, arr2), axis=0) [7 8]]
[7 8]]]
print(arr)
What will be output for the following code?
[[[1 2]
import numpy as np [[1 2]
[3 4]]
arr1 = np.array([[[1, 2], [3, 4]]]) [3 4] [[[1 2 5 6]
621 9 B 1 [1 2 3 4 5 6 7 8]
arr2 = np.array([[[5, 6], [7, 8]]]) [5 6] [3 4 7 8]]]
[[5 6]
arr = np.concatenate((arr1, arr2), axis=0) [7 8]]
[7 8]]]
print(arr)
What will be output for the following code?
[[[1 2]
import numpy as np [[[1 2] [[1 2]
[3 4]]
arr1 = np.array([[[1, 2], [3, 4]]]) [3 4] [[[1 2 5 6] [3 4]
622 9 A 1
arr2 = np.array([[[5, 6], [7, 8]]]) [5 6] [3 4 7 8]]] [5 6]
[[5 6]
arr = np.concatenate((arr1, arr2), axis=1) [7 8]]] [7 8]]
[7 8]]]
print(arr)
What will be output for the following code?
import numpy as np
623 9 arr = np.array([1, 2, 3, 4, 5, 6]) A 1 [array([1, 2]), array([3, 4]), array([5, 6])] [([1, 2]),([3, 4]),([5, 6])] (1,2) (3,4) (5,6) [1,2] [3,4] [5,6]
newarr = np.array_split(arr, 3)
print(newarr)
What will be output for the following code?
import numpy as np
[array([1, 2]), array([3, 4]), array([5]),
624 9 arr = np.array([1, 2, 3, 4, 5, 6]) A 1 [([1, 2]),([3, 4]),([5]), ([6])] [([1, 2]),([3, 4]),([5, 6])] [array([1, 2]), array([3, 4]), array([5, 6])]
array([6])]
newarr = np.array_split(arr, 4)
print(newarr)
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be output for the following code? [array([[ 1, 2], [[ 1 2]


import numpy as np [array([[1, 2], [ 3, 4], [ 3 4]
[array([[1, 2]]), array([[3, 4]]), array([[5,
arr = np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]]) [3, 4]]), array([[5, 6], [ 5, 6], [ 5 6]
625 9 B 1 6]]), array([[7, 8]]), array([[ 9, 10]]),
newarr = np.array_split(arr, 3) [7, 8]]), array([[ 9, 10], [ 7, 8], [ 7 8]
array([[11, 12]])]
print(newarr) [11, 12]])] [ 9, 10], [ 9 10]
[11, 12]])] [11 12]]
What will be output for the following code?
import numpy as np
[array([1]), array([2]), array([3]), array([4]),
626 9 arr = np.array([1, 2, 3, 4, 5, 6]) A 1 [1 2 3 4 5 6] [[1],[2],[3],[4],[5],[6]] ([1 2 3 4 5 6])
array([5]), array([6])]
newarr = np.array_split(arr, 6)
print(newarr)
What will be output for the following code?
import numpy as np
627 9 arr = np.array([1, 2, 3, 4, 5, 4, 4]) A 1 (array([3, 5, 6], dtype=int64),) (3,5,6) [3,5,6] [3]
x = np.where(arr == 4)
print(x)
What will be output for the following code?
import numpy as np
(array([1, 2], dtype=int64), array([1, 1],
628 9 arr = np.array([[1, 2], [3, 4], [5, 4]]) A 1 (array([3, 5, 6],) [3,5,6] (([1, 2]),([1, 1]))
dtype=int64))
x = np.where(arr == 4)
print(x)
import numpy as np
629 9 arr = np.array([3, 2, 0, 1]) A 1 [0 1 2 3] [3 2 1 0] 0123 3210
print(np.sort(arr))
What will be output for the following code?
import numpy as np [[2 3]
630 9 C 1 [[0,1],[2,3]] [[0,1,2,3]] [0,1] [2,3]
arr = np.array([[3, 2], [0, 1]]) [0 1]]
print(np.sort(arr))
What will be output for the following code?
import numpy as np
631 9 A 1 ['apple' 'banana' 'cherry'] 'apple' 'banana' 'cherry' ['apple', 'banana', 'cherry'] ERROR
arr = np.array(['banana', 'cherry', 'apple'])
print(np.sort(arr))
What will be output for the following code?
import numpy as np
632 9 A 1 [False True True] [0 1 1] [1 0 1] ERROR
arr = np.array([True, False, True])
print(np.sort(arr))
What will be output for the following code?
import numpy as np
633 9 B 1 [0 1 False True True] [0 0 1 1 1] [False True True 0 1] [False False True True True]
arr = np.array([True, False, True,0,1])
print(np.sort(arr))
What will be output for the following code?
import numpy as np
634 9 D 1 k "k" [k] ERROR
arr = np.array(k)
print(arr)
Instance of which type of class can’t be created?
635 9 A 1 Abstract class Parent class Anonymous class Nested class
What will be the output of the following code?
class A:
def rk(self):
print(" In class A")
class B:
(<class '__main__.C'>, <class D.(<class '__main__.C'>, <class
def rk(self): (<class '__main__.A'>, <class '__main__.C'>, <class (<class '__main__.B'>, <class '__main__.C'>,
636 9 A 1 '__main__.A'>, <class '__main__.B'>, <class '__main__.B'>, <class '__main__.A'>, <class
print(" In class B") '__main__.B'>, <class 'object'>) <class '__main__.A'>, <class 'object'>)
‘object'>) 'object'>)
class C(A, B):
def rk(self):
pass
r = C()
print(C.__mro__)
What is the output of the following code? import numpy as np
a=np.array([1,2,3,4])
637 9 A 1 (4, ) -4 (1,0) (1,4)
print(a.shape)

What is wrong with this program?


import numpy as np
arr = np.array([1, 2, 3, 4, 5, 6, 7, 8]) cannot reshape array of size 8 into shape
638 9 A 1 cannot reshape array of size 7 into shape (3,3) there is no function called array None of these
newarr = arr.reshape(3, 3) (3,3)
print(newarr)
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be output for the following code?


Import numpy as np
A=np.array([[[1,2], [4,3]], [[3,5], [6,4]]]) (array([0, 1], dtype=int64), array([1, 1], (array([1,2], dtype=int64), array([0, 1], (array([1, 1], dtype=int64), array([0, 1],
639 9 A 1 Error
x=np.where(A==4) dtype=int64), array([0, 1], dtype=int64)) dtype=int64), array([1, 1], dtype=int64)) dtype=int64))
print(x)

What will be the MRO for class P in program given below:


class A:
pass
class B:
pass
class C:
pass
class X(A,B):
640 9 D 1 P,Z,Y,X,A,B,C,Object P,Z,A,Y,C,A,B,X,A,B,Object P,Z,A,Y,C,B,X,Object P,Z,Y,C,X,A,B,Object
pass
class Y(C,A,B):
pass
class Z(A):
pass
class P(Z,Y,X):
pass

What will be output for the following code?


from abc import ABC,abstractmethod
class Father(ABC):
@abstractmethod
def display(self):
pass
def play(self): Child class
641 9 print('Abstract class') D 1 Child class Abstract class Error
Abstract class
class Son(Father):
def play(self):
print('Child class')
A=Son()
A.play()

What will be output for the following code?


import numpy as np
[[1 3] [[ 1 3 6] [[6]
arr1=np.array ([[1,3], [14,20], [5,6]])
642 9 B 1 [14 20] [14 20 9] [9] [1 3 6 14 20 9 5 6 12]
arr2=np.array ([[6], [9], [12]])
[5 6]] [ 5 6 12]] [12]]
arr=np.concatenate((arr1,arr2),axis=1)
print(arr)
What will be output for the following code?

import numpy as np
a = np.array([[1,0,3],[0,1,4]])
643 9 b = np.array([[0,2,3],[0,1,5]]) D 1 15 20 25 10
c = np.array([[1,2,0],[0,1,1]])
d=a+b+c
print (d[1,2])

What will be the output of the following Python code?

class A():
def disp(self):
print("C disp()")
class C():
def disp(self): A disp()
644 9 A 1 C disp() A disp() B disp()
print("A disp()") C disp()
class B(A,C):
def dis(self):
print("B disp()")
obj = B()
obj.disp()
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following Python code?

class A:
def __init__(self,x=3):
self._x = x
class B(A):
def __init__(self):
645 9 super().__init__(5) B 1 3 5 53 35
def display(self):
print(self._x)
def main():
obj = B()
obj.display()
main()

What will be the output of the following code:


class A:
def __init__(self,x):
self.x = x
def count(self,x):
self.x = self.x-2
class B(A):
def __init__(self, y=0):
646 9 A.__init__(self, 3) C 1 30 31 3 -1 Error
self.y = y
def count(self):
self.y -= 1
def main():
obj = B()
obj.count()
print(obj.x, obj.y)
main()

What will be printed?


import numpy as np
a = np.array([1,2,3,5,8])
b = np.array([0,3,4,2,1])
647 9 B 1 10 55 33 35
c=a+b+2*b
c = c*a
print (c[3])

What will be the output of the following code:


class P:
pass
class Q:
pass
class R(P,Q):
pass [__main__.T, __main__.S, __main__.R, (__main__.T, __main__.S, __main__.P, __main__.Q, (__main__.T, __main__.S, __main__.R, (__main__.T, __main__.S, __main__.Q,
648 9 C 1
class S(Q): __main__.P, __main__.Q] __main__.R, object) __main__.P, __main__.Q, object) __main__.R, __main__.P, object)
pass
class T(S,R):
pass
a=T()
T.__mro__

What will be the output of the following code:


class Demo:
def __init__(self):
self.x = 1
def change(self):
self.x = 10
return self.x
649 9 class Demo_derived(Demo): A 1 5 10 1 2
def change(self):
self.x*=5
return self.x
def main():
obj = Demo_derived()
print(obj.change())
main()
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be the output of the following code:


import numpy as np [[ 1 2 3] [[[ 1 2 3]] [[[ 1 2 3]
arr = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]]) [ 4 5 6] [[ 4 5 6]] [ 4 5 6]]
650 9 B 1 Error
newarr = arr.reshape(4, 1, -1) [ 7 8 9] [[ 7 8 9]] [[ 7 8 9]
print(newarr) [10 11 12]] [[10 11 12]]] [10 11 12]]]

What will be output for the following code?


import numpy as np
arr=np.array([[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]]])
[[[4 2] [[[1 3]
arr1=np.array([[[4,3,2],[7,10,15]],[[6,1,2],[8,7,9]]]) [[[1 2 3]
651 9 C 1 [7 15]]] Value Error [4 6]]]
newarr=np.concatenate((arr,arr1),axis=1) [4 5 6]]]
x=newarr[:1:,:2:,:3:2]
y=np.sort(x)
print(y)
What will be output for the following code?
import numpy as np [[3] [[3 4 5] [[3],
652 9 arr = np.array([[1,2,3,4,5], [6,7,8,9,10]]) A 1 [8]] [8 9 10]] [8]] [[3 8]]
print(arr[0:, -3:-2])

What will be output for the following code?


import numpy as np
arr=np.array([[[1,2,3],[4,5,6]],[[6,5,3],[4,2,1]]])
653 9 A 1 (2,1,2) (1,2,4) (2,2,3) (2,3,2)
x=arr[0:2,::2,::2]
print(x.shape)

What will be output for the following code?


import numpy as np
arr1 = np.array([[[1, 2], [3, 4]]])
654 9 arr2 = np.array([[[5, 6], [7, 8]]]) A 1 (1,4,2) (1,2,4) (2,2,2) (4,2)
arr = np.concatenate((arr1, arr2), axis=1)
print(arr.shape)

What will be the output of the following Python code?


class P1:
def hi(self):
print("hi P1")
class P2:
def hi(self):
print("hi P2")
class C1(P1):
655 9 pass D 1 hello C1 hi C1 hello GC hello C2
class C2(P1):
def hi(self):
print("hello C2")
class GC(C1,C2):
pass
gc=GC()
gc.hi()

What will be the output of the following Python code?


class P1:
def hello(self):
print("hi P1")
class P2:
def hi(self):
print("hi P2")
class C1(P1):
656 9 pass A 1 hi P1 hi C1 hello GC hello C2
class C2(P1):
def h(self):
print("hello C2")
class GC(C1,C2):
pass
gc=GC()
gc.hello()

What will be output for the following code?


import numpy as np
arr = np.array([1, 2, 3, 4, 5, 6, 7, 8]) (array([0, 2, 4, 6],
657 9 A 1 arr([1, 3, 5, 7],) [3] All of these
x = np.where(arr%2 == 1) dtype=int64),)
print(x)
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What is the Output of the Following Code?

class A:
def __init__(self, x=5):
self.x = x
class der(A):
658 9 def __init__(self, y=3): C 1 12 35 53 Error
super().__init__()
self.y = y
def main():
obj = der()
print(obj.x, obj.y)
main()
What will be output for the following code?

659 9 import numpy as np D 1 16 17 18 27


arr = np.array([[1,2,3,4,5], [6,7,8,9,10]])
print(arr[0,1],arr[1,1])
What will be output for the following code?

660 9 import numpy as np A 1 [3 2 1 0] [1 2 3 0] [0 1 2 3] 0123


arr = np.array([3, 2, 0, 1])
print(np.sort(arr)[::-1])
What will be output for the following code?

arr1 = np.array([[1,2],[5,6]])
arr2 = np.array([[3,4],[7,8]])
arr=np.concatenate((arr1,arr2))
661 9 D 1 [7 8] 7 4 8
for i in arr:
for j in i:
if(j%2==0):
newarr=j
print(newarr)
What will be printed?

import numpy as np
a = np.array([1,2,3,5,8])
662 9 C 1 18 15 30 20
b = np.array([0,3,4,2,1])
c=a*b
c=c+a
print ( c[2] + c[3] )
What is the output of following code?

663 9 arr = np.array([1,2,3,4,5,6,7,8]) A 1 1 2 3 (2,)


arr.reshape(2,4)
print(arr.ndim)
What will be output for the following code?
import numpy as np [[10 12 13] [[10 10 10]
664 9 a=np.array([[5],[7],[8]]) A 1 [12 14 15] [14 14 14] ValueError TypeError
b=np.array([[5,7,8]]) [13 15 16]] [16 16 16]]
print(b+a)
What will be output for the following code?
class A:
def hello(self):
print("1",end=",")
def hello(self):
print("2",end=",")
class B(A):
665 9 A 1 3,2,3,2, 3,2 2,3,2,3, 3,
def __init__(self):
self.hello()
def hello(self):
print("3",end=",")
super().hello()
b=B()
b.hello()
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

What will be output for the following code?


class A:
money=5000
def __init__(self):
self.money+=A.money
666 9 class B(A): A 1 12000 7000 5000 3000
def display(self):
self.money+=2000
print(self.money)
obj=B()
obj.display()
What will be output for the following code?
class A:
a=20
def __init__(self):
self.a+=10
class B(A):
a=15
667 9 def buy(self): C 1 30 20 40 10
pass
class C(B,A):
a=30
def buy(self):
print(self.a)
obj=C()
obj.buy()
Program to demonstrate the use of inheritance
668 9 4
Program to demonstrate the use of multiple inheritance
669 9 4
Program to demonstrate the use of multilevel inheritance
670 9 4
Implement the following hierarchy . The Book function has name, n (number of authors), authors (list of authors),
publisher, ISBN, and year as its data members and the derived class has course as its data member. The derived class
671 9 6
method overrides (extends) the methods of the base
class.
Implement the following hierarchy . The Staff function has name and salary as its data members, the derived class
672 9 Teaching has subject as its data member and the class NonTeaching has department as its data member. The derived class 6
method overrides (extends) the methods of the base class.
Create a class called Student, having name and email as its data members and _init_(self, name, email) and putdata(self) as
bound methods. The _init_ function should assign the values passed as parameters to the requisite variables. The putdata
function should display the data of the student. Create another class called PhDguide having name, email, and students as
its data members. Here, the students variable is the list of students under the guide. The PhDguide class should have four
673 9 bound methods: _init_, putdata, add, and remove. The _init_ method should initialize the variables, the putdata should 6
show the data of the guide, include the list of students, the add method should add a student to the list of students of the
guide and the remove function should remove the student (if the student exists in the list of students of that guide) from
the list of students.

Program to demonstrate the issue of invoking __init__() in case of multiple inheritance


674 9 4
Write program that has a class point. Define another class location which has two objects (Location and Destination) of
675 9 class point. Also define function in Location that prints reflection of Destination on the x axis. 6

Write a program that overload the + operator so that it can add two object of class fraction
676 9 4
Write a program that overload the * operator so that it can add two object of class fraction
677 9 4
Write a program to find the distance between two points in cartesian cordinate system
678 9 4
Write a program to find the slope between two points in cartesian cordinate system
679 9 4
Create a class student with following member attributes: roll no, name, age and total marks. Create suitable methods for
680 9 reading and printing member variables. Write a python program to overload ‘==’ operator to print the details of students 6
having same marks.
Write a program to create a class called Data having “value” as its data member. Overload the (>) and the (<) operator for
681 9 the class. Instantiate the class and compare the objects using _lt_ and _gt_. 5

The following illustration creates a class called data. If no argument is passed while instantiating the class a false is
682 9 4
returned, otherwise a true is returned.
Create a 5X2 integer array from a range between 100 to 200 such that the difference between each element is 10
683 9 3
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Following is the provided numPy array. Return array of items by taking the third column from all rows
684 9 sampleArray = numpy.array([[11 ,22, 33], [44, 55, 66], [77, 88, 99]]) 2

Return array of odd rows and even columns from below numpy array
685 9 3
sampleArray = numpy.array([[3 ,6, 9, 12], [15 ,18, 21, 24], [27 ,30, 33, 36], [39 ,42, 45, 48], [51 ,54, 57, 60]])
Sort following NumPy array
Case 1: Sort array by the second row
686 9 Case 2: Sort the array by the second column 2
sampleArray = numpy.array([[34,43,73],[82,22,12],[53,94,66]])

Print max from axis 0 and min from axis 1 from the following 2-D array.
687 9 3
sampleArray = numpy.array([[34,43,73],[82,22,12],[53,94,66]])
Write a NumPy array program to convert the values of Fahrenheit degrees into Celsius degrees. The numpy array to be
considered is [0, 12, 45.21, 34, 99.91, 32] for Fahrenheit values.
Values are stored into a NumPy array. After converting the following numpy array into Celsius, then sort the array and find
the position of 0.0 (means where 0.0 value is located i.e. it’s index)
Formula to convert value of Fahrenheit to Celsius is:
C=5*F/9 - 5*32/9
Output:
Values in Fahrenheit degrees:
688 9 3
[ 0. 12. 45.21 34. 99.91 32. ]
Values in Centigrade degrees:
[-17.77777778 -11.11111111 7.33888889 1.11111111 37.72777778
0. ]
[-17.77777778 -11.11111111 0. 1.11111111 7.33888889
37.72777778]
(array([2], dtype=int64),)

import numpy as np
arr = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
689 9 2

Reshape arr into a 2D array and a 3D array.


Imagine you own a call center. Use the following abstract class template to create three more classes, Respondent,
Manager, and Director that inherit this Employee Abstract Class.

from abc import ABC, abstractmethod

class Employee(ABC):

@abstractmethod
def receive_call(self):
pass

@abstractmethod
def end_call(self):
pass

@abstractmethod
def is_free(self):
pass

@abstractmethod
def get_rank(self):
pass

690 9 9
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Create a program using the instructions given below:

690 9 9
1.Create a constructor in all three classes (Respondent, Manager and Director) which takes the id and name as input and
initializes two additional variables, rank and free. rank should be equal to 3 for Respondent, 2 for Manager and 1 for
Director. free should be a boolean variable with value True initially. (1 mark)
2.Implement rest of the methods in all three classes in the following way: (2 marks)
a.receive_call(): prints the message, “call received by (name of the employee)” and sets the free variable to False.
b.end_call(): prints the message, “call ended” and sets the free variable to True.
c. is_free(): returns the value of the free variable
d. get_rank(): returns the value of the rank variable
3.Create a class Call, with a constructor that accepts id and name of the caller and initializes a variable called assigned to
False. (0.5 marks)
4.Create a class CallHandler, with three lists, respondents, managers and directors as class variables. (0.5 marks)
5.Create an add_employee() method in CallHandler class that allows you to add an employee (an object of
Respondent/Manager/Director) into one of the above lists according to their rank. (1 mark)
6.Create a dispatch_call() method in CallHandler class that takes a call object as a parameter. This method should find the
first available employee starting from rank 3, then rank 2 and then rank 1. If a free employee is found, call its receive_call()
function and change the call’s assigned variable value to True. If no free employee is found, print the message: “Sorry! All
employees are currently busy.” (2 marks)
7.Create 3 Respondent objects, 2 Manager objects and 1 Director object and add them into the list of available employees
using the CallHandler’s add_employee() method. (1 mark)
8.Create a Call object and demonstrate how it is assigned to an employee. (1 mark)

Write a python program to create a Bus child class that inherits from the Vehicle class.
In Vehicle class vehicle name, mileage and seatingcapacity as its data member. The default fare charge of any vehicle is
seating capacity * 100. If Vehicle is Bus instance, we need to add an extra 10% on full fare as a maintenance charge. So
total fare for bus instance will become the final amount = total fare + 10% of the total fare.

691 9 Sample Output: 4


The bus seating capacity is 50. so, the final fare amount should be 5000+500=5500.

The car seating capacity is 5. so, the final fare amount should be 500.

Create an abstract class named Shape.


Create an abstract method named calculate_area for the Shape class.
Create Two Classes named Rectangle and Circle which inherit Shape class.
Create calculate_area method in Rectangle class. It should return the area of the rectangle object. (area of rectangle =
(length * breadth))
9 Create calculate_area method in Circle class. It should return the area of the circle object. 9
692
(area of circle =πr^2))
Create objects of Rectangle and Circle class.
The python Program Should also check whether the area of one Rectangle object is greater
than another rectangle object by overloading > operator.
Execute the method resolution order of the Circle class.

Write a python program to demonstrate the use of super() method to call the method of base class.
693 9 4

Create a class called Matrix containing constructor that initialized the number of rows and number of columns of a new
Matrix object.

The Matrix class has methods for each of the following:


1. get the number of rows
2. get the number of columns
694 9 9
3. set the elements of the matrix at given position (i,j)
4. adding two matrices. If the matrices are not addable, “ Matrices cannot be added” will be displayed.(Overload the
addition operation to perform this)
5. Multiplying the two matrices. If the matrices are not multiplied, “ Matrices cannot be multiplied” will be
displayed.(Overload the addition operation to perform this)
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Find the MRO of class Z of below program:

class A: pass
class B: pass
class C: pass
695 9 class D:pass 2
class E:pass
class K1(C,A,B): pass
class K3(A,D): pass
class K2(B,D,E): pass
class Z( K1,K3,K2): pass

Write a Python Program to Find the Net Salary of Employee using Inheritance.
Create three Class Employee, Perks, NetSalary. Make an Employee class as an abstract class.
Employee class should have methods for following tasks.
- To get employee details like employee id, name and salary from user.
- To print the Employee details.
- return Salary.
- An abstract method emp_id.
Perks class should have methods for following tasks.
- To calculate DA, HRA, PF.
- To print the individual and total of Perks (DA+HRA-PF).
Netsalary class should have methods for following tasks.
- Calculate the total Salary after Perks.
696 9 - Print employee detail also prints DA, HRA, PF and net salary. 9

Note 1: DA-35%, HRA-17%, PF-12%


Note 2: It is compulsory to create objects and demonstrating the methods with
Correct output. Example:
Employee ID: 1
Employee Name: John
Employee Basic Salary: 25000
DA: 8750.0
HRA: 4250.0
PF: 3000.0
Total Salary: 35000.0

In the following syntax given below:


697 10 plt.plot(ypoints,’o:r’) D 1 o (marker), : (color) and r (line) o (color), : (line) and r (marker) o (line), : (marker) and r (color) o (marker), : (line) and r (color)
What does this ‘o:r’ stands for?
In the given chart, points surrounded with circle is called

698 10 C 1 Labels Ticks Markers Series

In the given syntax what does this ms indicates?


699 10 D 1 Markerborder Markercolor Markershape Markersize
plt.plot(ypoints,marker=’o’,ms=10)
Consider the code given below:
700 10 plt.bar(cities, population,color=[‘r’,’g’,’b’,’m’]) A 1 Magneta Green Blue Black
what will be the colour of last bar?
Which type of error will be generated in this program and why? import matplotlib.pyplot as plt
import numpy as np
Syntax Error as '*' this type of linestyle does Type Error as linestyle is not proper with this
701 10 ypoints = np.array([3,8,1,10,5,7]) B 1 Value Error as '*' this type of linestyle does not exist Syntax Error as this is not a syntax of linestyle
not exist type of array
plt.plot(ypoints,linestyle='*')
plt.show()
702 10 Which linestyle does Python takes by default? D 1 Dashpot Dotted Dashed Solid
703 10 The following code will generate which type of linestyle? plt.plot(ypoints,linestyle=':') A 1 Dotted Dashed Value Error Syntax Error
Consider the following code written to display a bar chart
x=range(0,40,8)
Both the sequences x and y do not start Values produced by range is not considered for Both the sequences x and y have values with
704 10 y=range(10,100,10) B 1 Both the sequences x and y are not of same shape
with 0 chart. different intervals
plt.bar(x,y)
While executing it, is producing error. Why?
705 10 To show grid in a barplot which syntax is appropriate? C 1 grid(true) grid(false) plt.grid(True) plt.grid(False)
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

The following given program lines will give which type of input? (Rest else lines are errorless)
A horizontal bar chart with grids and grey A horizontal bar chart without grids and grey A vertical bar chart without grids and green
706 10 plt.barh(names,values,color=”grey”) A 1 A vertical bar chart with grids and grey color
color color color
plt.grid(True)
The following syntax will create:
707 10 plt.subplot(2,1,1) A 1 Will create two subplots- above and below Will create two different line plots Will create two subplots (side by side) Syntax error will be generated
plt.subplot(2,1,2)
The following syntax indicates: position of 1st plot at 3rd row, 1st column position of 1st plot at 1st row, 3rd column, and 2nd position of 1st plot at 2nd row, 3rd column and position of 1st plot at 2nd row, 1st column
708 10 A 1
plt.subplot(3,1,2) and 2nd place place 1st place and 3rd place
For the given below figure identify the correct sequence:

709 10 D 1 x=[1,1.5,1.5,2,2,2,2,2.5,4,4,4,4,4.5,5,5] x=[1,1.5,1.5,1.5,2,2,2.5,2.5,4,4,4,4,4.5,5,5] x=[1,1.5,1.5,2,2,2,2.5,2.5,3,4,4,4,4,4.5,5,5] x=[1,1.5,1.5,2,2,2,2.5,2.5,4,4,4,4,4.5,5,5]

Identify the correct data sequence for this histogram.

710 10 B 1 [1,1,2,3,3,3,4,5,5,5,6] [1,1,1,2,3,3,4,5,5,5,6] [1,2,3,3,3,4,5,5,5,6] [1,1,1,2,2,3,4,5,5,5,5,6]

These cost categories applied to a $9.00 microcontroller:

Engineering $1.35
711 10 Manufacturing $3.60 3
Sales $2.25
Profit $1.80
Create a pie chart will show the cost breakdown as different sized pieces.
Here is how many students got each grade in the recent test:
712 10 A- 4, B-12, C-10, D-2. Plot a pie chart for the student grades in the recent chart with different colors for each student 3
grades and create a wedge for D. Also put a chart title as student's grade history.
Imagine you survey your friends to find the kind of movie they like best: Comedy- 4, Action -5, Romance - 6, Drama -1, SciFi
- 4. Plot a pie chart for the above survey and use different color for each analysis and create a wedge for action movies.
713 10 Also put as chart title as "Survey analysis of movie" 3

Create a Pie Chart using Python Program for the popularity data of different programming languages and displayed it as a
pie chart using the Matplotlib Python library. For Python- 29, Java – 19, Javascript – 8, C# - 7, PHP – 6, C,C++ - 5, R – 3.
714 10 3
Create an exploded view of python and show the % of each programming language in Pie Chart.

Write a python program to create a bar plot of course v/s no. of students using the following dictionary with appropriate
715 10 labels for X and Y axes and colour of the bars green. 3
Data={‘C’:20,’C++’:15,’Java’:30,’Python’:35}
Create a bar chart for the following dataset:
Country = ['USA','Canada','Germany','UK','France']
716 10 GDP_Per_Capita = [45000,42000,52000,49000,47000]. Also plot title, X-Axis, Y-Axis, different color for each country and 3
the grid should be visible

A Bar Chart to display employee id numbers on X-axis and their salaries as Y-axis in the form of a bar graph for two
departments of a company. There are two departments like sales department and purchase department. For sales
department their id's and salaries are mentioned as : x= [1001,1003,1006,1007,1009,1011] and y= [10000,
23000.50,18000.33,16500.5,12000.75, 9999.99] and for purchase department their id's and salaries are mentioned as:
717 10 5
x=[100̣2,1004,1010,1008,1014,1015] and y=[ 5000,6000,4500.5,12000,9000,10000]. Make the chart title as "Microsoft
Inc.", x-axis as emplyee id and Y axis as Salary. Use different colors for sales and purchase department.
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Write a program to build two bar graphs using subplot function for given two dictionaries in which one graph is in 1st row
and another in second row which is horizontal representation of bar graph.
D1={“aryan”:66,”bob”:70,”jack”:66,”seema”:34}
718 10 5
D2={“joy”:45,”sid”:85,”hina”:90}
And also make a title of graph at top as “BAR PLOT”.

A program to display a histogram showing the number of employees in specific age groups. The data is shown:
emp_ages=[22,45,30,59,58,56,57,45,43,43,50,40,34,33,25,19] and their bins are [0,10,20,30,40,50,60]. Create a histogram
719 10 with x-axis label as "emplyee ages" and y axis label as " no. of employees". Create a title of the plot as "Oracle Corp". Also 3
teh color of histogram created should be cyan.

Jeff is a branch manager at a local bank. Recently Jeff’s is receiving customer feedback saying that the wait times for a
client to be served by a customer service representative are too long. Jeff decides to observe and write down the time
spent by each customer on waiting. Here are his findings from observing and writing down the wait times spent by 20
720 10 customers (in seconds): 43.1, 35.6, 5
37.6,36.5,45.3,43.5,40.3,50.2,47.3,31.2,42.2,45.5,30.3,31.4,35.6,45.2,54.1,45.6,36.5,43.1.
Plot a histogram for the above data.

Uncle Bruno owns a garden with 30 black cherry trees. Each tree is of a different height. The height of the trees (in inches):
61, 63, 64, 66, 68, 69, 71, 71.5, 72, 72.5, 73, 73.5, 74, 74.5, 76, 76.2, 76.5, 77, 77.5, 78, 78.5, 79, 79.2, 80, 81, 82, 83, 84, 85,
721 10 87. Plot a histogram with color green, title of the chart should be height of trees along with it’s fontsize as 20. 3

A Program to create a line graph to show the profits of a company in various years. The data is as mentioned: x axis as
years and y axis as profits (in Millions). X=[2012,2013,2014,2015,2016,2017] and y = [9,10,10.5,8.8,10.9,9.75]. Plot a line
722 10 3
chart with x axis as "Years" and y axis as "Profits (in Millions)" and title of the line chart as "XYZ Company". Also the
linestyle should be dashed one.
Laurell had visited a zoo recently and had collected the following data. How can Laurell use a scatter plot to represent this
723 10 data? .Take Type of Animal as X-axis and no. in Y axis. The data is as follows: Zebra-25, Lions- 5, Monkeys- 50, Elephants - 3
10, Ostriches - 20
Prayatna sells designer bags and wallets. During the sales season, he gave discounts ranging from 10% to 50% over a
period of 5 weeks. He recorded his sales for each type of discount in an array. Draw a scatter plot to show a relationship
724 10 3
between the discount offered and sales made. Take 5 sales in Rupees as user defined values

Plot a subplot showing the marks of 5 students for 6 subjects (Digital Electronics, Probability and Stochastics, Python, Full
Stack Development, IELTS (Reading), and Data Structure). All the marks for each subject and for each student is to be taken
725 10 5
user defined. Subplot should be prepared for each subject. Each Subplot should have a title of subject along with a main
title of a plot.
Write a Python program to draw a scatter plot comparing two subject marks of Mathematics and Science. Use marks of 10
students.
Test Data:
726 10 math_marks = [88, 92, 80, 89, 100, 80, 60, 100, 80, 34] 4
science_marks = [35, 79, 79, 48, 100, 88, 32, 45, 20, 30]
marks_range = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
Add appropriate labels, title and legend.
Draw multiple plots in one figure using subplot function. The multiple plots include below according to order:
1. Plot a scatter plot with following data:
x = [5,7,8,7,2,17,2,9,4,11,12,9,6]
y = [99,86,87,88,111,86,103,87,94,78,77,85,86]
The x axis represents the age of car while y axis represents the speed of car.
The title of the graph should be age v/s speed of car. Also in graph there should be x and y labels. The marker used should
be star. The marker color should be green. The marker size should be 60.
2. Plot a horizontal bar with following data:
x=["A", "B", "C", "D"]
y=[3, 8, 1, 10]
The x axis represents the name of car while y axis represents the selling of car.
The title of the graph should be name v/s selling of car. Also in graph there should be x and y label. The horizontal bar
chart's height should be 0.1. The color of bar should be yellow.
727 10 3. Plot a histogram with following data: 9
data=[1,3,3,3,3,9,9,5,4,4,8,8,8,6,7]
bins=4, the title of the graph should be histogram of cars. The orientation should be vertical. The color of plot should be
violet
4. Plot a pie with following data:
y=[35,25,25,15]
mylabels=['Apple','Bananas','Cherries','Dates']
The title of the graph should be pie chart. The exploded view should be shown with 0.2 value for 'Apple'
Also need to provide a superior title to the subplot prepared i.e 'My Subplot for cars'(0.5 marks) and subplot preparation
(0.5 mark)
For clear visualization can use the following syntax after importing matplotlib
plt.figure(figsize=(10,10))
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

There is an array of scores of 5 Batsmen in 4 T20 Matches. Which is given below.


Scores= [[13, 10, 9, 33],
[63, 46, 90, 42],
[39, 76, 13, 29],
[82, 9, 29, 78],
[67, 61, 59, 36]]
Further you are asked to perform below tasks.
(i). Add scores of every batsman of 5th Match given below in the same array and print the array.
Match_6= [41, 87, 72, 36, 92]

(ii). Add two new batsmen’s scores in respective 5 T20 Matches in the array created in task (i) above and print the array.
Batsman_6= [77, 83, 98, 95, 89]
Batsman_7= [92, 71, 52, 61, 53]

(iii). Add extra column with sum of all 5 T20 Matches’ scores of each batsman in the array created in task (ii) and print the
final array.

Note: Use Numpy module for all the Arrays given above.
728 10 9

Using the final array created in task(iii) above, generate graphs mentioned below:

(a). Make a line chart of Total Scores of each batsman which is stored in last column of final array v/s No. of Batsman. Use
dashed line in graph, with black color. Give label on x-axis as “No. of Batsman” and label on y-axis as “Scores”. Give title to
the chart as “Leader Board” with bold fonts.

(b). Make one Bar chart of scores of Batsman_1 and Batsman_2 for all 5 T20 matches. Give color for bars of Batsman_1 as
Purple and for Batsman_2 Dark red. Also show required legend in bar chart.

(c). Make a pie chart of Total Scores of each batsman which is stored in last column of final array. Show the pie chart with
exploded view of all pieces with 0.1 amount. Also display percentage in the pie chart. Also show required legend for pie
chart.

Note: Passing the values using numpy Array Slicing from array created in task(iii) for creating graphs above is compulsory.

Write a program to build 6 graphs(3 row and 2 column) using subplot function for given data:
Subplot 1:
Draw a line from (5,5) to (10,17) to (25,25) to (60,40) to (80,30) with suitable label in the x axis, y axis and a title.
Line color should be green.
Line style should be dotted.
Marker should be diamond.

Subplot 2:
Write a Python program to create bar plot of scores by group and gender. Give suitable label in the x axis, y axis and a title.
Colors of all label should be black and title should be bold. Color of bar plot of men and women scores should be green and
red.
Data:
Scores_men = (22, 30, 35, 35, 26)
Scores_women = (25, 32, 30, 35, 29)

Subplot 3:
Write a Python programming to create a pie chart with a title of the popularity of Car company. Make multiple wedges of
the pie. Also show the percentage.
data:
Car : Maruti Suzuki, Hyundai, Kia, Toyota, Honda
Popularity: 25,50,30,20,35

729 10 9
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. 10 ks
9
729

Subplot 4:
Write a Python program to draw a scatter plot comparing two subject marks of Mathematics and Science. Use marks of 10
students. Marker of mathematics and science should be circle and star. Colors of marker of mathematics and science
should be yellow and blue.
Test Data:
math_marks = [88, 92, 80, 89, 100, 80, 60, 100, 80, 34]
science_marks = [35, 79, 79, 48, 100, 88, 32, 45, 20, 30]

Subplot 5:
Write a Python programming to display a horizontal bar chart of the popularity of programming Languages. Colors of all
programming Languages should be different. Give suitable label in the x axis, y axis and a title.
data:
Programming languages: Java, Python, PHP, JavaScript, C, C++
Popularity: 20,100,25,30,45,50

Subplot 6:
Write a Python programming to display a Histogram chart for given data.
Color of chart should be red.
Data=[10,20,20,30,30,30,40,40,40,40,50,50,50,60,60,70]

Consider the following datasheet to visualize Company Sales Data

730 10

Get total profit of all months and show line plot with the following Style properties:
•Line Style dotted and Line-color should be red
•Show legend at the lower right location.
•X label name = Month Number
•Y label name = Total Profits
•Add a circle marker
•Line marker color as blue
•Line marker size as 5
•Line width should be 3

There is an array of scores of 5 Batsmen in 4 T20 Matches. Which is given below.


Scores= [[31, 12, 19, 53],
[67, 48, 95, 83],
[59, 67, 13, 59],
[62, 29, 99, 88],
[87, 91, 69, 76]]

731 10 9
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

731 10 9

1. Find the maximum score in T_20-3 and print it (use only the numpy module)
2. Find the minimum score of YUVRAJ and print it (use only the numpy module)
3. Add an extra column with the sum of all 4 T20 Matches’ scores of each batsman in the array created and print it. (use
only the numpy module)
Write a NumPy program to swap columns in a given array.
Take number of rows, number of columns, and also take the values of each rows and columns as input and also number of
columns to be swapped.
Enter the number of rows: 3
Enter the number of columns: 4
Enter values for row 1: 0 1 2 3
Enter values for row 2: 4 5 6 7
Enter values for row 3: 8 9 10 11
Enter the index of the first column to be swapped: 0
Enter the index of the second column to be swapped: 1
732 10 3
Original array:
[[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]]

After swapping arrays:


[[ 1 0 2 3]
[ 5 4 6 7]
[ 9 8 10 11]]
You are given a dataset representing the daily workout durations (workout_durations_data = [40, 50, 45, 55, 60, 30, 40, 50,
45, 55, 60, 30, 40, 50, 45, 55, 60, 30, 40, 50, 45, 55, 60, 30, 40, 50, 45, 55])
of an individual over the course of a month. Additionally, there is data on calories burned (calories_burned_data= [200,
250, 220, 270, 300, 150, 200, 250, 220, 270, 300, 150, 200, 250, 220, 270, 300, 150, 200, 250, 220, 270, 300, 150, 200, 250,
220, 270]) during each workout session. Your task is to perform a comprehensive analysis and visualization of this fitness
data.

Calculate Weekly Averages:

Calculate the weekly average workout duration and calories burned. Use a loop to compute these averages for each week.
Create Visualizations:

Design a 3x2 subplot layout to visualize the following aspects:

Subplot 1 (Line plot for daily workout durations): (Days v/s Duration (in Minutes)

Use a blue line with circular markers (marker size 8).


Title: "Daily Workout Durations"

Subplot 2 (Line plot for weekly averages of workout duration and weekly calories burned):

Use a green line with circular markers (marker size 8) for workout duration.
Use an orange line with square markers (marker size 8) for calories burned.
Title: "Weekly Averages"
L.J Institute of Engineering and Technology, Ahmedabad.
FCSP-1 Practice Book (SEM-III )_ODD-2024
Note : This practice book is only for reference purpose. LJU Test question paper may not be completely set from this practice book.

Sr. mar
unit_number question_text MCQ Answer option A option B option C option D
No. ks

Subplot 3 (Bar chart for daily workout durations):

Use a blue color for bars.


Title: "Daily Workout Durations (Bar Chart)"

Subplot 4 (Histogram for workout durations distribution):

Use a skyblue color for bars. Take value of bins as 10


Title: "Workout Durations Distribution (Histogram)"

Subplot 5 (Pie chart for calories burned distribution over the weeks):

startangle should be 90 degree and also display percentage in pie chart with 1 digits after one decimal place.
Also display labels
Title: "Calories Burned Distribution (Pie Chart)"

Subplot 6 (Line plot for the rate of change in workout durations):

Use a red line with triangular markers (marker size 8).


Title: "Rate of Change in Workout Durations"
733 10 Features and Customizations: 9

Utilize different colors for each plot.


Add markers to the line plots for emphasis.
Adjust marker sizes for better visibility.
Formula and Calculation:

The rate of change in workout durations can be calculated using the formula:
Let's consider an example to illustrate this. Suppose we have the following workout duration data for four consecutive
days:
Workout Duration already given in list above at top (workout_durations_data):
Day 1: Workout Duration = 40 minutes
Day 2: Workout Duration = 50 minutes
Day 3: Workout Duration = 45 minutes
Day 4: Workout Duration = 55 minutes
We want to calculate the rate of change in workout durations for each day.

The negative rate of change between Day 2 and Day 3 indicates a decrease in workout duration, while the positive rate of
change between Day 3 and Day 4 indicates an increase.
In the context of the fitness data visualization, the rate of change plot will show how the workout durations are changing
on a daily basis, providing insights into trends and fluctuations in the individual's exercise routine.

Instructions:
Implement the required calculations using nested loops.
Ensure that each subplot is labeled appropriately.
Customize the visualizations with specific colors, markers, and marker sizes.
Display the main title for the entire figure.

You might also like