🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

O Level Python Paper July 2022 | Set 1

Question: 2 Report Error

आउटपुट निर्धारित करें:

Determine the output :

for i in range(20,30,10) :
      j=i/2
      print(j)
A)
B)
C)
D)
Explanation

Let's break down the code:

for i in range(20, 30, 10):
    j = i / 2
    print(j)

Explanation:

  • range(20, 30, 10) generates numbers starting from 20, ending before 30, with a step of 10.

    • This will generate the numbers: 20 and 30, but since the range is exclusive of 30, the loop will only run for i = 20.
  • Inside the loop:

    • For i = 20, j = i / 2, so j = 20 / 2 = 10.0.
  • print(j) will print 10.0.

Output:

(C) 10.0

Correct Answer: C) 10.0


Question: 3 Report Error

निम्नलिखित का आउटपुट क्या होगा?

What will be the output of the following ?

import numpy as np
print(np.minimum([2, 3, 4], [1, 5, 2]))
A)
B)
C)
D)
Explanation

Let's analyze the given code:

import numpy as np
print(np.minimum([2, 3, 4], [1, 5, 2]))

Explanation:

  • np.minimum(a, b) compares two arrays element-wise and returns a new array containing the smaller value for each corresponding pair of elements.
  • In this case, we have two lists:
    • [2, 3, 4]
    • [1, 5, 2]

Comparing elements:

  • min(2, 1)1
  • min(3, 5)3
  • min(4, 2)2

So, the result is [1, 3, 2].

Output:

(D) [1 3 2]

Correct Answer: D) [1 3 2]


Question: 5 Report Error

निम्नलिखित कोड का परिणाम क्या है ?

What is the output of the following code ?

print(bool(0), bool(3.14159), bool(3), bool(1.0+1j))
A)
B)
C)
D)
Explanation

Let's break down the code:

print(bool(0), bool(3.14159), bool(3), bool(1.0+1j))

Explanation:

  • bool(0): In Python, 0 is considered a falsy value, so bool(0) is False.
  • bool(3.14159): Any non-zero number (including floats like 3.14159) is considered truthy, so bool(3.14159) is True.
  • bool(3): Similarly, any non-zero integer is considered truthy, so bool(3) is True.
  • bool(1.0 + 1j): A non-zero complex number (like 1.0 + 1j) is also considered truthy, so bool(1.0 + 1j) is True.

Output:

(D) False True True True

Correct Answer: D) False True True True


Question: 6 Report Error

निम्नलिखित पायथन कोड का आउटपुट क्या होगा?

What will be the output of the following Python code ?

def C2F(c) :
        return c*9/5+32
print (C2F(100))
print (C2F(0))
A)
B)
C)
D)
Explanation

Let's analyze the given Python code:

def C2F(c):
    return c * 9 / 5 + 32

print(C2F(100))
print(C2F(0))

Explanation:

  • The function C2F(c) converts Celsius to Fahrenheit using the formula:

    F=(95×C)+32F = \left( \frac{9}{5} \times C \right) + 32
  • For C2F(100):

    • Substituting c = 100 into the formula: F=(95×100)+32=180+32=212.0F = \left( \frac{9}{5} \times 100 \right) + 32 = 180 + 32 = 212.0
    • So, C2F(100) returns 212.0.
  • For C2F(0):

    • Substituting c = 0 into the formula: F=(95×0)+32=0+32=32.0F = \left( \frac{9}{5} \times 0 \right) + 32 = 0 + 32 = 32.0
    • So, C2F(0) returns 32.0.

Output:

(A) 212.0 32.0

Correct Answer: A) 212.0 32.0


Question: 8 Report Error

निम्नलिखित में से कौन सा कथन अंतिम रूप से निष्पादित होगा?

Which of the following statement will execute in last ?

def s(n1): #Statement 1
         print(n1) #Statement 2
n2=4 #Statement 3
s(n2) #Statement 4
A)
B)
C)
D)
Explanation

Let's analyze the given code step by step:

def s(n1):   # Statement 1
    print(n1)  # Statement 2
n2 = 4  # Statement 3
s(n2)  # Statement 4

Execution Order:

  1. Statement 1: The function s(n1) is defined. This statement does not execute anything immediately; it only defines the function.
  2. Statement 3: n2 = 4 assigns the value 4 to n2. This is a regular assignment statement.
  3. Statement 4: s(n2) calls the function s() with n2 (which is 4). This triggers the execution of the function, so the next statement to execute is inside the function.
  4. Statement 2: Inside the function, print(n1) is executed, printing the value of n1, which is 4.

Conclusion:

The last statement to be executed is Statement 2, because it's inside the function s() and runs when the function is called in Statement 4.

Answer:

(B) Statement 2

Correct Answer: B) Statement 2


Question: 10 Report Error

निम्नलिखित का आउटपुट क्या है?

What is the output of the following ?

x = 'abcd'
for i in range(len(x)) :
             i.upper()
print (x)
A)
B)
C)
D)

