निम्न NumPy कोड का आउटपुट क्या होगा?
What will be the output of the following NumPy code?
x = np.arange(1, 11, 2)
print(x)
A
[1 2 3 4 5]
B
[1 3 5 7 9]
C
[2 4 6 8 10]
D
[1 3 5 7 9 11]
Explanation
x = np.arange(1, 11, 2)
print(x)
np.arange(start, stop, step)
→ यहाँ:
start = 1,
stop = 11 (stop शामिल नहीं होता),
step = 2
इसलिए यह 1 से शुरू होकर हर बार 2 जोड़ता है जब तक 11 से कम है:
➡️ Output: [1, 3, 5, 7, 9]
In English:
np.arange(1, 11, 2) generates numbers from 1 to 10 with a step of 2.
Correct Answer: B) [1 3 5 7 9]