KVS PGT Computer Science Question paper with answers

Question 1: Which of the following is not hardware of a computer system?

  • (A) Keyboard
  • (B) Printer
  • (C) Operating System
  • (D) Mouse
Show Answer & Explanation

Correct Answer: (C) Operating System

Explanation: The operating system is software, not hardware. It manages computer resources and allows interaction with hardware components.

Question 2: Which out of the following is the least capacity of memory unit compared to other options?

  • (A) MB
  • (B) KB
  • (C) GB
  • (D) TB
Show Answer & Explanation

Correct Answer: (B) KB

Explanation: KB (Kilobyte) is smaller than MB, GB, and TB in terms of storage capacity.

Question 3: A collection of 4 bits is known as:

  • (A) BYTE
  • (B) WORD
  • (C) NIBBLE
  • (D) K.BYTE
Show Answer & Explanation

Correct Answer: (C) NIBBLE

Explanation: A nibble consists of 4 bits. A byte is made up of 8 bits.

Question 4: While working on a computer, if we open a document in MS Word, which of the following is used?

  • (A) RAM
  • (B) ROM
  • (C) BIOS
  • (D) I/O BUS
Show Answer & Explanation

Correct Answer: (A) RAM

Explanation: RAM (Random Access Memory) is used for temporary data storage when a document is open in MS Word.

Question 5: Which of the following is not an operating system?

  • (A) UNIX
  • (B) WINDOWS
  • (C) ANDROID
  • (D) MS OFFICE
Show Answer & Explanation

Correct Answer: (D) MS OFFICE

Explanation: MS Office is an application software suite, not an operating system.

Question 6: What will be the result of the following Boolean expression?

NOT True OR False AND True

  • (A) False
  • (B) True
  • (C) Error in Expression
  • (D) No result
Show Answer & Explanation

Correct Answer: (B) True

Explanation: The Boolean expression follows operator precedence: NOT True = False, False AND True = False, then False OR False = False.

Question 7: Which Boolean expression is the correct interpretation of the following logic circuit?

  • (A) A + B.C
  • (B) (A + B).C
  • (C) A.B + C
  • (D) A + B + C
Show Answer & Explanation

Correct Answer: (A) A + B.C

Explanation: The logic circuit represents the Boolean expression A + (B AND C), which simplifies to A + B.C.

Question 8: Which of the following represents Absorption law correctly?

  • (A) X + Y.Z = (X + Y).(X + Z)
  • (B) X + X.Y = X
  • (C) (X + Y)’ = X’ Y’
  • (D) (X . X)’ = X’
Show Answer & Explanation

Correct Answer: (B) X + X.Y = X

Explanation: The Absorption Law in Boolean algebra states that X + X.Y simplifies to X.

Question 9: Which of the following represents the exact equivalent of the given binary number in Octal number? (101110001011)

  • (A) (232023)
  • (B) (A8A)
  • (C) (5613)
  • (D) (3165)
Show Answer & Explanation

Correct Answer: (C) (5613)

Explanation: Converting the binary number (101110001011)2 to octal by grouping into triplets, we get (5613)8.

Question 10: What is the full form of the ISCII encoding scheme?

  • (A) Indian Standard Code for Interchange of Information
  • (B) Indian Standard Code for Information Interchange
  • (C) Indian Standard Coding for Information in Interchange
  • (D) Indian Scheme of Coding for Information Interchange
Show Answer & Explanation

Correct Answer: (B) Indian Standard Code for Information Interchange

Explanation: ISCII stands for Indian Standard Code for Information Interchange, which is used for representing Indian languages.

Question 11: Which of the following cannot be registered under cybercrime?

  • (A) Sending pornographic material online
  • (B) Stealing of brand-new internet routers from a showroom
  • (C) Accessing CCTV camera of a private company without their knowledge
  • (D) Sending threats on social media accounts
Show Answer & Explanation

Correct Answer: (B) Stealing of brand-new internet routers from a showroom

Explanation: Cybercrime relates to illegal activities carried out using the internet or digital systems. Physical theft of hardware is not categorized under cybercrime.

Question 12: Which of the following is an example of a very strong password?

  • (A) STRONG
  • (B) Abc1234
  • (C) admin
  • (D) Ap9#2@cQ
Show Answer & Explanation

Correct Answer: (D) Ap9#2@cQ

Explanation: A strong password includes uppercase and lowercase letters, numbers, and special characters.

Question 13: Which protocol is used to upload and download files from remote servers?

  • (A) SMTP
  • (B) VoIP
  • (C) HTTP
  • (D) FTP
Show Answer & Explanation

Correct Answer: (D) FTP

Explanation: FTP (File Transfer Protocol) is used for uploading and downloading files from remote servers.

Question 14: What type of network is created when buildings are connected using CAT6 cables?

  • (A) PAN
  • (B) MAN
  • (C) LAN
  • (D) WAN
Show Answer & Explanation

Correct Answer: (C) LAN

Explanation: A Local Area Network (LAN) connects devices within a limited area such as buildings using wired connections like CAT6 cables.

Question 15: Which of the following is not a network device?

  • (A) Switch
  • (B) Router
  • (C) Hub
  • (D) RAM
Show Answer & Explanation

Correct Answer: (D) RAM