Question: 12 Report Error

निम्नलिखित कोड के लिए आउटपुट क्या होगा?

What will be output for the following code ?

import numpy as np
a = np.array([1,2,1,5,8])
b = np.array([0,1,5,4,2])
c = a + b
c = c*a
print (c[2])
A)
B)
D)
Explanation

Let's break down the code step by step:

import numpy as np

a = np.array([1, 2, 1, 5, 8])
b = np.array([0, 1, 5, 4, 2])

c = a + b  # Element-wise addition of a and b
c = c * a  # Element-wise multiplication of c and a

print(c[2])  # Print the third element of array c

Step-by-Step Explanation:

  1. a and b arrays:

    • a = np.array([1, 2, 1, 5, 8])
    • b = np.array([0, 1, 5, 4, 2])
  2. c = a + b:

    • Element-wise addition of a and b:
    c = [1+0, 2+1, 1+5, 5+4, 8+2]
    c = [1, 3, 6, 9, 10]
    
  3. c = c * a:

    • Element-wise multiplication of c and a:
    c = [1*1, 3*2, 6*1, 9*5, 10*8]
    c = [1, 6, 6, 45, 80]
    
  4. print(c[2]):

    • The third element (index 2) of the array c is 6.

Output:

(A) 6

Correct Answer: A) 6


Question: 13 Report Error

नीचे दिए गए प्रोग्राम का आउटपुट क्या है?

What is the output of the below program ?

def func(a, b=5, c=10) :
      print('a is', a, 'and b is', b, 'and c is', c)
func(3, 7)
func(25, c = 24)
func(c = 50, a = 100)
A)
B)
C)
D)
Explanation

Here’s a simple breakdown of the code:

  1. func(3, 7):

    • a = 3, b = 7 (overrides default 5), c = 10 (default).
    • Output: a is 3 and b is 7 and c is 10
  2. func(25, c = 24):

    • a = 25, b = 5 (default), c = 24 (overrides default).
    • Output: a is 25 and b is 5 and c is 24
  3. func(c = 50, a = 100):

    • a = 100, b = 5 (default), c = 50 (overrides default).
    • Output: a is 100 and b is 5 and c is 50

Final Output:

(C) a is 3 and b is 7 and c is 10 a is 25 and b is 5 and c is 24 a is 100 and b is 5 and c is 50

Correct Answer: C) a is 3 and b is 7 and c is 10 a is 25 and b is 5 and c is 24 a is 100 and b is 5 and c is 50


Question: 15 Report Error

सीएसवी का फुल फॉर्म क्या है?

What is full form of CSV ?

A)
B)
C)
D)

Question: 17 Report Error

निम्नलिखित पायथन कोड का आउटपुट क्या होगा?

What will be the output of the following Python code ?

x = 50
def func(x):
         print('x is', x)
         x = 2
         print('Changed local x to', x)
func(x)
print('x is now', x)
A)
B)
C)
D)
Explanation

Let's break down the code step by step:

x = 50  # Global variable x

def func(x):
    print('x is', x)  # Prints the value of x passed to the function
    x = 2  # Local variable x is changed inside the function
    print('Changed local x to', x)  # Prints the new value of the local x

func(x)  # Calls the function with the global x (which is 50)
print('x is now', x)  # Prints the global x

Explanation:

  1. x = 50: This sets the global variable x to 50.

  2. Function Call: func(x):

    • The function is called with the global x (which is 50).
    • Inside the function:
      • The first print('x is', x) prints the value of the parameter x (which is 50).
      • The local x is changed to 2 (this does not affect the global x).
      • The second print('Changed local x to', x) prints the new value of the local x (which is 2).
  3. print('x is now', x):

    • After the function call, it prints the global x, which remains unchanged at 50, because the local change to x inside the function does not affect the global variable.

Final Output:

x is 50
Changed local x to 2
x is now 50

Answer:

(A) x is 50 Changed local x to 2 x is now 50

Correct Answer: A) x is 50 Changed local x to 2 x is now 50


Question: 18 Report Error

कथन 3 के लिए उत्तर चुनें.

Choose the answer for statement 3.

import ___________ # statement 1
rec = [ ]
while True:
      rn = int(input("Enter"))
      nm = input("Enter")
      temp = [rn, nm]
      rec.append(temp)
      ch = input("Enter choice (Y/N)")
      if ch.upper == "N":
           break
f = open("stud.dat", "____________") #statement 2
__________ .dump(rec, f) #statement 3
_______.close( ) # statement 4
A)
B)
C)
D)
Explanation

Let's break down the code and identify the correct answer for Statement 3:

Given code structure:

import ___________ # statement 1
rec = [ ]
while True:
      rn = int(input("Enter"))
      nm = input("Enter")
      temp = [rn, nm]
      rec.append(temp)
      ch = input("Enter choice (Y/N)")
      if ch.upper == "N":
           break
f = open("stud.dat", "____________") # statement 2
__________ .dump(rec, f) # statement 3
_______.close( ) # statement 4

