黑马程序员python教程,8天python从入门到精通,学python看这套就
Day01:
第一阶段-第二章-03-变量 P16 - 11:44

代码如下:
# Day01 变量练习
money = 50
print("当前钱包余额:", money, "元")
# 冰淇淋10元
ice_cream = 10
print("购买冰淇淋,花费:", ice_cream, "元")
# 可乐5元
coke = 5
print("购买了可乐,花费:", coke, "元")
print("最终,钱包剩余:", money - ice_cream - coke, "元")

第一阶段-第二章-13-对表达式进... P26 - 07:26

代码如下:
name = "传智播客" # 公司名
stock_price = 19.99 # 当前股价
stock_code = "003032" # 股票代码
stock_price_daily_growth_factor = 1.2 # 股票每日增长系数
growth_days = 7 # 增长天数
after_growth_price = stock_price * stock_price_daily_growth_factor ** growth_days
# f"{变量}的方式"
print(f"公司:{name},股票代码:{stock_code},当前股价:{stock_price}")
# % 占位符的方式
print("每日增长系数是:%.2f,经过%d天的增长后,股价达到了:%.2f" % (stock_price_daily_growth_factor, growth_days, after_growth_price))

第一阶段-第二章-15-数据输入(input语句) P28 - 09:36

代码如下:
user_name = input("请输入用户名:")
user_type = input("请输入用户类型:")
print(f"您好:{user_name},您是尊贵的:{user_type}用户,欢迎您的光临!")


