Python 1 - 常量,变量,基本类型

第01节 介绍

第02节 安装

第03节 猜数字游戏-1

第04节 变量

第05节 猜数字游戏 2

from numpy import random
    end_flag = False
    num_try = 3
    answer = random.randint(0,9)
    while num_try > 0 and not end_flag:
        # 使用input的时候,最好用isinstance判断数据类型
        guess = int(input("please input your guessed number"))
        if guess == answer:
            print("hey, Bingo.")
            print("But... nothing")
            end_flag = True
        elif guess > answer:
            print("your number is too large")
            num_try = num_try - 1
        else:
            print("your number is too small")
            num_try = num_try - 1
    print("----- game over -----")
    print("The answer is ", answer)
    if num_try > 0:
        print("you fucking smart!")
    else:
        print("poor you!")

第06节 基本数据类型

Table of Contents