摘要: # for循环 for n in [1, 2, 3, 4, 5]: print(n)# for 变量 in 可迭代对象: 变量每一次循环都会等于对象中的一项 # 遍历: 依次访问到 可迭代对象中的每一项 # 可迭代对象: 可以被遍历的对象。 例如列表,字符串,序列 for n in [1,2,3]: 阅读全文
posted @ 2018-10-24 22:29 pypi111258 阅读(106) 评论(0) 推荐(0) 编辑
摘要: # while循环语句 # if True: # print('hello') # while True: # print('hello') """ while <条件> 如果条件为True,那么会重复运行while语句块中的内容。 如果while循环的条件一直未True,死循环 """ # whi 阅读全文
posted @ 2018-10-24 22:19 pypi111258 阅读(101) 评论(0) 推荐(0) 编辑
摘要: # 简单输出 print('您好小明') print('您好小红') print('您好小李') # 带变量的输出 # 更有灵活性,易于维护,好处参考excercise1-3 name = '小明' print(name)# 加好拼接字符串 pay = '8' print('花费一共' + pay 阅读全文
posted @ 2018-10-24 21:43 pypi111258 阅读(267) 评论(0) 推荐(0) 编辑
摘要: # 判断变量类型 # 类型不同,input() 用户输入 返回的是字符串 # '1' + 3 '小明考了' + 90 报错 # type() 判断变量类型 a = 1 b = 1.5 c = 'hello word' d = True type(a) #<class 'int'> type(b) # 阅读全文
posted @ 2018-10-24 20:37 pypi111258 阅读(91) 评论(0) 推荐(0) 编辑
摘要: number = 20 user_number = int(input('请输入一个数字:'))if user_number > number: print('猜大了')elif user_number < number: print('猜小了') else: print('猜对了')""" inp 阅读全文
posted @ 2018-10-24 19:47 pypi111258 阅读(116) 评论(0) 推荐(0) 编辑
摘要: age = 10 if age >18: print('是成年人') else: print('未成年人') score = 60 if score>100 or score= 90:print('优秀') elif 90 > score >= 75: print('良') elif 75 > score >=60: print('及格') elif score nu... 阅读全文
posted @ 2018-10-24 19:29 pypi111258 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 注释语法 #开头 可以用来写评论,标注,临时 #多行注释 ctrl + / 多行注释 取消 同理 ctrl + shift + f10 运行 三引号注释 """ 注释 """ 阅读全文
posted @ 2018-10-24 18:13 pypi111258 阅读(116) 评论(0) 推荐(0) 编辑
摘要: python下载地址:https://www.python.org/ 我们下载最新的版本,点击安装即可,但是注意勾选添加路径到系统path,这样我们在cmd中可以在任何位置执行py程序 。 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 可以把python2.x和python3.x的路径都设置到系统变量值,这样我们 阅读全文
posted @ 2018-10-24 17:24 pypi111258 阅读(257) 评论(0) 推荐(0) 编辑