Explanation: RAM (Random Access Memory) is not a networking device; it is used for temporary data storage in a computer.

Question 16: Which of the following is an example of a DBMS?

  • (A) Windows
  • (B) Linux
  • (C) MySQL
  • (D) MS Paint
Show Answer & Explanation

Correct Answer: (C) MySQL

Explanation: MySQL is a database management system (DBMS) used for storing and managing data.

Question 17: What does CPU stand for?

  • (A) Central Processing Unit
  • (B) Central Printed Unit
  • (C) Core Processing Unit
  • (D) Computer Processing Unit
Show Answer & Explanation

Correct Answer: (A) Central Processing Unit

Explanation: The CPU (Central Processing Unit) is the brain of the computer that performs instructions from programs.

Question 18: Which of the following is not an operating system?

  • (A) Windows
  • (B) Linux
  • (C) Python
  • (D) macOS
Show Answer & Explanation

Correct Answer: (C) Python

Explanation: Python is a programming language, not an operating system.

Question 19: Which memory is volatile?

  • (A) ROM
  • (B) Hard Drive
  • (C) RAM
  • (D) SSD
Show Answer & Explanation

Correct Answer: (C) RAM

Explanation: RAM (Random Access Memory) is volatile, meaning it loses its data when power is turned off.

Question 20: What is the full form of URL?

  • (A) Uniform Resource Locator
  • (B) Unified Resource Link
  • (C) Universal Remote Link
  • (D) Uniform Record Locator
Show Answer & Explanation

Correct Answer: (A) Uniform Resource Locator

Explanation: A URL (Uniform Resource Locator) is the address of a resource on the internet.

Question 21: Which of the following is an invalid identifier in Python programming language?

  • (A) none
  • (B) False
  • (C) true
  • (D) For
Show Answer & Explanation

Correct Answer: (B) False

Explanation: ‘False’ is a reserved keyword in Python and cannot be used as an identifier.

Question 22: Which of the following is not a valid operator in Python?

  • (A) ==
  • (B) =>
  • (C) //
  • (D) **
Show Answer & Explanation

Correct Answer: (B) =>

Explanation: ‘=>’ is not a valid operator in Python, whereas ‘==’, ‘//’, and ‘**’ are valid.

Question 23: Identify the correct output of the following Python arithmetic expression:
1 + (2 – 3) * 4 ** 5 // 6

  • (A) -171
  • (B) 172
  • (C) -170
  • (D) 170
Show Answer & Explanation

Correct Answer: (C) -170

Explanation: The expression follows the order of operations (PEMDAS). The correct evaluation results in -170.

Question 24: Evaluate the following expression:
not True or not False and False

  • (A) True
  • (B) False
  • (C) None
  • (D) will generate an Error.
Show Answer & Explanation

Correct Answer: (A) True

Explanation: The expression is evaluated as follows: ‘not True’ is False, ‘not False’ is True, ‘True and False’ is False, ‘False or False’ is True.

Question 25: Identify the correct output of the following Python command:
print(10 or 40)

  • (A) 10
  • (B) 40
  • (C) 50
  • (D) 400
Show Answer & Explanation

Correct Answer: (A) 10

Explanation: The ‘or’ operator returns the first truthy value. Since 10 is truthy, it is returned.

Question 26: Identify the correct output of the following Python program segment?

Pi=3.141592
print(‘%d4f’ %Pi)

  • (A) 3.14
  • (B) 3.1415
  • (C) 3.1416
  • (D) 3.0000
Show Answer & Explanation

Correct Answer: (C) 3.1416

Explanation: The format specifier ‘%d4f’ is incorrect. Assuming it meant ‘%.4f’, the output would be rounded to 4 decimal places, resulting in 3.1416.

Question 27: Which of the following is an immutable data type in Python?

  • (A) Set
  • (B) List
  • (C) Tuple
  • (D) Dictionary
Show Answer & Explanation

Correct Answer: (C) Tuple

Explanation: Tuples in Python are immutable, meaning their values cannot be changed after creation.

Question 28: If we have 2 Python lists as follows:

List1=[10,20,30]
List2=[40,50,60]

If we want to generate a list List3 as
List3= [10,20,30,40,50,60]

Then the best Python command out of the following is:

  • (A) List3 = List1 + List2
  • (B) List3 = List1.append(List2)
  • (C) List3 = List1.update(List2)
  • (D) List3 = List1.extend(List2)
Show Answer & Explanation

Correct Answer: (A) List3 = List1 + List2

Explanation: The ‘+’ operator concatenates two lists, producing a new list that contains all elements of List1 followed by all elements of List2.

Question 29: Identify the correct output of the following Python code:

L=[3,3,2,2,1,1]
L.append(L.pop(L.pop()))
print(L)

  • (A) [3,2,2,1,3]
  • (B) [3,3,2,2,3]
  • (C) [1,3,2,2,1]
  • (D) [1,1,2,2,3,3]
Show Answer & Explanation

Correct Answer: (A) [3,2,2,1,3]

Explanation: The pop() function removes an element at a given index and returns it. The sequence of operations leads to appending the popped value at the last index.

Question 30: Identify the output of the Python command:

print(22.0/5)

  • (A) 4.4
  • (B) 4
  • (C) 4.0
  • (D) 2