Explanation:

  1. import ___________ (Statement 1):

    • The module needed for pickling (saving data to a file) in Python is pickle.

    So, the correct module to import is pickle.

  2. f = open("stud.dat", "____________") (Statement 2):

    • This line is opening a file stud.dat in write mode. Since we're using pickle to save the data, the correct mode would be "wb" (write binary mode).
    • So, the correct fill for this statement would be "wb".
  3. __________ .dump(rec, f) (Statement 3):

    • The correct method to save data to a file using pickle is pickle.dump().
    • So, pickle.dump(rec, f) would serialize and save the rec list to the file f.
  4. _______.close() (Statement 4):

    • This closes the file f, so f.close() is used here.

Conclusion:

For Statement 3, the correct answer is pickle.dump().

Answer:

(B) pickle

Correct Answer: B) pickle


Question: 19 Report Error

निम्नलिखित छद्म कोड का आउटपुट क्या होगा?

What will be the output of the following pseudo-code ?

Integer a
Set a = 5
do
   print a - 2
              a = a- 1
while (a not equals 0)
end while
A)
B)
C)
D)
Explanation

Let's break it down quickly:

  1. Initial value: a = 5.
  2. In each loop iteration:
    • Prints a - 2.
    • Decreases a by 1.
  3. The loop stops when a becomes 0.

Iterations:

  • First: prints 5 - 2 = 3, a becomes 4.
  • Second: prints 4 - 2 = 2, a becomes 3.
  • Third: prints 3 - 2 = 1, a becomes 2.
  • Fourth: prints 2 - 2 = 0, a becomes 1.
  • Fifth: prints 1 - 2 = -1, a becomes 0.

The loop stops when a = 0.

Output:

3 2 1 0 -1

So the correct answer is:
(D) None of these

Correct Answer: B) 3 0


Question: 22 Report Error

रिक्त स्थान को भरें।

Fill in the blank.

import pickle
f=open(“data.dat”,"rb")
d=_____________.load(f)
f.close()
A)
B)
C)
D)
Explanation

The correct function to read a serialized object from a file using the pickle module is pickle.load().

Explanation:

  • pickle.load(f): This is used to load the data that was serialized and stored in a file (in this case, data.dat).

Answer:

(C) pickle

Correct Answer: C) pickle


Question: 24 Report Error

कौन सा कथन फ़ाइल पॉइंटर को वर्तमान स्थिति से 10 बाइट्स पीछे ले जाएगा?

Which statement will move file pointer 10 bytes backward from current position ?

A)
B)
C)
D)
Explanation

To move the file pointer 10 bytes backward from its current position, we need to use the seek() method in the following way:

  • f.seek(offset, whence):
    • offset: The number of bytes to move the file pointer.
    • whence: The reference point for the offset.
      • 0: Start of the file (absolute positioning).
      • 1: Current position (relative to the current position).
      • 2: End of the file (relative to the end of the file).

To move the pointer backwards by 10 bytes, we use:

  • offset = -10 (to move backward)
  • whence = 1 (relative to the current position)

Correct statement:

(B) f.seek(-10,1)

This will move the file pointer 10 bytes backward from its current position.

Answer:

(B) f.seek(-10,1)

Correct Answer: B) f.seek(-10,1)


Question: 27 Report Error

निम्नलिखित लाइन को कार्यात्मक बनाने के लिए कौन सा मॉड्यूल आयात किया जाना चाहिए?

Which module to be imported to make the following line functional ?

sys.stdout.write(“ABC”)
A)
B)
C)
D)
Explanation

The correct module to import for using sys.stdout.write() is the sys module. This module provides access to some variables used or maintained by the interpreter, including stdout, which is used for writing output.

Correct answer:

(D) sys

Correct Answer: D) sys


Question: 28 Report Error

निम्नलिखित कोड का आउटपुट क्या होगा?

What will be the output of following code ?

import math
abs(math.sqrt(36))
A)
B)
C)
D)
Explanation

Let's break down the code:

import math
abs(math.sqrt(36))

Step-by-step explanation:

  1. math.sqrt(36):

    • This calculates the square root of 36, which is 6.0. In Python, math.sqrt() always returns a float value.
  2. abs():

    • The abs() function returns the absolute value of a number.
    • Since 6.0 is already positive, abs(6.0) will simply return 6.0.

Conclusion:

The output will be 6.0.

Answer:

(D) 6.0

Correct Answer: D) 6.0


Question: 29 Report Error

निम्नलिखित कोड का आउटपुट क्या है?

What is the output of following code ?

a=set('abc')
b=set('cd')
print(a^b)
A)
B)
C)
D)
Explanation

Let's break down the code:

a = set('abc')  # Converts string 'abc' to a set: {'a', 'b', 'c'}
b = set('cd')   # Converts string 'cd' to a set: {'c', 'd'}
print(a ^ b)     # The symmetric difference between sets a and b

