1、数据类型
1、"" 和‘‘,本质没有什么区别,用的时候看要输出内容,灵活使用
比如:
(1) 输出 let‘s go
print("let‘s go")
(2) 输出 春光长得"很帅"
print(‘春光长得"很帅"‘)
(3)输出 let‘s go,春光长得"很帅"
print(‘‘‘let‘s go,春光长得"很帅"‘‘‘)
(4)输出 ‘‘‘let‘s go,春光长得"很帅"‘‘‘
print("""‘‘‘let‘s go,春光长得"很帅"‘‘‘""")
2、多行注释
(1)选中 然后Ctrl+/
(2)‘‘‘ ‘‘‘
3、数据类型:
name = ‘xiaohei‘#定义变量字符串,string 类型
age = 18 #定义整型
score = 98.8 #浮点数 float
4、条件判断
4.1 单条件判断
#条件判断 if--else
if age >= 18:
print("成年人")
else:
print("还是个宝宝")
4.2 多条件判断
#多种条件判断
score = 98.8
if score >= 90 and score <= 100:
print("优秀")
elif score <90 and score >= 80:
print("良好")
elif score <80 and score >= 60:
print("及格")
elif score < 60:
print("不及格")
else:
print(‘分数不合法‘)
原文:https://www.cnblogs.com/luoxinmoli/p/11497887.html