python里randint是什么意思_Python中random.randint方法(精选)

Python中 random.randint方法的具体用法?Python 中random.randint怎么用?Python 中random.randint使用的例子?以下例子或许可以帮助到你:

示例1: __init__

# 需要导入模块: import random [as 别名]

# 或者: from random import randint [as 别名]

def __init__(self, name, infected, infection_length, initiative,

coupling_tendency, condom_use, test_frequency, commitment,

coupled=False, coupled_length=0, known=False, partner=None):

init_state = random.randint(0, 3)

super().__init__(name, "wandering around", NSTATES, init_state)

self.coupled = coupled

self.couple_length = coupled_length

self.partner = partner

self.initiative = initiative

self.infected = infected

self.known = known

self.infection_length = infection_length

self.coupling_tendency = coupling_tendency

self.condom_use = condom_use

self.test_frequency = test_frequency

self.commitment = commitment

self.state = init_state

self.update_ntype()

示例2: test_get_my_pop

# 需要导入模块: import random [as 别名]

# 或者: from random import randint [as 别名]

def test_get_my_pop(self):

report = True

for var in self.dic_for_reference:

for a in self.dic_for_reference[var][AGENTS]:

self.agentpop.append(a)

var = str(random.randint(0, 2))

dummy_node = node.Node("dummy node")

dummy_node.ntype = var

self.agentpop.append(dummy_node)

self.dic_for_reference[var][AGENTS].append(dummy_node)

result = self.agentpop.get_my_pop(dummy_node)

correct_pop = len(self.dic_for_reference[var][AGENTS])

if result != correct_pop:

report = False

self.assertEqual(report, True)

以上为PYTHON的方法,如果想了解web前端内容,包括html,css,Javascript可以点击相关链接

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值