猫史档案馆


【Python作品分享】新的作品【作品秀】

用户:缘来如此iz57缘来如此iz57查看:0 回复:0 评论:0 创建时间:2023-01-07T21:23:06


【作品展示】

center_image

 

【作品介绍】

喵贩卖机

 

【作品源代码】

import random
import time
n = a = b = c = d = e = f = a7 = 0


def fun(line):
    for i in range(len(line)):
        print("\r"+line[0:i+1], end="")
        time.sleep(0.1)
    print()


print("\033[1;36m欢迎使用\033[1;33m小熊牌\033[1;36m喵自助机!?")
time.sleep(0.5)
fun("每张喵两元,物美价廉")
fun("每次最多购买300张喵?")
fun("自动过滤错误输入信息?")
fun("请您放心使用?")
time.sleep(1)
while True:
    try:
        g = int(input("\n\033[1;33mQ: 您需要购买多少张:"))
        if not (type(g) == type(1) and 1 <= g <= 300):
            1/0
    except:
        print("\033[1A", end="")
        print("\033[K", end="")
        print("\033[1;31m输入有误,请重新输入")
        print("\033[2A", end="")
        time.sleep(1)
        print
        continue
    break
time.sleep(0.5)
print()
print("\033[A")
print("\033[1;37m正在购买中,请等待...")
scale = 15
for i in range(scale+1):
    aaa = '*'*i
    bbb = '.'*(scale-i)
    ccc = (i/scale)*100
    print("\r\033[1;32m{:^3.0f}%[{}->{}]".format(ccc, aaa, bbb), end='')
    time.sleep(0.1)
print("\033[1A")
print("\033[1;37m正在核对中奖喵,请等待...")
print()

print("\033[2A")
for i in range(g):
    time.sleep(0.02)
    if g == 1:
        print("\033[1;32m已完成100%")
    else:
        print("\r\033[1;32m已完成{:.1f}%".format(i/(g-1)*100), end="")
    b = b+1
    a1 = random.randint(0, 9)
    a2 = random.randint(0, 9)
    a3 = random.randint(0, 9)
    b1 = random.randint(0, 9)
    b2 = random.randint(0, 9)
    b3 = random.randint(0, 9)
    if a3 != b3:
        c = c+1

    elif a2 != b2:
        d = d+1
        a = a+5

    elif a1 != b1:
        e = e+1
        a = a+20

    else:
        f = f+1
        a = a+200

n = (d+e+f)/g*100
print("""

""")
print("\033[1;33m统计:")
time.sleep(1)
print("本轮中奖率为:{:.2f}%".format(n))
time.sleep(1)
print("您购买了{}张,消费{}元".format(b, 2*b))
time.sleep(1)
print("核对一共获得:{}元".format(a))
time.sleep(1)
print("未中奖{}次".format(c))
time.sleep(1)
print("获三等奖5元:{}次".format(d))
time.sleep(1)
print("获二等奖20元:{}次".format(e))
time.sleep(1)
print("获一等奖200元:{}次".format(f))
time.sleep(1)
print("您的钱即将入账:\033[1;31m{}元".format(a-2*b))
time.sleep(1)
print("在你的存款没有达到500万之前")
time.sleep(1)
print("你更应该做的是努力学习!")
fun("\033[1;34m感谢您的使用? ")
fun("欢迎下次光临?")
fun("作者:王俊泽")

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页