Show Answer & Explanation

Correct Answer: (A) 4.4

Explanation: The ‘/’ operator in Python performs floating-point division. 22.0 divided by 5 results in 4.4.

Question 31: Find the output of the following Python code:

L1 = [1,4,3,2]
L2 = L1
L1.sort()
print(L2)

  • (A) [1,4,3,2]
  • (B) [1,2,3,4]
  • (C) 1 4 3 2
  • (D) 1 2 3 4
Show Answer & Explanation

Correct Answer: (B) [1,2,3,4]

Explanation: Since L2 is a reference to L1, sorting L1 also modifies L2.

Question 32: If PL is a Python list as follows:
PL = [‘Basic’, ‘C’, ‘C++’]
Then what will be the status of the list PL after PL.sort(reverse=True)?

  • (A) [‘Basic’,’C’,’C++’]
  • (B) [‘C++’,’C’,’Basic’]
  • (C) [‘C’,’C++’,’Basic’]
  • (D) [‘Basic’,’C++’,’C’]
Show Answer & Explanation

Correct Answer: (B) [‘C++’,’C’,’Basic’]

Explanation: The sort function with reverse=True arranges the list in descending order.

Question 33: Identify the correct output of the following Python program.

CHARR = [[‘A’,’B’],[‘C’,’D’],[‘E’,’F’]]
print(CHARR [1][1])

  • (A) ‘A’
  • (B) ‘B’
  • (C) ‘C’
  • (D) ‘D’
Show Answer & Explanation

Correct Answer: (D) ‘D’

Explanation: CHARR[1][1] accesses the second row and second column, which is ‘D’.

Question 34: The following Python list S is implemented as a stack.
S=[10, 12, 0, 4, 6]
If 10 is the element added (pushed) last into the stack S, which command from the following options is best to remove (pop) an element from the Stack S, if not empty?

  • (A) S.pop(0)
  • (B) S.pop()
  • (C) S.remove()
  • (D) S.remove(0)
Show Answer & Explanation

Correct Answer: (B) S.pop()

Explanation: The pop() function removes and returns the last element from a list, which follows the stack (LIFO) principle.

Question 35: Traditionally, the end of a stack from where PUSH (addition) and POP (deletion) take place is popularly known as:

  • (A) FRONT
  • (B) TOP
  • (C) LIFO
  • (D) FIFO
Show Answer & Explanation

Correct Answer: (B) TOP

Explanation: The top of the stack is the position where new elements are pushed and removed.

Question 36: Identify the correct output of the Python code:

L1 = [1,2,3]
L2 = [4,5]
L3 = [6,7]
L1.extend(L2)
L1.append(L3)
print(L1)

  • (A) [1,2,3,4,5,6,7]
  • (B) [1,2,3,[4,5],6,7]
  • (C) [1,2,3,4,5,[6,7]]
  • (D) [1,2,3,[4,5],[6,7]]
Show Answer & Explanation

Correct Answer: (C) [1,2,3,4,5,[6,7]]

Explanation: The extend() method adds elements from L2 to L1, while append() adds L3 as a single element.

Question 37: Identify the correct output of the Python code:

TUP = ([1, 2], [3, 4], [5, 6])
TUP[2][1] = 8
print(TUP)

  • (A) ([1, 2], [8, 4], [5, 6])
  • (B) ([1, 2], [3, 4], [8, 6])
  • (C) ([1, 2], [3, 4], [5, 8])
  • (D) will generate an error as a Tuple is immutable
Show Answer & Explanation

Correct Answer: (C) ([1, 2], [3, 4], [5, 8])

Explanation: While tuples are immutable, they can hold mutable objects like lists, allowing modification of their contents.

Question 38: Identify the output of the following Python program segment:

S = “Python Programming”
L = S.split()
S = “,”.join(L)
print(S)

  • (A) Python Programming
  • (B) Python, Programming
  • (C) ,Python Programming,
  • (D) ,Python, Programming,
Show Answer & Explanation

Correct Answer: (B) Python, Programming

Explanation: split() creates a list of words, and join() connects them using a comma.

Question 39: If S = “python language” is a Python string, which of the following commands will display “Python language”?

  • (A) print(S.upper())
  • (B) print(S.title())
  • (C) print(S.capitalize())
  • (D) print(S.sentence())
Show Answer & Explanation

Correct Answer: (C) print(S.capitalize())

Explanation: capitalize() converts only the first letter of the string to uppercase.

Question 40: Identify the correct output of the following Python Code:

Str = “Hello World! Hello India!”
Pos = Str.index(“Hello”)
print(Pos)

  • (A) 0
  • (B) 13
  • (C) [0, 13]
  • (D) (0, 13)
Show Answer & Explanation

Correct Answer: (A) 0

Explanation: index() returns the first occurrence of “Hello” in the string, which starts at index 0.

Question 41: If a List L=[‘Hello’, ‘World!’] Identify the correct output of the following Python command:
print(*L)

  • (A) Hello World!
  • (B) Hello, World!
  • (C) ‘Hello’, ‘World!’
  • (D) ‘Hello’ ‘ ‘World!’
Show Answer & Explanation

Correct Answer: (A) Hello World!

Explanation: The * operator unpacks the list elements when passed to print(), resulting in space-separated output.