Explanation:

  • Set a is {'a', 'b', 'c'}.
  • Set b is {'c', 'd'}.
  • a ^ b is the symmetric difference of sets a and b, which includes all elements that are in either a or b but not in both.

The elements that are in either a or b but not both are:

  • 'a' and 'b' from set a.
  • 'd' from set b.

So, the result of a ^ b will be {'a', 'b', 'd'}.

Answer:

(C) {'b', 'a', 'd'}

Correct Answer: C) {'b', 'a', 'd'}


Question: 32 Report Error

निम्नलिखित पायथन कोड का आउटपुट क्या होगा?

What will be the output of the following Python code ?

from math import factorial
print(math.sqrt(25))
A)
B)
C)
D)
Explanation

The error occurs because only factorial was imported from the math module, not the whole math module. The code tries to use math.sqrt(25), but math is not available.

To fix it, either import the entire math module:

import math
print(math.sqrt(25))

Or import sqrt directly:

from math import sqrt
print(sqrt(25))

Answer:

(D) Error, the statement should be: print(sqrt(25))

Correct Answer: D) Error, the statement should be: print(sqrt(25))


Question: 34 Report Error

कथन 1 के लिए उत्तर चुनें.

Choose the answer for statement 1.

import ___________ # statement 1
rec = [ ]
while True:
    rn = int(input("Enter"))
    nm = input("Enter")
    temp = [rn, nm]
    rec.append(temp)
    ch = input("Enter choice (Y/N)")
    if ch.upper == "N":
         break
f = open("stud.dat", "____________") #statement 2
__________ .dump(rec, f) #statement 3
_______.close( ) # statement 4
A)
B)
C)
D)
Explanation

The code involves serializing a list (rec) into a file. The correct module for serializing and deserializing Python objects into a file is pickle.

Explanation:

  • Statement 1: To serialize and deserialize objects, we need to import the pickle module.

  • Statement 2: The file mode should be "wb" (write binary) since we are writing serialized data.

  • Statement 3: To serialize and save the data to the file, the pickle.dump() method is used.

  • Statement 4: The file should be closed using f.close().

Correct answer:

(C) pickle

Correct Answer: C) pickle


Question: 35 Report Error

os.getlogin() क्या लौटाता है?

What does os.getlogin() return ?

A)
B)
C)
D)

Question: 36 Report Error

इनमें से कौन सी परिभाषा मॉड्यूल का सही वर्णन करती है?

Which of these definitions correctly describes a module ?

A)
B)
C)
D)

Question: 40 Report Error

निम्नलिखित कोड का परिणाम क्या है ?

What is the output of the following code ?

import numpy as np
a = np.array([1.1,2,3])
print(a.dtype)
A)
B)
C)
D)
Explanation

Let's break down the code:

import numpy as np
a = np.array([1.1, 2, 3])
print(a.dtype)

Explanation:

  1. Creating the array:

    • a = np.array([1.1, 2, 3]) creates a NumPy array. The array contains a mix of float (1.1) and int (2 and 3).
  2. NumPy Array Type Promotion:

    • NumPy automatically promotes the data type of the array to a common type that can hold all the values. Since there is a float (1.1), NumPy will convert the entire array to the float64 data type to accommodate the decimal values.
  3. a.dtype:

    • This returns the data type of the elements in the array. Since the array contains a float, the dtype will be float64.

Conclusion:

The output will be float64.

Answer:

(B) float64

Correct Answer: B) float64


Question: 42 Report Error

कथन 2 के लिए उत्तर चुनें.

Choose the answer for statement 2.

import ___________ # statement 1
rec = [ ]
while True:
    rn = int(input("Enter"))
    nm = input("Enter")
    temp = [rn, nm]
    rec.append(temp)
    ch = input("Enter choice (Y/N)")
    if ch.upper == "N":
         break
f = open("stud.dat", "____________") #statement 2
__________ .dump(rec, f) #statement 3
_______.close( ) # statement 4
A)
B)
C)
D)
Explanation

Let's break down the code for statement 2.

Context:

The code involves writing data (a list of records) into a file, and since we're using serialization (as inferred from the usage of .dump()), the file should be opened in binary write mode.

Explanation:

  • f = open("stud.dat", "____________"):
    Since we're writing binary data (likely using pickle.dump()), the correct mode to open the file should be "wb", which stands for write binary.

Answer:

(B) wb

Correct Answer: B) wb


Question: 43 Report Error

आइए मान लें कि 4 बाइनरी में 100 है और 11 1011 है। निम्नलिखित बिटवाइज़ का आउटपुट संचालक क्या है?

Let us assume 4 is 100 in binary and 11 is 1011. What is the output of the following bitwise operators ?

a = 4
b = 11
print(a | b)
print(a >> 2)
A)
B)
C)
D)
Explanation

Let's go through it briefly:

  1. Bitwise OR (|):

    • a = 4 (binary: 100), b = 11 (binary: 1011)
    • OR operation gives 1111 in binary, which equals 15 in decimal.
  2. Right Shift (>>):

    • a = 4 (binary: 100)
    • Shifting right by 2 positions: 100 becomes 1, which equals 1 in decimal.

