|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
Create another function called roll_and_show.
The function should use the throw_dice function to throw the dice.
After that the function should call the show_roll function to show the number you threw as an image.
创建另一个名为 roll_and_show 的函数。
该函数应该使用 throw_dice 函数来掷骰子。
之后,该函数应调用 show_roll 函数以将您投掷的数字显示为图像。
求各位大佬来解!谢谢!
代码正确很好,只是还差 show_row 和 roll_and_show 函数:
- import random
- def show_roll(num):
- image = [
- [
- "*****",
- "* *",
- "* O *",
- "* *",
- "*****"
- ],
- [
- "*****",
- "* O*",
- "* *",
- "*O *",
- "*****"
- ],
- [
- "*****",
- "* O*",
- "* O *",
- "*O *",
- "*****"
- ],
- [
- "*****",
- "*O O*",
- "* *",
- "*O O*",
- "*****"
- ],
- [
- "*****",
- "*O O*",
- "* O *",
- "*O O*",
- "*****"
- ],
- [
- "*****",
- "*O O*",
- "*O O*",
- "*O O*",
- "*****"
- ]
- ]
- for n in image[num - 1]:
- print(n)
- print()
- def throw_dice():
- return random.randint(1,6)
- def roll_and_show():
- show_roll(throw_dice())
- for i in range(3):
- roll_and_show()
复制代码
|
|