Question 42: If Str is a Python string as
Str= “Hello World!”
What will be the output of the following Python Command?
print(Str.find(‘1’))

  • (A) 2
  • (B) 3
  • (C) [2, 3, 7]
  • (D) (2, 3, 7)
Show Answer & Explanation

Correct Answer: (B) 3

Explanation: The find() function returns the index of the first occurrence of the specified character. Since ‘1’ appears at index 3, the output is 3.

Question 43: Suppose a Python tuple TUP is declared as
TUP = (‘A’,’B’,’C’)
Which of the following command is invalid?

  • (A) TUP = (‘D’)
  • (B) TUP = (‘D’,)
  • (C) TUP += (‘D’)
  • (D) TUP += (‘D’,)
Show Answer & Explanation

Correct Answer: (A) TUP = (‘D’)

Explanation: In Python, writing ('D') without a comma creates a string, not a tuple. To define a tuple with one element, a trailing comma is required.

Question 44: Identify the correct output of the following Python code:
TUP = (3, 1, 2, 4)
sorted(TUP)
print(TUP)

  • (A) (3, 1, 2, 4)
  • (B) (1, 2, 3, 4)
  • (C) [3, 1, 2, 4]
  • (D) [1, 2, 3, 4]
Show Answer & Explanation

Correct Answer: (A) (3, 1, 2, 4)

Explanation: The sorted() function returns a new sorted list but does not modify the original tuple. Since the original tuple remains unchanged, the output is (3, 1, 2, 4).

Question 45: Find the correct output of the following Python program segment:
T=(‘1’)
print(T*3)

  • (A) 3
  • (B) (‘1′,’1′,’1’)
  • (C) 111
  • (D) (‘3’)
Show Answer & Explanation

Correct Answer: (C) 111

Explanation: Since T = ('1') is actually a string, not a tuple, multiplying it by 3 results in ‘111’.

Question 46: Select the correct output of the given Python code from the following options:

S = ‘INDIAN’
L=S.partition(‘N’)
NS = L[0]+’-‘+L[1]+’-‘+L[2]
print(NS)

  • (A) I – N – DIA – N –
  • (B) I – DIA –
  • (C) I – DIAN
  • (D) I – N – DIAN
Show Answer & Explanation

Correct Answer: (D) I – N – DIAN

Explanation: The partition() function splits the string at the first occurrence of ‘N’, keeping ‘N’ in the middle.

Question 47: To execute the following code in Python, which module needs to be imported?

print(mean([1, 2, 3]))

  • (A) math
  • (B) random
  • (C) statistics
  • (D) probability
Show Answer & Explanation

Correct Answer: (C) statistics

Explanation: The mean() function is available in the statistics module.

Question 48: If D is a Python dictionary as

D= {‘A’ : 1, ‘B’ : 2, ‘C’ : 3}

Then, which of the following command will remove the entire dictionary from memory?

  • (A) del(D)
  • (B) D.del()
  • (C) D.clear()
  • (D) D.remove()
Show Answer & Explanation

Correct Answer: (A) del(D)

Explanation: The del statement deletes the entire dictionary from memory.

Question 49: What will be the output of the following Python code?

D1 = {‘A’ : 5,’B’ : 7, ‘C’ : 9}
D2 = {‘B’ : 5, ‘D’ : 10}
D1.update(D2)
print(D1)

  • (A) {‘A’ : 5, ‘B’ : 5, ‘C’ : 9, ‘D’ : 10}
  • (B) {‘A’ : 5, ‘B’ : 5, ‘C’ : 9, ‘B’ : 5, ‘D’ : 10}
  • (C) {‘A’ : 5, ‘C’ : 9, ‘D’ : 10}
  • (D) {‘B’ : 7, ‘D’ : 10, ‘A’ : 5, ‘C’ : 9}
Show Answer & Explanation

Correct Answer: (A) {‘A’ : 5, ‘B’ : 5, ‘C’ : 9, ‘D’ : 10}

Explanation: The update() method updates the dictionary with key-value pairs from another dictionary, replacing existing keys.

Question 50: Select the output for the given Python code from the following options:

D1 = { 1 : 2, 2 : 3, 3 : 4 }
D2 = D1.get(1,2)
print(D2)

  • (A) 2
  • (B) 3
  • (C) [2,3]
  • (D) {1 : 2, 2 : 3 }
Show Answer & Explanation

Correct Answer: (A) 2

Explanation: The get() method returns the value associated with the key. Here, D1.get(1,2) fetches the value associated with key 1, which is 2.

Question 51:

Which of the following functions cannot be used with string (str) data type?

  • (A) islower()
  • (B) isupper()
  • (C) isalpha()
  • (D) isnum()
Show Answer & Explanation

Correct Answer: ✅ (D) isnum()

Explanation: The correct function name for checking numeric strings in Python is `isnumeric()`, not `isnum()`.

Question 52:

Examine the given Python program and select the purpose of the program from the following options:

N = int(input("Enter the number"))
for i in range(2, N):
    if (N % i == 0):
        print(i)
  • (A) to display the proper factors (excluding 1 and the number N itself)
  • (B) to check whether N is a prime or Not
  • (C) to calculate sum of factors of N
  • (D) to display all prime factors of the number N
