gpt4 book ai didi

python - 为什么 Python 3.4 randrange 不想工作?

转载 作者:太空宇宙 更新时间:2023-11-04 10:30:23 24 4
gpt4 key购买 nike

<分区>

我目前正在为我和我的 friend 制作一款小 Sprite 宝可梦游戏。但要做到这一点,我打算使用 randrange 模块来随机化使用哪些问题,而不是按顺序排列。我这样做了,但每次我运行该程序时,它都没有做它需要做的事情,它只是停留在一个空白屏幕上。除此之外,无论如何我可以确保它每轮只使用一次这个数字吗?谢谢。源代码:

#All importations.
import sys
import os
import time
from random import randrange, uniform
#Clear Screen
def cls():
os.system('cls')
#The Game
def game():
score = 0
possible_score = 20
print ("In a moment, we will ask you a series of questions relating to Pokémon.")
time.sleep(2)
print ("These questions are in no certain order. Answer them the best you can.")
time.sleep(2)
print ("Good luck...")
time.sleep(3)
while True:
irand = randrange(1, 2)
if irand == '1':
print ("What is the first Pokémon?")
time.sleep(0.5)
print ("A. Trashbag")
time.sleep(0.5)
print ("B. Bulbasaur")
time.sleep(0.5)
print ("C. Arceus")
time.sleep(0.5)
print ("D. Pikachu")
time.sleep(1)
question1 = input ("Your option: ")
question1 = question1.lower()
if question1 == 'b':
score += 1
time.sleep(1)
print ("You got it right!")
if question1 == 'a' or 'c' or 'd':
time.sleep(1)
print ("Sorry you answered incorrectly.")
if irand == '2':
print ("hai")


#Menu Code
def main():
print ("Please select an option when prompted!")
while True:
time.sleep(0.5)
print ("[1] PokéTrivia Test")
time.sleep(0.5)
print ("[2] Credits")
time.sleep(0.5)
print ("[3] Exit")
time.sleep(1)
menu = input ("Please select an option: ")
time.sleep(1)
cls()
#PokéTrivia Game
if menu == '1':
game()
#Credits go to...
if menu == '2':
credit2()
#Quit the game
if menu == '3':
print ("Exiting game...")
time.sleep(1)
break
SystemExit
#Startup Code
if __name__ == "__main__":
print ("PokéTrivia!")
time.sleep(1.5)
print ("Developed by: Oiestin")
time.sleep(2)
print ("In partnership with:")
time.sleep(1.5)
print (" /---------\ ")
print ("| oysterDev |")
print (" \---------/")
time.sleep(2)
cls()
main()

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com