什么是表达式?一条具有明确执行结果的代码语句
表达式例子:1+1;1*1;"xiao"
表达式格式化例子
print("1*1的结果是:%d"%(1*1))
print(f"1*2的结果是:{1*2}")
print("字符串在python中的类型名是:%s"%type("字符串"))
输出如下
如何格式化表达式:1.f"{表达式}" 2.%s,%d,%f % (表达式 表达式 表达式)
总结题目
#定义需要的变量
name="xiao"
stock_price=20.20
stock_code="096756"
#股票 价格 每日 增长 因子
stock_price_daily_groeth_factor=1.2
growth_days=7
finale_stock_price=stock_price ** stock_price_daily_groeth_factor
print(f"公司:{name},股票代码{stock_code},当前股价{stock_price}")
print("每日增长系数:%.1f,经过%d天的增长后,股价达到了:%.2f" % (stock_price_daily_groeth_factor,growth_days,finale_stock_price))
输出如下