Final Output:

(A) 15 1

Correct Answer: A) 15 1


Question: 44 Report Error

जब हम सूची ("हैलो") निष्पादित करते हैं तो आउटपुट क्या होता है?

What is the output when we execute list("hello") ?

A)
B)
C)
D)
Explanation

When we execute list("hello"), Python converts the string "hello" into a list of its individual characters.

Explanation:

  • "hello" is a string.
  • Using list("hello"), we convert the string into a list where each character becomes an element of the list.

So, the result will be:

['h', 'e', 'l', 'l', 'o']

Answer:

(A) ['h', 'e', 'l', 'l', 'o']

Correct Answer: A) ['h', 'e', 'l', 'l', 'o']


Question: 46 Report Error

निम्नलिखित का आउटपुट क्या है?

What is the output of the following ?

i = 2
while True:
    if i%3 == 0:
        break
    print(i,end=" " )
    i += 2
A)
B)
C)
D)
Explanation

Let's break down the code:

i = 2
while True:
    if i % 3 == 0:
        break
    print(i, end=" ")
    i += 2

Step-by-step execution:

  1. i = 2: We start with i = 2.

  2. First iteration:

    • i % 3 == 0 is False because 2 % 3 == 2.
    • print(i, end=" ") prints 2.
    • i += 2 makes i = 4.
  3. Second iteration:

    • i = 4, so i % 3 == 0 is still False because 4 % 3 == 1.
    • print(i, end=" ") prints 4.
    • i += 2 makes i = 6.
  4. Third iteration:

    • i = 6, so i % 3 == 0 is True because 6 % 3 == 0.
    • The break statement is executed, and the loop stops.

Conclusion:

The output is 2 4.

Answer:

(B) 2 4

Correct Answer: B) 2 4


Question: 47 Report Error

निम्नलिखित कोड का आउटपुट क्या होगा?

What will be the output of following code ?

x = ['XX', 'YY']
     for i in x
     i.lower()
print(x)
A)
B)
C)
D)
Explanation

Let's break down the code step by step:

x = ['XX', 'YY']
for i in x:
    i.lower()
print(x)

Explanation:

  1. List x: The list x = ['XX', 'YY'] contains two strings: 'XX' and 'YY'.

  2. The for loop:

    • The loop goes through each element in x, and for each string i, it calls the lower() method. However, lower() does not modify the string in place. Strings are immutable in Python, meaning the lower() method returns a new string but does not change the original one.
  3. The print(x):

    • After the loop completes, the list x is still unchanged because lower() was applied to each string but its result was not stored back in x.

Thus, the list x remains as ['XX', 'YY'].

Answer:

(A) ['XX', 'YY']

Correct Answer: A) ['XX', 'YY']


Question: 52 Report Error

निम्नलिखित कोड के लिए आउटपुट क्या होगा?

What will be output for the following code ?

import numpy as np
a = np.array([11,2,3])
print(a.min())
A)
B)
C)
D)
Explanation

Let's break down the code:

import numpy as np
a = np.array([11, 2, 3])
print(a.min())

Explanation:

  • a = np.array([11, 2, 3]) creates a NumPy array with the elements [11, 2, 3].

  • a.min() finds the minimum value in the array.

So, the minimum value in the array [11, 2, 3] is 2.

Answer:

(A) 2

Correct Answer: A) 2


Question: 53 Report Error

कथन 4 के लिए उत्तर चुनें.

Choose the answer for statement 4.

import ___________ # statement 1
rec = [ ]
while True:
    rn = int(input("Enter"))
    nm = input("Enter")
    temp = [rn, nm]
    rec.append(temp)
    ch = input("Enter choice (Y/N)")
    if ch.upper == "N":
          break
f = open("stud.dat", "____________") #statement 2
__________ .dump(rec, f) #statement 3
_______.close( ) # statement 4
A)
B)
C)
D)
Explanation

In this scenario, you're working with the pickle module to serialize data into a file. Let's look at statement 4 in the context of the code:

f = open("stud.dat", "____________")  # statement 2
__________ .dump(rec, f)  # statement 3
_______.close()  # statement 4

Explanation of the code:

  1. Statement 1 imports the necessary module, likely pickle because .dump() is used.
  2. Statement 2 opens the file stud.dat in write-binary mode (wb), allowing us to write binary data to it.
  3. Statement 3 uses pickle.dump() to serialize the rec list and save it to the file f.
  4. Statement 4 should close the file f after writing. To do this, you call .close() on the file object f.

Thus, statement 4 should close the file object f.

Answer:

(A) f

Correct Answer: A) f


Question: 54 Report Error

निम्नलिखित छद्म कोड का आउटपुट क्या होगा, जहां ʌ XOR ऑपरेशन का प्रतिनिधित्व करते हैं?

What will be the output of the following pseudo code, where ʌ represent XOR operation ?

