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

O Level Python Paper January 2023

Question: 4 Report Error

NumPY का अर्थ है:

NumPY stands for :

A)
B)
C)
D)

Question: 9 Report Error

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

What is the output of the following code snippet ?

print([i.lower() for i in “HELLO”])
A)
B)
C)
D)
Explanation

Sure!

The code converts each character in "HELLO" to lowercase using .lower(), resulting in the list ['h', 'e', 'l', 'l', 'o'].

Answer: (B) ['h', 'e', 'l', 'l', 'o'].

Correct Answer: B) [‘h’, ‘e’, ‘l’, ‘l’, ‘o’]


Question: 11 Report Error

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

What will be the output of the following pseudo code ?

Integer a, b
Set a = 10, b = 5
a = a mod (a - 6)
b = b mod (b - 2)
Print a – b
A)
B)
C)
D)
Explanation

Sure!

  • a = 10 mod (10 - 6) = 10 mod 4 = 2
  • b = 5 mod (5 - 2) = 5 mod 3 = 2
  • Then, a - b = 2 - 2 = 0.

Answer: (B) 0.

Correct Answer: B) 0


Question: 13 Report Error

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

What will be the output of the following pseudo code, where & represent And operation ?

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

Sure!

  • a = 1 (binary 0001), b = 5 (binary 0101).
  • The AND operation (&) compares each bit: 0001 & 0101 = 0001 (which is 1).

So, the output is 1.

Answer: (A) 1.

Correct Answer: A) 1


Question: 14 Report Error

निम्नलिखित कोड का परिणाम क्या है ? एनपी के रूप में सुन्न आयात करें

What is the output of the following code ?

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

Sure!

  • c = a + b[1, 5, 7, 7, 9]
  • c = c * a[1, 10, 21, 35, 72]
  • c[2] is 21.

Answer: (B) 21.

Correct Answer: C) 12


Question: 15 Report Error

निम्नलिखित कोड का आउटपुट क्या है? एनपी के रूप में सुन्न आयात करें

What is the output of following code ? import numpy as np

a = np.array([[1,2,3],[4,5,6]])
print(a.shape)
A)
B)
C)
D)
Explanation

Let's break down the code:

import numpy as np
a = np.array([[1, 2, 3], [4, 5, 6]])
print(a.shape)
  • a is a 2x3 numpy array (2 rows and 3 columns).
  • The .shape attribute of a numpy array returns a tuple representing the dimensions of the array.

So, for this array:

  • It has 2 rows and 3 columns, so the shape will be (2, 3).

Answer: (A) (2, 3).

Correct Answer: A) (2, 3)


Question: 16 Report Error

निम्नलिखित कथन में 'f' क्या है?

What is ‘f’ in the following statement ?

f=open(“Data.txt”, “r”)
A)
B)
C)
D)
Explanation

In the statement:

f = open("Data.txt", "r")
  • f is a file handle. It's a reference to the file that has been opened, allowing you to perform operations (like reading, writing) on the file.

So, the correct answer is:

Answer: (B) File Handle.

Correct Answer: B) File Handle


Question: 18 Report Error

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

What is the output of the following code ?

WM=[‘b’ * x for x in range(4)]
print(WM)
A)
B)
C)
D)
Explanation

Let's break down the code:

WM = ['b' * x for x in range(4)]
print(WM)
  • The list comprehension ['b' * x for x in range(4)] iterates over the range of numbers from 0 to 3.

  • In each iteration, it multiplies the string 'b' by the current value of x.

  • For x = 0: 'b' * 0 results in an empty string ''.

  • For x = 1: 'b' * 1 results in 'b'.

  • For x = 2: 'b' * 2 results in 'bb'.

  • For x = 3: 'b' * 3 results in 'bbb'.

So, the list WM will be: ['', 'b', 'bb', 'bbb'].

Answer: (A) ['', 'b', 'bb', 'bbb'].

Correct Answer: A) [‘’, ‘b’, ‘bb’, ‘bbb’]


Question: 19 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

Let's break down the code:

import numpy as np
a = np.array([1, 2, 3])
print(a.ndim)
  • a is a 1-dimensional numpy array (since it is a single list with elements [1, 2, 3]).
  • The .ndim attribute of a numpy array gives the number of dimensions of the array.

For a = np.array([1, 2, 3]), it is a 1D array, so a.ndim will return 1.

Answer: (A) 1.

Correct Answer: A) 1


Question: 22 Report Error

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

What will be output for the following code ?

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

Sure!

