随机选择一个字符串visual basic 2010列表

时间:2012-07-11 02:27:19

标签: vb.net python-2.x

我创建了一个基本的数学游戏,产生随机的添加问题,当用户得到正确的答案时,程序会说出很棒的“名字”,然后会拉出一个随机的短语,比如“你很棒”,“哇,这是大” ....等。

我已经能够在Python2中创建程序了,我现在正在尝试在Visual Basic 2010中重建程序

我的问题是我无法弄清楚如何从短语列表中随机选择。我可以为程序生成随机整数,但不能生成字符串。

这是python2中代码的代码部分:

def randy(name):
x = random.randint(1,100)
y = random.randint(1,10)
z = x + y
phrases = ['!!!cool!!!','all right!!!','I like that Dude!','you are awesome','keep it up','AWESOME','Your The Man']
random.choice(phrases)
print
print x, '+ ',y
ans = input('enter your answer: ')
print
if ans == x + y:
    print 'good job', name, random.choice(phrases)
    print
    randy(name)
else:
    print 'that is an incorrect answer! try another '
    print 'the correct answer was: ', z
    print
    randy(name)

0 个答案:

没有答案
相关问题