Integer a, b, c
Set b = 5, a = 1
c = a ^ b
Print c
A)
B)
C)
D)
Explanation

Sure! Here's a simple breakdown:

  • a = 1 and b = 5.
  • In binary:
    • a = 10001
    • b = 50101
  • XOR operation (^):
    • Compare bits: 0001 ^ 0101
    • Result: 0100 (binary)
    • 0100 in decimal = 4

Answer:

(A) 4

Correct Answer: A) 4


Question: 55 Report Error

सुन्न सरणी की विशेषताएँ क्या हैं?

What are the attributes of numpy array ?

A)
B)
C)
D)

Question: 57 Report Error

निम्नलिखित का आउटपुट क्या है?

What is the output of the following ?

for i in range(10):
     if i == 5:
         break
     else:
          print(i)
else:
     print("Here")
A)
B)
C)
D)
Explanation

Sure! Here's a simple breakdown:

  • The for loop runs from i = 0 to i = 9.
  • When i reaches 5, the break statement stops the loop.
  • The numbers 0 1 2 3 4 are printed because the loop ends before i reaches 5.
  • The else after the loop is not executed because the loop was stopped with break.

Output:

(C) 0 1 2 3 4

Correct Answer: C) 0 1 2 3 4


Question: 60 Report Error

निम्नलिखित कोड का परिणाम क्या है ?

What is the output of the following code ?

a = 15
b = 6
print(a and b)
print(a or b)
A)
B)
C)
D)
Explanation

Let's break down the code and the logic behind it:

a = 15
b = 6
print(a and b)
print(a or b)

Explanation:

  1. a and b:

    • In Python, the and operator returns the second operand if the first operand is truthy (non-zero).
    • Since a = 15 (a non-zero value, which is truthy), the result of a and b is b, which is 6.
  2. a or b:

    • The or operator returns the first truthy operand it encounters.
    • Since a = 15 is truthy, the result of a or b is a, which is 15.

Output:

(C) 6 15

Correct Answer: C) 6 15


Question: 61 Report Error

यदि उपयोगकर्ता ने 55 दर्ज किया है तो आउटपुट क्या है?

What is the output, if user has entered 55 ?

a=input("Enter a number")
print(type(a))
A)
B)
C)
D)
Explanation

In Python, the input() function always returns a value as a string. So, even if the user enters a number like 55, the input is treated as a string.

Explanation:

  • a = input("Enter a number"): The value entered by the user (in this case, 55) is stored as a string.
  • print(type(a)): This will print the type of the variable a, which is a string (str), not an integer or float.

Output:

(D) str

Correct Answer: D) str


Question: 62 Report Error

a=5, b=8, c=6 के लिए निम्नलिखित एल्गोरिदम का आउटपुट क्या होगा?

What will be the output of the following algorithm for a=5, b=8, c=6 ?

Step 1: Start
Step 2: Declare variables a,b and c.
Step 3: Read variables a,b and c.
Step 4: If a > b
                   If a > c
                          Display a is the largest number.
                   Else
                          Display c is the largest number.
             Else
                   If b > c
                          Display b is the largest number.
                   Else
                          Display c is the greatest number.
Step 5: Stop
A)
B)
C)
D)
Explanation

Sure! Here's a simple explanation:

  • We are given a = 5, b = 8, and c = 6.
  • The algorithm first checks if a > b, but a (5) is not greater than b (8).
  • Since a is not greater than b, the algorithm moves to the else part, which checks if b > c.
  • Since b (8) is greater than c (6), it prints "b is the largest number".

Output: (A) b is the largest number

Correct Answer: A) b is the largest number


Question: 67 Report Error

निम्नलिखित कोड का आउटपुट क्या है?

What is the output of following code ?

a1={1:"A",2:"B",3:"C"}
b1={4:"D",5:"E"}
b1.update(a1)
print(b1)
A)
B)
C)
D)
Explanation

Sure! Here's a concise explanation:

  • We have two dictionaries:

    • a1 = {1: "A", 2: "B", 3: "C"}
    • b1 = {4: "D", 5: "E"}
  • The update() method adds the items from a1 to b1.

  • After b1.update(a1), b1 will include all key-value pairs from both dictionaries.

So, the final result of b1 will be:

{4: 'D', 5: 'E', 1: 'A', 2: 'B', 3: 'C'}

Output: (A)

Correct Answer: A) {4: 'D', 5: 'E', 1: 'A', 2: 'B', 3: 'C'}


Question: 68 Report Error

कौन सा कथन एक फ़ाइल (फ़ाइल ऑब्जेक्ट „f‟) से 5 अक्षर पढ़ेगा?

Which statement will read 5 characters from a file(file object „f‟) ?

A)
B)
C)
D)
Explanation

The correct answer is:

(B) f.read(5)

Explanation:

  • f.read(5) reads exactly 5 characters from the file. The number 5 specifies the number of characters to read from the file.
  • f.read() without a number will read the entire file or until the end of the file.
  • f.reads(5) is incorrect and will raise an error since there is no reads method.