The array a has 2 rows and 3 columns, so the total number of elements is 2 * 3 = 6.

Answer: (C) 6.

Correct Answer: C) 6


Question: 24 Report Error

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

What will be the output of following ?

Y=[2,5J,6]
Y.sort()
A)
B)
C)
D)
Explanation

Let's break down the code:

Y = [2, 5j, 6]
Y.sort()
  • Y is a list containing elements: 2, 5j (a complex number), and 6.
  • The sort() method in Python does not work with mixed data types such as integers and complex numbers because they cannot be directly compared.

Since you cannot compare integers with complex numbers in Python, this will result in an error.

Answer: (C) Error.

Correct Answer: C) Error


Question: 31 Report Error

x का डेटाटाइप क्या है?

What is the datatype of x ?

import numpy as np
a=np.array([1,2,3,4])
x= a.tolist()
A)
B)
C)
D)
Explanation

Let's break down the code:

import numpy as np
a = np.array([1, 2, 3, 4])
x = a.tolist()
  • a is a numpy array.
  • The method .tolist() converts a numpy array into a Python list.

So, the variable x will be a list.

Answer: (D) list.

Correct Answer: D) list


Question: 33 Report Error

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

What will be the output of the following Python code ?

>>>list1 = [1, 3]
>>>list2 = list1
>>>list1[0] = 4
>>>print(list2)
A)
B)
C)
D)
Explanation

Sure!

  • list2 is just a reference to list1.
  • When list1[0] is changed to 4, it also affects list2 because both point to the same list.

Answer: (C) [4, 3].

Correct Answer: C) [4, 3]


Question: 34 Report Error

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

What will be the output of following statement ?

>>>”m”+”nl”
A)
B)
C)
D)
Explanation

Let's break down the statement:

"m" + "nl"
  • This is string concatenation, where the string "m" is combined with the string "nl".
  • The result will be the two strings joined together: "mnl".

Answer: (B) 'mnl'.

Correct Answer: B) ‘mnl’


Question: 35 Report Error

पायथन के संबंध में सही विकल्प चुनें

Choose the correct option with respect to Python.

A)
B)
C)
D)

Question: 36 Report Error
Question: 39 Report Error

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

What will following code segment print ?

if True or True:
      if False and True or False:
             print(‘A’)
      elif False and False or True and True:
             print(‘B’)
      else:
             print(‘C’)
      else:
             print(‘D’)
A)
B)
C)
D)
Explanation

Sure!

  • True or True is True, so the first block is executed.
  • The second condition False and True or False is False, so it moves to elif.
  • False and False or True and True is True, so it prints 'B'.

Answer: (B) B.

Correct Answer: B) B


Question: 41 Report Error

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

What will be the output of the following Python code ?

example = “helle”
example.rfind(“e”)
A)
B)
C)
D)
Explanation

Let's break down the code:

example = "helle"
example.rfind("e")
  • rfind() returns the highest index of the substring (in this case, "e") found in the string.
  • In the string "helle", the last occurrence of "e" is at index 4.

So, the output will be 4.

Answer: (C) 4.

Correct Answer: C) 4


Question: 42 Report Error

निम्नलिखित में से कौन सा मॉड्यूल का उपयोग करने का लाभ नहीं है ?

Which of the following is not an advantage of using modules ?

A)
B)
C)
D)

Question: 44 Report Error

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

What will be output for the following code ?

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

Let's break down the code:

import numpy as np
a = np.array([1, 2, 3, 5, 8])
print(a.ndim)
  • a is a 1-dimensional numpy array because it's a single list [1, 2, 3, 5, 8].
  • The .ndim attribute of a numpy array tells us the number of dimensions of the array.

For the array a = np.array([1, 2, 3, 5, 8]), it is 1D.

So, the output will be 1.

Answer: (B) 1.

Correct Answer: B) 1


Question: 46 Report Error

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

What will be the output of the following Python code ?

from math import *
floor(11.7)
A)
B)
C)
D)
Explanation

Let's break down the code:

from math import *
floor(11.7)
  • The floor() function returns the largest integer less than or equal to the given number.
  • For 11.7, the largest integer less than or equal to it is 11.

So, the output will be 11.

Answer: (B) 11.

Correct Answer: B) 11


Question: 49 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 smallest number.
                Else
                     Display c is the smallest number.
              Else
                  If b < c
                     Display b is the smallest number.
                  Else
                      Display c is the smallest number.
Step 5 : Stop

A)
B)
C)
D)
Explanation

