Python Random random () Method
ဥပမာ
3 နှင့် 9 အကြား နံပါတ်တစ်ခုကို ပြန်ပေးပါ။
import random
print(random.randrange(3, 9))
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
randrange()
နည်းလမ်းသည် သတ်မှတ်ထားသော အပိုင်းအခြားမှ ကျပန်းရွေးချယ်ထားသော အစိတ်အပိုင်းကို ပြန်ပေးသည် ။
အထားအသို
random.randrange(start, stop, step)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
start | Optional. An integer specifying at which position to start. Default 0 |
stop | Required. An integer specifying at which position to end. |
step | Optional. An integer specifying the incrementation. Default 1 |