12.24 python学习笔记

1.算术运算

+  -  *  /  

// —— 结果取整

% ——取余

** —— 幂

2.数学函数

round()—— 四舍五入

abs()——绝对值

import math ——引入math模块

https://www.cnblogs.com/MingleYuan/p/10628503.html

3.if语句

price = 1000000
has_good_credit = True

if has_good_credit:
   down_payment = 0.1 * price
else:
    down_payment = 0.2 * price
print(f"Down payment :{down_payment}")

4.综合案例

weight = int (input(“weight:”))
unit = input ("(L)bs or (K)g: "if unit.upper()=="L"
   converted = weight * 0.45
   print (f"You are {converted} kilos"}
else:
    converted =  weight / 0.45
    print(f"You are {converted} pounds”}
posted @ 2019-12-24 21:15  昨天也没吃饭  阅读(469)  评论(0)    收藏  举报