Output:

(B) f.read(5)

Correct Answer: B) f.read(5)


Question: 70 Report Error

निम्नलिखित पायथन कोड का आउटपुट क्या होगा?

What will be the output of the following Python code ?

from math import *
ceil(3.4)
A)
B)
C)
D)
Explanation

The correct answer is:

(A) 4

Explanation:

  • The ceil() function from the math module returns the smallest integer greater than or equal to the given number.
  • For ceil(3.4), the smallest integer greater than or equal to 3.4 is 4.

So, the output of the code ceil(3.4) is 4.

Output:

(A) 4

Correct Answer: A) 4


Question: 71 Report Error

निम्नलिखित ऑब्जेक्ट का डेटा प्रकार क्या है?

What is the data type of following object ?

A = [5,‟abc‟,3.2,6]
A)
B)
C)
D)
Explanation

The correct answer is:

(C) list

Explanation:

  • The object A = [5, 'abc', 3.2, 6] is enclosed in square brackets [], which denotes a list in Python.
  • A list can hold items of various data types, such as integers, strings, and floating-point numbers, as seen in the example.

Output:

(C) list

Correct Answer: C) list


Question: 74 Report Error

निम्नलिखित कोड का आउटपुट क्या है?

What is the output of following code ?

A=[[1,2,3],
[4,5,6],
[7,8,9]]
print(A[1][:])
A)
B)
C)
D)
Explanation

The correct answer is:

(B) [4, 5, 6]

Explanation:

  • A is a 2D list (a list of lists), where A[1] refers to the second list (since indexing starts from 0), which is [4, 5, 6].
  • The [:] slice operator is used to copy the entire list at index 1. So, A[1][:] gives the list [4, 5, 6].

Output:

(B) [4, 5, 6]

Correct Answer: B) [4, 5, 6]


Question: 75 Report Error

NumPY का मतलब है?

NumPY stands for ?

A)
B)
C)
D)

Question: 77 Report Error

निम्नलिखित कोड का परिणाम क्या है ?

What is the output of the following code ?

import numpy as np
a = np.array([[1,2,3],[4,5,6],[7,8,9]])
print(a.shape)
A)
B)
C)
D)
Explanation

The correct answer is:

(B) (3, 3)

Explanation:

  • The array a is a 2D NumPy array with 3 rows and 3 columns:
    [[1, 2, 3],
     [4, 5, 6],
     [7, 8, 9]]
    
  • The .shape attribute of a NumPy array returns a tuple that gives the dimensions of the array (rows, columns).
  • In this case, the shape of the array is (3, 3), meaning 3 rows and 3 columns.

Output:

(B) (3, 3)

Correct Answer: B) (3, 3)


Question: 78 Report Error

print((-3)** 2) का आउटपुट क्या है?

What is the output of print((-3)** 2) ?

A)
B)
C)
D)
Explanation

The correct answer is:

(D) 9

Explanation:

  • In Python, the expression (-3)**2 means that the negative number -3 is raised to the power of 2.
  • The exponentiation operator ** has higher precedence than the negative sign, so -3 is treated as (-3) and then squared.
  • Squaring -3 gives 9 because: (−3)×(−3)=9(-3) \times (-3) = 9

Output:

(D) 9

Correct Answer: D) 9


Question: 79 Report Error

निम्नलिखित पायथन कोड का आउटपुट क्या होगा?

What will be the output of the following Python code ?

def say(message, times = 1):
        print(message * times)
say('Hello')
say('World', 5)
A)
B)
C)
D)
Explanation

The correct answer is:

(A) Hello WorldWorldWorldWorldWorld

Explanation:

  • In the function say(message, times=1), the default value for times is 1.
  • When say('Hello') is called, it prints the message 'Hello' only once because times is defaulted to 1.
  • When say('World', 5) is called, the message 'World' is printed 5 times because the times parameter is explicitly set to 5.

Output:

(A) Hello WorldWorldWorldWorldWorld

Correct Answer: A) Hello WorldWorldWorldWorldWorld


Question: 81 Report Error

निम्नलिखित कोड का परिणाम क्या है ?

What is the output of the following code ?

import numpy as np
a = np.array([[1,2,3]])
print(a.ndim)
A)
B)
C)
Explanation

The correct answer is:

(B) 2

Explanation:

  • In the code, a is a NumPy array created with the shape [[1, 2, 3]], which represents a 2D array with 1 row and 3 columns.
  • a.ndim returns the number of dimensions of the array.
  • Since a is a 2D array (1 row and 3 columns), a.ndim will be 2.

Output:

(B) 2

Correct Answer: B) 2


Question: 83 Report Error

निम्नलिखित कोड खंड क्या प्रिंट करेगा?

What will following code segment print ?

a = True
b = False
c = False
if a or b and c:
         print "HELLO"
else:
         print "hello"
A)
B)
C)
D)
Explanation

The correct answer is:

(A) HELLO

