我正在做一个随机数字猜谜游戏,我想知道当你的猜测小于或小于答案时,它会打印出类似"关闭!答案是(答案)"的内容
import random
while True:
dicesize = raw_input('What size die do you want to guess from?>')
number = random.randrange(1, int(dicesize))
guess = raw_input('What is your guess?>')
if int(guess) == number:
print 'Correct!'
print " "
# less than 3 print "close"?
# more than 3 print "close"?
else:
print 'Nope! The answer was', number
print " "
Run Code Online (Sandbox Code Playgroud)
(我有打印""在每个循环之间留出空格)
我正在为学校的计算机俱乐部制作一个小马里奥。(好吧,作为团队的一员。)无论如何,我在使用“keyup/keydown”命令时遇到了一些麻烦。这是我的代码:
# 1 - Import library
import pygame
from pygame.locals import *
# 2 - Initialize the game
pygame.init()
width, height = 1280, 1000
screen=pygame.display.set_mode((width, height))
keys = [False, False, False, False]
playerpos=[100,100]
# 3 - Load images
player = pygame.image.load("images/totallynotgodzilla.png")
# 3.1 - Load Audio
music = pygame.mixer.Sound("audio/skyrim.wav")
# 4 - keep looping through
while 1:
# 5 - clear the screen before drawing it again
screen.fill(0)
# 6 - draw the screen elements
screen.blit(player, playerpos)
# 7 - …
Run Code Online (Sandbox Code Playgroud)