小编phh*_*hnk的帖子

有没有办法可以设置python龟的背景颜色?

我正在尝试设置我的乌龟图形的背景颜色,有没有办法可以设置蟒蛇龟的背景颜色?

python turtle-graphics

6
推荐指数
2
解决办法
5万
查看次数

需要帮助我的shuffle卡计划

我正在做一个洗牌计划.最后我for loop用来打印10张随机卡,但我不知道它有什么问题.

最后deal_card(card),为什么我放,card因为我的h/w这样说,但如果你有其他答案,我会很高兴听你说的.

这是我的计划:

import random

def define_cards():
    rank_string = ("ace","two","three","four","five","six","seven","eight","nine","ten","jack","queen","king")
    suit_string = ("clubs","diamonds","hearts","spades")
    cards = []
    for suit in range(4):
        for rank in range(13):
            card_string = rank_string[rank] + " of " + suit_string[suit]
            cards.append(card_string)
        return cards

def create_deck(deck):
    for i in range(52):
        deck.append(i)
        return

def shuffle_deck(deck):
    random.shuffle(deck)
    return

def deal_card(deck):
    return deck.pop(0)

deck=[]

create_deck(deck)
shuffle_deck(deck)
print "The first 10 cards are:"
for i in range(10):             # I don't know why won't work
    deal_card(card) …
Run Code Online (Sandbox Code Playgroud)

python

1
推荐指数
1
解决办法
1万
查看次数

刽子手一词被选中

我试图让用户选择他们想要的单词的长度,但我很难弄清楚出了什么问题.我是Python的菜鸟,我学了3个月,我搜索过Python.我不知道所有Python内置函数或我可能知道但不知道如何使用它们.

这是我的代码:

from random import *
import os


wordlist_1 = 'cat dog'.split()                #Is all the wordlist be in a function to all three of wordlist?
wordlist_2 = 'donkey monkey dragon'.split()   #Like def wordlist():
wordlist_3 = 'dinosaur alligator buffalo'.split()

keep_playing = True
def print_game_rules(max_incorrect,word_len):
    print"You have only 7 chances to guess the right answer"
    return

def length_1():
    print('You will have length of 3 word')
    return
def length_2():
    print('You will have length of 6 word')
    return
def length_3():
    print('You will have length …
Run Code Online (Sandbox Code Playgroud)

python graphics

0
推荐指数
1
解决办法
639
查看次数

标签 统计

python ×3

graphics ×1

turtle-graphics ×1