Here's a concise breakdown:

  • a = 5, b = 8, c = 6.
  • First, we check if a < b, which is true (5 < 8).
  • Then, we check if a < c, which is also true (5 < 6).
  • Since both conditions are true, the output will be "a is the smallest number".

Answer: (A) a is the smallest number.

Correct Answer: A) a is the smallest number


Question: 50 Report Error

निम्नलिखित में से कौन सी त्रुटि दिया गया कोड लौटाई गई है?

Which of the following error is returned by the given code ?

>>> f = open(“test.txt”,”w”)
>>> f.write(345)
A)
B)
C)
D)
Explanation

Let's analyze the given code:

f = open("test.txt", "w")
f.write(345)
  • The open() function is used to open a file in write mode ("w").
  • The write() method expects a string as an argument, but 345 is an integer.
  • Trying to write an integer directly will cause an error because the write() method cannot handle non-string data types.

The error will be:

TypeError because you're passing an integer instead of a string to the write() method.

Answer: (B) Type Error.

Correct Answer: B) Type Error


Question: 52 Report Error

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

What will be the output of the following Python code ?

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

Sure!

  • You imported factorial directly, so you should use factorial(5), not math.factorial(5).
  • Using math.factorial(5) will give an error because math wasn't imported.

Answer: (D) Error, the statement should be: print(factorial(5)).

Correct Answer: D) Error, the statement should be : print(factorial(5))


Question: 55 Report Error

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

What is the output of the following ?

y = ‘klmn’
for i in range(len(y)):
print(y)
A)
B)
C)
D)
Explanation

Let's break down the code:

y = 'klmn'
for i in range(len(y)):
    print(y)
  • y = 'klmn' is a string.
  • len(y) is 4 because the string "klmn" has 4 characters.
  • The loop runs 4 times (because range(4) generates the values 0, 1, 2, 3).
  • In each iteration, it prints the entire string y, which is "klmn".

So the output will be:

klmn
klmn
klmn
klmn

Answer: (A) klmn klmn klmn klmn.

Correct Answer: A) klmn klmn klmn klmn


Question: 59 Report Error

पायथन में शून्य () फ़ंक्शन का उपयोग क्या है?

What is the use of the zeros() function in Numpy array in python ?

A)
B)
C)
D)

Question: 60 Report Error

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

What will be the output of the following Python code ?

x = ‘abcd’
for i in x:
print(i.upper())
A)
B)
C)
D)
Explanation

The code iterates through each character in the string 'abcd', and for each character, it prints the uppercase version using .upper(). So it will print:

A
B
C
D

Answer: (D) A B C D.

Correct Answer: D) A B C D


Question: 61 Report Error

पुनरावर्ती कार्य __________ है।

Recursive function is __________.

A)
B)
C)
D)

Question: 63 Report Error

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

What will be the output of the following code snippet ?

from math import *
a = 2.19
b = 3.999999
c = -3.30
print(int(a), floor(b), ceil(c), fabs(c))
A)
B)
C)
D)
Explanation

Here’s a quick breakdown:

  1. int(a): Converts 2.19 to 2.
  2. floor(b): Floors 3.999999 to 3.
  3. ceil(c): Ceils -3.30 to -3.
  4. fabs(c): Converts -3.30 to its absolute value 3.30.

So, the output will be:

2 3 -3 3.3

Answer: (C) 2 3 -3 3.

Correct Answer: C) 2 3 -3 3


Question: 66 Report Error

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

What will be output for the following code ?

import numpy as np
ary = np.array([1,2,3,5,8])
ary = ary + 1
print (ary[1])
A)
B)
C)
D)
Explanation

Let's analyze the code:

import numpy as np
ary = np.array([1, 2, 3, 5, 8])
ary = ary + 1
print(ary[1])

Step-by-step breakdown:

  1. ary = np.array([1, 2, 3, 5, 8]): Creates a NumPy array with elements [1, 2, 3, 5, 8].
  2. ary = ary + 1: Adds 1 to each element of the array. This will give [2, 3, 4, 6, 9].
  3. print(ary[1]): Prints the element at index 1 of the modified array, which is 3.

So, the output will be:

3

Answer: (D) 3.

Correct Answer: D) 3


Question: 67 Report Error

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

What is the output of the following code ?

a = set(‘abc’)
b = set(‘cdef’)
print(a&b)
A)
B)
C)
D)
Explanation

Here’s a quick explanation:

  • a = set('abc') creates a set {'a', 'b', 'c'}.
  • b = set('cdef') creates a set {'c', 'd', 'e', 'f'}.
  • a & b gives the intersection (common elements) of both sets. The common element is 'c'.

So, the output is:

{'c'}

Answer: (A) {'c'}.

Correct Answer: A) {‘c’}


Question: 68 Report Error

निम्नलिखित में से कौन शब्दकोश में key=”tiger” के लिए कुंजी-मान को हटा देगा?

Which of the following will delete key-value pair for key=”tiger” in dictionary ?

dic={“lion”:”wild”,”tiger”:”wild”,”cat”:”domestic”,“dog”.”domestic”}
A)
B)
C)
D)
Explanation

To delete the key-value pair for "tiger" in the dictionary, you use the del statement:

del dic["tiger"]

This removes the key "tiger" and its value from the dictionary.

Correct answer: (A) del dic["tiger"].

Correct Answer: A) del dic[“tiger”]


Question: 69 Report Error

निम्नलिखित Python का कोड क्या है?

What is the value of the following Python code ?

>>>print(36 / 4)
A)
B)
C)
D)
Explanation

The Python code print(36 / 4) will perform division, and in Python 3, division always returns a floating-point number, even if the result is a whole number.

So, the result of 36 / 4 will be 9.0, which is a float.

Thus, the correct answer is:

(C) 9.0

Correct Answer: C) 9.0


Question: 71 Report Error

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

What will be the output of the following ?

print(sum(1,2,3))
A)
B)
C)
D)
Explanation

The sum() function in Python takes an iterable (like a list or tuple) as its argument. However, in the code sum(1, 2, 3), three separate arguments are passed to the function, which is incorrect. The function expects a single iterable (like a list or tuple), not multiple individual numbers.

So, the code will raise a TypeError.

Thus, the correct answer is:

(A) Error

Correct Answer: A) Error


Question: 72 Report Error

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

What is the output of the following ?

n=5
while n>0:
       n-=1
       if n ==2:
          continue
       print(n)
A)
B)
C)
D)
Explanation

Sure! Here's a simpler explanation:

  • Initially, n = 5.
  • The loop runs while n > 0, and in each iteration, n is reduced by 1.
  • When n == 2, the continue skips printing n and moves to the next iteration.

Step-by-step output:

  1. n = 5 → print 4
  2. n = 4 → print 3
  3. n = 3 → skip printing (because n = 2)
  4. n = 1 → print 1
  5. n = 0 → loop ends

So the output is: 4 3 1 0

Answer: (B) 4 3 1 0

Correct Answer: B) 4 3 1 0


Question: 73 Report Error

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

What is the output of the following ?

print(max([1, 2, 3, 4], [4, 5, 6], [7]))
A)
B)
C)
D)
Explanation

The max() function compares the first element of each list:

  • First list: [1, 2, 3, 4] (first element: 1)
  • Second list: [4, 5, 6] (first element: 4)
  • Third list: [7] (first element: 7)

Since 7 is the largest, the function returns the list [7].

Answer: (B) [7]

Correct Answer: B) [7]


Question: 76 Report Error

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

What is the output of the following ?

m = 0
while m < 5:
       print(m)
       m += 1
       if m == 3:
             break
        else:
             print(0)
A)
B)
C)
D)
Explanation

Here’s how the code works:

  • First iteration: Prints 0, then 0 again (since m != 3).
  • Second iteration: Prints 1, then 0 again.
  • Third iteration: Prints 2, then the loop stops because m == 3.

Output: 0 0 1 0 2

Answer: (C) 0 0 1 0 2

Correct Answer: B) 0 1 2


Question: 78 Report Error

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

What will be the output of the following expression ?

x = 14
print(x>>2)
A)
B)
C)
D)
Explanation

The operation x >> 2 shifts the bits of x (14) two places to the right.

  • 14 in binary is 1110.
  • After shifting right by 2, it becomes 0011, which is 3 in decimal.

So, the output is 3.

Answer: (C) 3

Correct Answer: C) 3


Question: 81 Report Error

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

What is the output of the following code ?

n2=4
def s(n1):
        print(n1)
        n1 = n1 +2
       n2=4
s(n2)
print(n2)
A)
B)
C)
D)
Explanation

Here's how the code works:

  • n2 is 4 globally.
  • Inside the function s(n1), n1 is set to 4 (from n2).
  • The function prints 4 (the value of n1).
  • Modifying n1 inside the function doesn't affect the global n2.
  • After the function, the global n2 remains 4.

Output: 4 4

Answer: (C) 4 4

Correct Answer: C) 4 4


Question: 83 Report Error

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

What will be the output of the following Python code ?