Show Answer & Explanation

Correct Answer: ✅ (A) to display the proper factors (excluding 1 and the number N itself)

Explanation: The given program prints all divisors of N except 1 and N itself, which are the proper factors of N.

Question 53:

If A = random.randint(B, C) assigns a random value between 1 and 6 (both inclusive) to the identifier A, what should be the values of B and C, if all required modules have already been imported?

  • (A) B = 0, C = 6
  • (B) B = 0, C = 7
  • (C) B = 1, C = 7
  • (D) B = 1, C = 6
Show Answer & Explanation

Correct Answer: ✅ (D) B = 1, C = 6

Explanation: The function `random.randint(B, C)` generates a random integer between B and C (both inclusive). To ensure A is between 1 and 6, we set B = 1 and C = 6.

Question 54:

Identify the correct output of the following Python code:

from math import *
A = 5.6
print(floor(A), ceil(A))
  • (A) 5 6
  • (B) 6 5
  • (C) -5 -6
  • (D) -6 -5
Show Answer & Explanation

Correct Answer: ✅ (A) 5 6

Explanation: – `floor(5.6)` returns 5 (rounds down to the nearest integer). – `ceil(5.6)` returns 6 (rounds up to the nearest integer).

Question 55:

Identify the correct output of the following Python program segment:

import math
print(math.fabs(-10))
  • (A) 1
  • (B) -10
  • (C) -10.0
  • (D) 10
Show Answer & Explanation

Correct Answer: ✅ (D) 10

Explanation: – `math.fabs(-10)` returns the absolute value of -10 as a floating-point number. – The correct output is `10.0`, but since the option `10` is given, that is the correct choice.

Question 56:

Consider the given Python program and identify one possible output from the following options:

from random import *
Low = randint(2, 3)
High = randrange(5, 7)
for N in range(Low, High):
    print(N, end=' ')
  • (A) 3 4 5
  • (B) 2 3
  • (C) 4 5
  • (D) 3 4 5 6
Show Answer & Explanation

Correct Answer: ✅ (A) 3 4 5

Explanation: – `randint(2,3)` randomly selects either 2 or 3 for `Low`. – `randrange(5,7)` randomly selects either 5 or 6 for `High`. – If `Low = 3` and `High = 6`, the range would be `3, 4, 5`.

Question 57:

Assuming all required modules have already been imported, identify the correct output of the following Python program segment:

Data = [4, 4, 1, 2, 4]
print(mean(Data), mode(Data))
  • (A) 1 4
  • (B) 2 1
  • (C) 3 4
  • (D) 4 3
Show Answer & Explanation

Correct Answer: ✅ (C) 3 4

Explanation: – The mean (average) is calculated as: \( (4+4+1+2+4) / 5 = 3.0 \) (rounded to 3). – The mode (most frequently occurring value) is `4` (as it appears 3 times).

Question 58:

Observe the Python code carefully and answer the following question:

def FUN(A):
    L = []
    for i in range(2, A):
        if (A % i == 0):
            L.append(i)
    print(L)

N = 10
FUN(N)

Identify the global identifier in the above code:

  • (A) A
  • (B) L
  • (C) i
  • (D) N
Show Answer & Explanation

Correct Answer: ✅ (D) N

Explanation: – In Python, an identifier is global if it is declared outside of any function. – `A` is a parameter of the function `FUN`, making it a local variable. – `L` is defined inside `FUN`, making it local. – `i` is a loop variable within `FUN`, making it local. – `N` is defined outside of `FUN`, making it a global identifier.

Question 59:

Observe the following Python program carefully.

import random

def DICE(Low=1, High=6):
    RND = random.randint(Low, High)
    print(RND, end=' ')

DICE()
DICE(2)
DICE(2,4)

Which of the following options cannot be an output of the above code?

  • (A) 4 3 3
  • (B) 4 1 3
  • (C) 3 5 4
  • (D) 6 4 3
Show Answer & Explanation

Correct Answer: ✅ (C) 3 5 4

Explanation: – The function DICE() is called three times. – DICE() uses the default values Low=1 and High=6, meaning it returns a random number between 1 and 6. – DICE(2) sets Low=2, but High remains 6 (default). So it returns a number between 2 and 6. – DICE(2,4) sets Low=2 and High=4, so it returns a number between 2 and 4. – The number 5 cannot appear in the third call (DICE(2,4)), making option (C) invalid.

Question 60:

Identify the output of the following Python code:

def EXP(N2):
    global N1
    N1, N2 = N1 + 5, N2 + 10
    print(N1, N2, end=' ')

N1 = 10
EXP(N1)
print(N1)
  • (A) 10 20 15
  • (B) 15 20 10
  • (C) 15 20 15
  • (D) 10 20 10
Show Answer & Explanation

Correct Answer: ✅ (C) 15 20 15

Explanation: – The global variable N1 is modified inside the function EXP. – Initially, N1 = 10. – Inside EXP(N1), N1 is updated to 10 + 5 = 15, and N2 (passed as 10) is updated to 10 + 10 = 20. – The function prints: 15 20. – Outside the function, print(N1) prints 15, as N1 was modified inside EXP.

Question 61:

Which of the following modes, when used in the file opening statement in Python, generates an error if the file does not exist?

  • (A) a+
  • (B) r+
  • (C) w+
  • (D) a
Show Answer & Explanation

Correct Answer: ✅ (B) r+

Explanation: – The mode r+ (read and write) requires the file to exist. If the file does not exist, it raises a FileNotFoundError. – The a+ (append and read) and a (append) modes create the file if it does not exist. – The w+ (write and read) mode also creates a new file if it does not exist.

Question 61:

Which of the following modes, when used in the file opening statement in Python, generates an error if the file does not exist?

  • (A) a+
  • (B) r+
  • (C) w+
  • (D) a
Show Answer & Explanation

Correct Answer: ✅ (B) r+

Explanation: – The mode r+ (read and write) requires the file to exist. If the file does not exist, it raises a FileNotFoundError. – The a+ (append and read) and a (append) modes create the file if it does not exist. – The w+ (write and read) mode also creates a new file if it does not exist.

Question 62:

Consider the following Python command:

File = open('Myfile', 'a')

Which of the following option cannot be true?

  • (A) ‘Myfile’ can be a text file
  • (B) ‘Myfile’ can be a csv file
  • (C) ‘Myfile’ can be a binary file
  • (D) ‘Myfile’ will be created if not exist
Show Answer & Explanation

Correct Answer: ✅ (C) ‘Myfile’ can be a binary file

Explanation: – The mode 'a' (append mode) is for text files by default. – If a binary file is intended, the mode should be 'ab' instead of 'a'. – CSV files are still text-based and can be opened in 'a' mode. – If the file does not exist, it will be created.

Question 63:

Which of the following is not true for the Python command:

File = open('story.txt', 'a+')
  • (A) More text can be written into ‘story.txt’
  • (B) Content of the file ‘story.txt’ can be read.
  • (C) Content of the file ‘story.txt’ can be modified.
  • (D) Command generates an error, if the file ‘story.txt’ does not exist.
Show Answer & Explanation

Correct Answer: ✅ (D) Command generates an error, if the file ‘story.txt’ does not exist.

Explanation: – The 'a+' mode allows both appending and reading. – If the file does not exist, it is automatically created. – Therefore, option (D) is false, as no error is generated if the file is missing.

Question 64:

Consider the following Python program segment:

File = open('Poem.txt', 'r')
T = File.readline()

Identify the data type of T:

  • (A) String (str)
  • (B) List
  • (C) Tuple
  • (D) Dictionary
Show Answer & Explanation

Correct Answer: ✅ (A) String (str)

Explanation: – The readline() function reads a single line from the file as a string. – The returned value is always of type str, even if the line contains numbers or special characters.

Question 65:

Name the Python module that needs to be imported to invoke the function?

  • (A) csv
  • (B) pickle
  • (C) sql
  • (D) binary
Show Answer & Explanation

Correct Answer: ✅ (B) pickle

Explanation: – The pickle module is used for serializing and deserializing Python objects. – If a function related to object serialization is being referred to, the correct answer is pickle. – The csv module is used for reading and writing CSV files. – The sql option is incorrect as Python uses the sqlite3 module for SQL operations. – There is no built-in module named binary in Python.

Question 66:

Examine the given Python program and select the purpose of the program from the following options:

F = open('story.txt', 'r+')
S = F.read()
S = S.upper()
F.seek(0)
F.write(S)
F.close()

What is the purpose of this program?

  • (A) To count the uppercase alphabets present in the file
  • (B) To convert all alphabets into uppercase in the file
  • (C) To copy only the uppercase alphabets from the file
  • (D) To remove all lowercase alphabets from the file
Show Answer & Explanation

Correct Answer: ✅ (B) To convert all alphabets into uppercase in the file

Explanation: – The program reads the content of the file story.txt and stores it in S. – The function upper() converts all characters in S to uppercase. – seek(0) moves the file pointer to the beginning of the file. – write(S) writes the modified content back to the file. – Thus, the entire content of the file is converted to uppercase.

Question 67:

The seek() method is a method of which object/module?

  • (A) csv module
  • (B) pickle module
  • (C) text module
  • (D) file object
Show Answer & Explanation

Correct Answer: ✅ (D) file object

Explanation: – The seek() method is used to move the file pointer to a specific position in a file. – It is a method of the file object in Python. – The csv and pickle modules do not have a seek() method. – The text module does not exist in standard Python.

Question 68:

The csv module needs to be imported in a program to invoke or use which function?

  • (A) write()
  • (B) writerow()
  • (C) writeline()
  • (D) writelines()
Show Answer & Explanation

Correct Answer: ✅ (B) writerow()

Explanation: – The writerow() function belongs to the csv.writer object. – It is used to write a single row to a CSV file. – The other options (write(), writeline(), writelines()) belong to the standard file object in Python.

Question 69:

Examine the given Python program and select the best purpose of the program from the given options:

File = open("Poem.txt", "r")
print(len(File.readline().split()))
File.close()
  • (A) To count the number of words present in the file
  • (B) To count the number of lines present in the file
  • (C) To count the number of characters present in the file
  • (D) To count the number of words present in the first line of the file
Show Answer & Explanation

Correct Answer: ✅ (D) To count the number of words present in the first line of the file

