• python 2018全国自学考试第5章 第36题。好激动呀 排名23310


    在这里插入图片描述

    成功了。下面是代码。兄弟们话不多说。上代码

    import random as ra
    
    lottery_num = 0
    guess_num = 0
    print("This game scissor(0),rock(1),paper(2).")
    count_guess = 0
    count_lottery = 0
    lot_t = ""
    gue_t = ""
    while count_lottery <= 2 or count_guess <= 2:
        lottery_num = ra.randint(0, 2)
        guess_num = ra.randint(0, 2)
        if lottery_num == 0:
            lot_t = "剪子"
        elif lottery_num == 1:
            lot_t = "石头"
        elif lottery_num == 2:
            lot_t = "布"
    
        if guess_num == 0:
            gue_t = "剪子"
        elif guess_num == 1:
            gue_t = "石头"
        elif guess_num == 2:
            gue_t = "布"
    
        print(f"The Computer show {lot_t} and User show {gue_t}.")
        # this base text show
        if lottery_num == 0 and guess_num == 2:
            print(f"The Computer is {lot_t}, and User is {gue_t} This game is computer win.")
            count_lottery += 1
        elif lottery_num == 2 and guess_num == 0:
            print(f"The Computer is {lot_t}, and User is {gue_t} This game is User win.")
            count_guess += 1
        elif lottery_num > guess_num:
            print(f"The Computer is {lot_t}, and User is {gue_t} This game is computer win.")
            count_lottery += 1
        elif lottery_num < guess_num:
            print(f"The Computer is {lot_t}, and User is {gue_t} This game is User win.")
            count_guess += 1
        # This program not result to draw. so this is content become note text!!
        elif lottery_num == guess_num:
            print(f"The Computer is {lot_t}, and User is {gue_t} This game are draw.")
        # success this program
        if count_lottery == 2 and count_guess < 2:
            print("This game Computer is Winner.")
            break
        elif count_lottery < 2 and count_guess == 2:
            print("This game User is Winner.")
            break
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50

    结果如下

    在这里插入图片描述

  • 相关阅读:
    myBatis
    SI好文翻译:铜表面纹理对损耗的影响:一个有效的模型(一)
    垃圾回收 - 复制算法
    centos7.8 开启mysql3306端口
    七大基于比较的排序算法(JAVA)
    Nginx配置SSL证书
    数学建模之插值法
    微信又更新啦,再也不怕错过女朋友的消息
    Python中*args 和**kwargs的用法
    vue3 自定义指令
  • 原文地址:https://blog.csdn.net/m0_37228426/article/details/126604320