def func(a, b=5, c=10):
       print(‘a is’, a, ‘and b is’, b, ‘and c is’, c)
func(13, 17)
func(a=2, c=4)
func(5,7,9)
A)
B)
C)
D)
Explanation

Here's the breakdown:

  1. First call: func(13, 17)

    • a = 13, b = 17, c = 10 (default).
      Output: a is 13 and b is 17 and c is 10.
  2. Second call: func(a=2, c=4)

    • a = 2, b = 5 (default), c = 4.
      Output: a is 2 and b is 5 and c is 4.
  3. Third call: func(5, 7, 9)

    • a = 5, b = 7, c = 9.
      Output: a is 5 and b is 7 and c is 9.

Final output:

a is 13 and b is 17 and c is 10
a is 2 and b is 5 and c is 4
a is 5 and b is 7 and c is 9

Answer: (C)

Correct Answer: C) a is 13 and b is 17 and c is 10 a is 2 and b is 5 and c is 4 a is 5 and b is 7 and c is 9


Question: 84 Report Error

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

What will be the output of the following code snippet ?

numbers = (4, 7, 19, 2, 89, 45, 72, 22)
sorted_numbers = sorted(numbers)
odd_numbers = [x for x in sorted_numbers if
x % 2 != 0]
print(odd_numbers)
A)
B)
C)
D)
Explanation

Here’s how the code works:

  1. The tuple numbers is sorted: [2, 4, 7, 19, 22, 45, 72, 89].
  2. It then filters out the odd numbers: [7, 19, 45, 89].
  3. Finally, it prints the list of odd numbers.

Output: [7, 19, 45, 89]

Answer: (A)

Correct Answer: A) [7, 19, 45, 89]


Question: 92 Report Error

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

What will be the output of the following Python code ?

def display(b, n):
          while n>0:
print(b, end=””)
  n=n-1
    display(‘z’, 3)
A)
B)
C)
D)
Explanation

Let's break down the code:

def display(b, n):
    while n > 0:
        print(b, end="")
        n = n - 1

display('z', 3)
  1. Function call: display('z', 3)
    • b = 'z' and n = 3.
  2. While loop: The loop runs while n > 0. In each iteration:
    • It prints b (which is 'z').

    • Decreases n by 1.

    • First iteration: n = 3, print 'z', n becomes 2.

    • Second iteration: n = 2, print 'z', n becomes 1.

    • Third iteration: n = 1, print 'z', n becomes 0. The loop stops.

So, the output will be 'zzz'.

Answer: (A) zzz

Correct Answer: A) zzz


Question: 93 Report Error

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

What will be output for the following code ?

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

Question: 94 Report Error

एक स्ट्रिंग x=”hello” दिया गया x.count('l') का आउटपुट क्या है?

Given a string x=”hello” What is the output of x.count(‘l’) ?

A)
B)
D)
Explanation

The count() method in Python counts how many times a specified substring appears in a string.

For the string x = "hello", if you call x.count('l'), it counts the occurrences of the character 'l'.

  • In the string "hello", the letter 'l' appears 2 times.

Thus, the output is:

(A) 2

Correct Answer: A) 2


Question: 97 Report Error

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

What is the output of the following ?

x=123
for i in x:
print(i)
A)
B)
C)
D)
Explanation

The code:

x = 123
for i in x:
    print(i)

The issue here is that x = 123 is an integer, and integers are not iterable in Python. You cannot loop through an integer directly like you can with a string, list, or other iterable objects.

So, this will result in an Error.

The correct answer is:

(C) Error

Correct Answer: C) Error


Question: 98 Report Error

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

What will be the output of the following Python code ?

tuple1=(5,1,7,6,2)
tuple1.pop(2)
print(tuple1)
A)
B)
C)
D)
Explanation

The issue here is that the pop() method is not available for tuples in Python. Tuples are immutable, meaning you cannot modify them by removing elements like you can with lists.

Since the pop() method is used for lists (not tuples), this will result in an Error.

The correct answer is:

(D) Error

Correct Answer: D) Error


Question: 100 Report Error

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

What will be the output of the following Python code ?

def power(x, y=2):
   r=1
   for i in range(y):
         r=r*x
    return r

print (power(3))
print (power(3,3))
A)
B)
C)
D)
Explanation

The power function calculates x raised to the power of y. By default, y = 2.

  1. First call: power(3)3^2 = 9
  2. Second call: power(3, 3)3^3 = 27

Output:
9 27

Answer: (B) 9 27

Correct Answer: B) 9 27


Related Papers



















































Latest Updates