python代码怎么弄颜色_如何使用python中的Colorama为特定代码添加颜色?

这是我的代码:import colorama

from colorama import Fore, Back, Style

import random

colorama.init()

score = int(0)

#--------------------------------------------------------------------#

q1 = ("Work out the answer. 45 + 46 = ")

q2 = ("Kai buys a pair of shoes for £31 and a shirt for £67. Altogether, he spends £")

q3 = ("Work out the answer. 68 - 29 = ")

q4 = ("A bike normally costs £260. Its price is reduced in a sale by £90. The sale price of the bike is ")

q5 = ("Work out the answer. 32 x 30 = ")

q6 = ("A box holds 22 apples. The total number of apples in 20 boxes are ")

q7 = ("Work out the answer. 70 x 7 = ")

q8 = ("For a school show, 22 chairs are arranged equally in 30 rows. The total number of chairs is ")

q9 = ("A function machine changes 49 to 98 and changes 26 to '?'. The number in the question mark is ")

q10 = ("What number fills the gap? 35 x ? = 105. The number is ")

question = [

(q1, "91"),

(q2, "98"),

(q3, "39"),

(q4, "170"),

(q5, "960"),

(q6, "440"),

(q7, "490"),

(q8, "660"),

(q9, "52"),

(q10, "3")

]

comments = ["Correct, you get one point, onto the next question", "At least I'm not the only smart one around here",

"Well done", "You must be really smart", "Some people have actually failed at that question...",

"Congratulations", "Good work I guess...", "You actually got that right?!"]

bcomments = ["Too bad, I have to take a point away, but I bet you got that wrong on purpose. Right...?",

"I'm stealing your points!","You're a disgrace to mathematics",

"You can't be serious... Can you?","Oops to you too...","Throw me your points!!",

"Did you read the question properly?","Too bad...","I'm running out of ways to take your points...","Did you have to get it wrong??"]

colour = [(Fore.BLACK + Back.WHITE), (Fore.RED + Back.BLUE)]

最后一行是我使用Colorama识别出两种颜色的行

^{pr2}$

如果我想给每个问题加上颜色,我该怎么做?例如,如何编辑代码,使每个问题都以不同的颜色显示?在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值