示例一:
题目:
利用输出语句输出下列语句内容:公司:
ikun股票,股票代码:001314 ,当前股价:2.5 ,每日增长系数:1.2350 ,经过增长7天后,股价达到了:10.954907424。
name ="ikun股票"
#股票当前价格
stock_price =2.5
#股票编号
stock_code ="001314"
#股票每日增长系数
stock_price_daily_factor = 1.235
#增长天数
growth_days = 7
#用一句话输出
print("公司:",name+",股票代码:%s"%stock_code,f",当前股价:{2.5}",",每日增长系数:%.4f"%stock_price_daily_factor,f",经过增长{growth_days}天后,"+"股价达到了:%.9f"%(stock_price*stock_price_daily_factor**growth_days)+"。")
#第一行:f+内容{变量}输出,第二行:用 % 号输出
print(f"公司:{name},股票代码:{stock_code},当前股价:{stock_price}")
print("股票每日增长系数.%4f,增长%d天后,股票的价格为:%.9f"%(stock_price_daily_factor,growth_days,stock_price*stock_price_daily_factor**growth_days))输出结果:
公司: ikun股票,股票代码:001314 ,当前股价:2.5 ,每日增长系数:1.2350 ,经过增长7天后,股价达到了:10.954907424。
公司:ikun股票,股票代码:001314,当前股价:2.5
股票每日增长系数.1.235000,增长7天后,股票的价格为:10.954907424