python竞猜商品价格random模块运用
说明:
python竞猜商品价格,主要是随机数和分支结构的运用
实例:
import random price = random.randint(1000,1500) print("今日竞猜的商品为小米扫地机器人,价格在[1000-1500]之间:") guess = int(input()) if guess>price: print('大了') elif guess<price: print('小了') else: print('猜对了') print('商品真实价格为:',price)