np.random.randint() का इस्तेमाल
randint आपके specify किए एक range से random whole numbers draw करता है।
In this page:
Syntax
np.random.randint(low, high, size)
np.random.randint()
np.random.randint(low, high, size) low से लेकर लेकिन high को शामिल किए बिना integers return करता है। अगर आप एक argument दें, इसका मतलब high है और low default से 0 है। किसी भी shape के arrays बनाने के लिए size इस्तेमाल करें।
Note:
high value exclusive है, इसलिए randint(1, 7) एक die simulate करता है।
उदाहरण: np.random.randint()
import numpy as np
np.random.seed(3)
print(np.random.randint(1, 7, size=10))
print(np.random.randint(0, 100, size=(2, 3)))
# Output:
# [3 1 2 4 1 1 1 6 6 4]
# [[74 41 10]
# [21 38 96]]
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
- यह उम्मीद करना कि high included होगा
- यह भूल जाना कि size एक single number return करता है
- rand इस्तेमाल करना और int में cast करना
चैप्टर सारांश
- high exclusive है
- size output shape control करता है
- एक argument मतलब high
- Integers return करता है
🔒
Chapter Quiz — Complete all 6 topics to unlock
0/6 topics done
Complete these topics first: