Python Randrange Randrange ()วิธี การ
ตัวอย่าง
ส่งกลับตัวเลขระหว่าง 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 |