Explanation:readline() reads only the first line from the file. – split() breaks the line into words. – len() counts the number of words in that line. – Therefore, the program counts the words in the first line, not the entire file.

Question 70:

CSV files are comma-separated values saved as a ________.

  • (A) text file
  • (B) binary file
  • (C) MySQL table
  • (D) random file
Show Answer & Explanation

Correct Answer: ✅ (A) text file

Explanation: – CSV files are stored as plain text where values are separated by commas. – They can be opened with any text editor. – They are not binary files, MySQL tables, or random files.

Question 71:

The creator of the open-source Pandas package for data analysis in the Python programming language was ________.

  • (A) Wes McKinney
  • (B) Mc Pandas
  • (C) John D. Hunter
  • (D) Travis Oliphant
Show Answer & Explanation

Correct Answer: ✅ (A) Wes McKinney

Explanation: – Wes McKinney created the Pandas library in 2008 while working at AQR Capital Management. – John D. Hunter created Matplotlib, and Travis Oliphant was a key contributor to NumPy and SciPy.

Question 72:

Which of the following is not a bundled package with Pandas?

  • (A) Six
  • (B) NumPy
  • (C) Pytz
  • (D) Statistics
Show Answer & Explanation

Correct Answer: ✅ (D) Statistics

Explanation: – Pandas depends on external libraries like NumPy and Pytz. – The six module was used for Python 2 and 3 compatibility. – The statistics module is a built-in Python module, not a dependency of Pandas.

Question 73:

Which of the following is equivalent to the and operator while using Boolean indexing on DataFrames?

  • (A) &&
  • (B) @
  • (C) &
  • (D) N
Show Answer & Explanation

Correct Answer: ✅ (C) &

Explanation: – In Pandas Boolean indexing, & is used instead of and. – The and operator does not work directly with Pandas series. – Similarly, && is not a valid operator in Python.

Question 74:

Find the output of the following Python code:

import Pandas as pd
M = pd.series({‘P’ : 10, ‘Q’ : 90})
print(M)
  • (A) P Q
    10 90
  • (B) P 10
    Q 90
  • (C) 0 P 10
    1 Q 90
  • (D) 10 P
    90 Q
Show Answer & Explanation

Correct Answer: ✅ (B) P 10
Q 90

Explanation:
– The pd.Series function creates a Pandas Series object with labeled indices.
– When printed, a Pandas Series displays the index on the left and values on the right.
– The output is:

P    10
Q    90
dtype: int64
  
– This matches option (B).

76. Fill in the blanks with an appropriate command from the given options to produce the output shown on the right side of the following code:

  1. D = pd.DataFrame(D, columns = A, index = B)
  2. D = pd.DataFrame(D, rows = B, columns = A)
  3. D = pd.DataFrame(D, B, i = A)
  4. D = pd.DataFrame(A, B, D )
Show Answer & Explanation Correct Answer:

Option 1: D = pd.DataFrame(D, columns=A, index=B)

Explanation:
  • In Pandas, a DataFrame can be created using lists and assigned column names and index labels using columns and index parameters.
  • pd.DataFrame(D, columns=A, index=B) correctly assigns:
    • A1, A2 as column names.
    • B1, B2 as row indices.
  • Other options use incorrect parameters (e.g., rows does not exist in pd.DataFrame).

77. What will be the output of the following Python code?
import numpy as np
B= np.array([20, 50, 80, 30])
print(B, B.size, B.shape)

  1. (20, 50, 80, 30) 4, (4,)
  2. [20, 50, 80, 30] 4, (4,)
  3. (20, 50, 80, 30) (4,) 4
  4. [20, 50, 80, 30] (4,) 4

78. Which of the following will help us to read the content of a CSV file ITEMS.CSV as pandas DataFrame ?

  1. IT-pandas.read(“ITEMS.CSV”)
  2. IT pandas.readcsv(“ITEMS.CSV”)
  3. IT-pandas.csv_read(“ITEMS.CSV”)
  4. IT-pandas.read_csv(“ITEMS.CSV”)

79. Consider the following import command:
import matplotlib.pyplot as PLT
Which of the following command will help us to draw a line chart for given values?

  1. PLT.line plot([100, 400, 200, 300])
  2. PLT.plotline([100, 400, 200, 300])
  3. PLT line([100, 400, 200, 300])
  4. PLT.plot([100, 400, 200, 300])

80. Which of the following is DDL command ?

  1. UPDATE SET
  2. DELETE
  3. DROP TABLE
  4. INSERT INTO

81. Which of the following is DML command ?

  1. INSERT INTO
  2. DROP TABLE
  3. CREATE TABLE
  4. ALTER TABLE

82. An attribute or a set of attribute which are used to identify a tuple uniquely is known as :

  1. Primary Key
  2. Foreign Key
  3. Alternate Key
  4. Candidate Key

83. Which of the following is not a valid relational operator used in SQL ?

  1. <=
  2. <>
  3. =>
  4. =

84. Which of the following is using wrong syntax for a SELECT query in SQL?

  1. SELECT * WHERE RNO>100 FROM STUDENT;
  2. SELECT * FROM STUDENT WHERE RNO>100;
  3. SELECT * FROM STUDENT WHERE RNO BETWEEN 100 AND 200;
  4. SELECT * FROM STUDENT WHERE RNO IN (100,101,105,104);