Explanation:

  • The expression a or b and c evaluates the logical conditions.
  • Python evaluates and before or. So, the expression is evaluated as a or (b and c).
  • Since b and c is False (because both b and c are False), the condition becomes a or False, which is True or False, which results in True.
  • Since the condition is True, the if block is executed, and it prints "HELLO".

Output:

(A) HELLO

Correct Answer: A) HELLO


Question: 84 Report Error

निम्नलिखित में से कौन सा नंबर निम्नलिखित कोड द्वारा कभी भी उत्पन्न नहीं किया जा सकता है:

Which of the following number can never be generated by the following code :

random.randrange(0, 50)
A)
B)
C)
D)
Explanation

The correct answer is:

(D) 50

Explanation:

The random.randrange(start, stop) function generates a random number in the range from start to stop - 1, i.e., it includes start but excludes stop.

  • In this case, random.randrange(0, 50) will generate a number between 0 and 49 (inclusive of 0 and exclusive of 50).
  • Therefore, 50 can never be generated by this code.

Output:

(D) 50

Correct Answer: D) 50


Question: 85 Report Error

निम्नलिखित का आउटपुट क्या है?

What is the output of the following ?

x = 'abcd'
for i in range(x):
print(i)
A)
B)
C)
D)
Explanation

The answer is (C) error.

Reason:

The code for i in range(x): will throw an error because x is a string ('abcd'), and range() expects an integer. You can't pass a string to range().

Fix:

You need to use len(x) to get the length of the string:

for i in range(len(x)):
    print(i)

This will print the indices (0, 1, 2, 3). But as the code is written, it will result in an error.

Correct Answer: C) error


Question: 87 Report Error
Question: 89 Report Error

निम्नलिखित का आउटपुट क्या है?

What is the output of the following ?

t=(2, 3, 4, 3.5, 5, 6)
print(sum(t) + t.count(2))
A)
B)
C)
D)
Explanation

Let's break down the code and understand it step by step:

Given:

t = (2, 3, 4, 3.5, 5, 6)
  1. sum(t): This function will return the sum of all the elements in the tuple t.

    • 2 + 3 + 4 + 3.5 + 5 + 6 = 23.5
  2. t.count(2): This function will count how many times the number 2 appears in the tuple t.

    • The number 2 appears once in the tuple.
  3. Now, we add these two results:

    • sum(t) = 23.5
    • t.count(2) = 1

    So, 23.5 + 1 = 24.5

Thus, the correct answer is (C) 24.5.

Correct Answer: C) 24.5


Question: 90 Report Error

निम्नलिखित पायथन कोड का आउटपुट क्या होगा?

What will be the output of the following Python code ?

def sayHello():
           print("Hello World!‟)
sayHello()
sayHello()
A)
B)
C)
D)
Explanation

The code has a small typo in the print statement. Specifically, the closing quotation mark for the string "Hello World!" is incorrectly written as a special character instead of a standard double quote ".

Here’s the corrected version of the code:

def sayHello():
    print("Hello World!")
    
sayHello()
sayHello()

Now, if the code is corrected, the output will be:

Hello World!
Hello World!

Correct Answer: (A) Hello World! Hello World!

Correct Answer: A) Hello World! Hello World!


Question: 91 Report Error

पायथन में निम्नलिखित में से किस फ़ंक्शन का उपयोग होता है?

Which of the following is the use of function in python ?

A)
B)
C)
D)

Question: 94 Report Error

निम्नलिखित कोड का परिणाम क्या है ?

What is the output of the following code ?

a = 50
b = a= a*5
print(b)
A)
B)
C)
D)
Explanation

Let's break down the code:

a = 50
b = a = a * 5
print(b)
  1. Initially, a = 50.
  2. Then b = a = a * 5:
    • The expression a * 5 is evaluated first, which results in 50 * 5 = 250.
    • This result is assigned to a, so a becomes 250.
    • Simultaneously, b is also assigned the value of a, which is now 250.
  3. Finally, print(b) outputs the value of b, which is 250.

So, the output of the code is:

Answer: (A) 250

Correct Answer: D) Syntax Error


Question: 96 Report Error

सही फ़ंक्शन हेडर को पहचानें.

Identify the correct function header.

A)
B)
C)
D)

Question: 98 Report Error

निम्नलिखित में से कौन सा सही है?

Which one of the following is correct ?

A)
B)
C)
D)

Question: 100 Report Error

निम्नलिखित कोड का उद्देश्य क्या है?

What is the purpose of the following code ?

import numpy as np
z=[1,2,3]
y=np.array(z)
A)
B)
C)
D)
Explanation

The code provided:

import numpy as np
z = [1, 2, 3]
y = np.array(z)

Explanation:

  • z = [1, 2, 3]: This creates a regular Python list with elements 1, 2, and 3.
  • y = np.array(z): This converts the Python list z into a NumPy array and stores it in y.

Thus, the purpose of the code is to convert the list z into a NumPy array.

Answer: (A) to convert z to array

Correct Answer: A) to convert z to array


Related Papers



















































Latest Updates