自学python 2.
1.T or F
1>1 or 3<4 or 4>5 and 2>1 and 9>8 or 7<6
t
not 2>1 and 3<4 or 4>5 and 2>1 and 9>8 or 7<6
f 2.值
8 or 3 and 4 or 2 and 0 or 9 and 7
8
0 or 2 and 3 and 4 or 6 and 0 or 3
4 3.结果
6 or 2>1 #6
3 or 2>1 #3
0 or 5<4 #F
5<4 or 3 #3
2>1 or 6 #T
3 and 2>1 #T
0 and 3>1 #0
2>1 and 3 #3
3>1 and 0 #0
3>1 and 2 or 2<3 and 3 and 4 or 3>2 #t and 2 or t and 3 and 4 or t=2 or 4 or t=2 or t=2 4.while 循环语句基本结构
while 条件:
循环体(代码块)
else:
条件为假 5.猜大小
while True:
a = int(input("输入数字:"))
if a>66:
print("大")
elif a<66:
print("小")
else:
print("正确")
break 6.3次机会
n = 3
while n>0:
a = int(input("输入数字:"))
if a>66:
print("大")
elif a<66:
print("小")
else:
print("正确")
break
n-=1
print("剩余机会:%d次" % n)
else:
print("太笨了") 7.输出1 2 3 4 5 6 8 9 10
(1)n = 1
while n<11:
if n==7:
n+=1
continue
print(n)
n+=1 (2)n = 1
while n<11:
if n != 7:
print(n)
n+=1 8.1-100和
n = 1
s = 0
while n<=100:
s = s + n
n+=1
print(s) 9.1-100奇数
n = 1
while n<=100:
if n%2 == 0:
n+=1
continue
else:
print(n)
n+=1 10.1-100偶数
n = 1
while n<=100:
if n%2 == 1:
n+=1
continue
else:
print(n)
n+=1 11.1-2+3-4+5..99的和
(1)n = 1
a = 0
while n <= 99:
a = a + n
n+=2
n = 2
b = 0
while n <= 99:
b = b + n
n += 2
print(a-b) (2)n = 1
s = 0
while n < 100:
if n%2 == 0:
s = s - n
else:
s = s + n
n+=1
print(s) 12.3次登录,剩余次数
c = 1
while c <= 3:
name = input("用户名:")
pw = input("密码:")
if name == "zjx" and pw == "123":
print("登录成功!")
break
else:
print("登录失败!")
print("剩余次数:%s" % (3 - c))
c += 1
else:
print("登录错误") 13.过敏词汇
num = input("请输入广告词汇:")
if ("最" or "第一" or "国家" or "稀缺") in num:
print("过敏词汇!")
else:
print("正确!")
自学python 2.的更多相关文章
- 【转载】如何系统地自学 Python?
原文:如何系统地自学 Python? 作者:彭猫 本文由 知乎 彭猫 授权发布,版权所有归作者,转载请联系作者! 是否非常想学好 Python,一方面被琐事纠缠,一直没能动手,另一方面,担心学习成本太 ...
- 420小时学习代码之后:如何教你免费自学Python
原文地址:learning-to-code-420-hours-later-how-to-teach-yourself-python-for-free 说明:有些网址需要FQ. 大约在1.5年前,我开 ...
- 你是如何自学 Python 的?
作为一名Python爱好者,我也想跟大家分享分享我自学Python的一些小经验.搬来你的小板凳,听听看吧.也许,你会很有收获,也许你也走上了自学Python的不归路.开讲啦~ 首先,你要有自信心,要明 ...
- 如何自学Python?
关于如何自学Python,我也是有话说的.来看看? Python具有丰富和强大的类库,常被称为胶水语言.而且语法简洁而清晰,功能强大且简单易学,因而得到了广泛应用和支持.它特别适合专家使用,也非常适 ...
- 自学Python之路
自学Python之路[第一回]:初识Python 1.1 自学Python1.1-简介 1.2 自学Python1.2-环境的搭建:Pycharm及python安装详细教程 1.3 ...
- 自学Python的经验之谈,学好Python的捷径
其实python非常适合初学者入门.相比较其他不少主流编程语言,有更好的可读性,因此上手相对容易.自带的各种模块加上丰富的第三方模块,免去了很多“重复造轮子”的工作,可以更快地写出东西.配置开发环境也 ...
- 如何系统地自学 Python?
最近开始系统的学习Python,以及整理的一些资料.github记录着个人自学 Python 的过程,持续更新.欢迎大家一起来完善这个自学Python学习的项目,给后来者一个参考的学习过程.githu ...
- 自学Python Day1
Day1: 强制转换,打印类型.Python2(row input)=Python3 input input(Python2)不接受强制转换,输入和输出是一致的.加双引号是字符串,不加 ...
- 自学Python之路-Python核心编程
自学Python之路-Python核心编程 自学Python之路[第六回]:Python模块 6.1 自学Python6.1-模块简介 6.2 自学Python6.2-类.模块.包 ...
- 自学Python之路-Python基础+模块+面向对象+函数
自学Python之路-Python基础+模块+面向对象+函数 自学Python之路[第一回]:初识Python 1.1 自学Python1.1-简介 1.2 自学Python1.2-环境的 ...
随机推荐
- Java 枚举 的学习
在JDK5.0之后,引进了一种与C语言相通的枚举类型. 所谓枚举类型就是指含有一组具有固定值, 并且容量有限的数据集合. 例如,定义一个星期的枚举类型, 从周一到周日是具有固定大小和固定值的集合 pu ...
- Mysql数据库操作笔记
如果数据库表字段存在,则删除该表 drop table if exists `table_name` 创建数据库表语句 create table `table_name`( `id` ) not n ...
- Swarm平滑升级回滚
#滚动更新创建服务: docker service create --name my_web --replicas=5 nginx:1.12更新为1.14 docker service update ...
- Atlantis HDU - 1542 (扫描线,线段树)
扫描线的模板题,先把信息接收,然后排序,记录下上边和下边,然后用一条虚拟的线从下往上扫.如果我扫到的是下边,那么久用线段树在这个区间内加上1,表示这个区间现在是有的,等我扫描到上边的时候在加上-1,把 ...
- hdu 1686 Oulipo (kmp)
Problem Description The French author Georges Perec (1936–1982) once wrote a book, La disparition, w ...
- Quick Guide to Microservices with Spring Boot 2.0, Eureka and Spring Cloud
https://piotrminkowski.wordpress.com/2018/04/26/quick-guide-to-microservices-with-spring-boot-2-0-eu ...
- Linux下Chrome/Chromium窗口边框有白线
原因 窗口边框有白线是因为没有开启使用系统边框和标题栏 解决方法 勾选菜单-设置-外观-使用系统标题栏和边框 效果展示
- 如何写一个通用的README规范
背景 我们平常在进行项目开发时,一般都会把代码上传至代码托管平台上方便管理和维护.目前我厂使用的托管平台是SVN,国内外还有一些比较知名的代码托管平台,比如github.Gitlab.BitBucke ...
- django基于存储在前端的token用户认证
一.前提 首先是这个代码基于前后端分离的API,我们用了django的framework模块,帮助我们快速的编写restful规则的接口 前端token原理: 把(token=加密后的字符串,key= ...
- Linux常用基本命令(less)
转: Linux常用基本命令(less) LESS:跟more命令的功能类似,都是用于分页显示内容,但是他的性能比more更高,功能比more更丰富,他读取文件是按需加载 格式: less [opti ...