85. Which of the following will be the correct SQL command to add a new column FEES in a table TEACHER ?

  1. ALTER TABLE TEACHER
    ADD COLUMN FEES FLOAT;
  2. ADD COLUMN FEES FLOAT
    INTO TEACHER;
  3. UPDATE TEACHER
    ADD COLUMN FEES FLOAT;
  4. INSERT INTO TEACHER
    ADD COLUMN FESS FLOAT;

86. Which of the following will display a list of tables in a database ?

  1. DISPLAY TABLES;
  2. SHOW TALES;
  3. SELECT TABLES;
  4. VIEW TABLES;

87. Which of the following will display information about all the employees from employee table, whose names contains second letter as “A” ?

  1. SELECT * FROM EMPLOYEE WHERE NAME LIKE “_A%”;
  2. SELECT * FROM EMPLOYEE WHERE NAME LIKE “%A_”;
  3. SELECT * FROM EMPLOYEE WHERE NAME LIKE “_ _ A%”;
  4. SELECT * FROM EMPLOYEE WHERE NAME = “_A%”;

88. Which of the following SQL command will help in incrementing values of FEES column in STUDENT table by 10% ?

  1. UPDATE STUDENT ASSIGN FEES = FEES * 1.1;
  2. UPDATE STUDENT SET FEES = FEES * 1.1;
  3. UPDATE STUDENT SET FEES = FEES * 10%;
  4. UPDATE STUDENT SET FEES 10%;

89. Which of the following is correct sequence in a SELECT query ?

  1. SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY
  2. SELECT, WHERE, FROM, GROUP BY, HAVING, ORDER BY
  3. SELECT, FROM, WHERE, HAVING, GROUP BY, ORDER BY
  4. SELECT, FROM, WHERE, GROUP BY, ORDER BY, HAVING

90. Consider the following tables and their respective degrees and cardinalities in a database called SCHOOL :

Select the degree and cardinality of the cartesian product of the tables STUDENT x TEACHER from the following options :

  1. 30 7500
  2. 200 325
  3. 30 325
  4. 200 7500

91. Which of the following set of functions is a valid set of aggregate functions in MySQL ?

  1. AVG(), ROUND(), COUNT()
  2. MIN(), UPPER(), AVG()
  3. COUNT(), MAX(), SUM()
  4. DATE(), COUNT(), LTRIM()

92. Find the output of the MySQL query based on the given Table-COACH (ignore the output header)

Query :
SELECT COUNT(GAME), AVG(SALARY) FROM COACH;

  1. 3 70000
  2. 4 35000
  3. 4 70000
  4. 3 35000

93. Find the output of the MySQL query based on the given Table – STUDENT (ignore the output header)

Query :
SELECT SEC, AVG (MARKS) FROM STUDENT GROUP BY SEC HAVING MIN (MARKS) > 80;

  1. B 83
  2. A 84
  3. A 84
    B 83
  4. A 83
    B 80

94. Consider the following tables in a database called SPORTS.
Database : SPORTS

Which is the best command from the following options to display the name of the player (PNAME) and their respective games (GNAME)

  1. SELECT PNAME, GID FROM PLAYERS ;
  2. SELECT PNAME, GAME FROM GAMES, PLAYERS
    WHERE GAMES.GID = PLAYERS.G1D ;
  3. SELECT PNAME, GNAME FROM GAMES, PLAYERS;
  4. SELECT PNAME, GNAME FROM GAMES, PLAYERS
    WHERE P.GID = G.GID;

95. Following are the two tables in a MySQL database.
Database : COMPARTMENT

Select the command from the following option to display subjects (SUBNAME) and number of students registered in that subject in table RESULT.

  1. SELECT SUBNAME, COUNT(*)
    FROM SUBJECTS, RESULT GROUP BY SUBNAME ;
  2. SELECT SUBNAME, COUNT(*)
    FROM SUBJECTS, RESULT ORDER B SUBNAME;
  3. SELECT SUBNAME, COUNT(*)
    FROM SUBJECTS NATURAL JOIN RESULT ORDER BY SUBNAME;
  4. SELECT SUBNAME, COUNT(*)
    FROM SUBJECTS NATURAL JOIN RESULT GROUP BY SUBNAME;

96. To establish the Python-MySQL connection, connect() methods is used with certain parameters or arguments. Which of the following is not a parameter / argument used with connect() method ?

  1. user
  2. password
  3. database
  4. table

97. commit( ) is required to be used after the execution of certain queries in Python-MySQL connectivity applications. Identify one such MySQL command out of the following options :

  1. CREATE
  2. INSERT
  3. SELECT
  4. DROP

98. While working on Python-MySQL connectivity, fetchall( ) method is used to get data from table. The method fetchall( ) returns –

  1. a list
  2. a tuple
  3. tuple of lists
  4. list of tuples

99. The method cursor( ) is used in Python-MySQL connectivity applications. This method is a member of :

  1. sql module
  2. pickle module
  3. database-connectivity module
  4. csv module

100. Which of the following clause is used with SELECT command in MySQL to avoid duplication of output rows.

  1. NO DUPLICATE
  2. UNIQUE
  3. DISTINCT
  4. NO REPEAT

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top