day 02 ---class

# -*- coding: utf-8 -*-
# @Time : 2018/12/20 14:34
# @Author : Endless-cloud
# @Site :
# @File : day 02 作业.py
# @Software: PyCharm
# >>>>1 : 1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
# 解 1 True
#print(1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6)
#>>>>>2 : not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
# 解 2 :False
# print(not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6)
# >>>>3 :8 or 3 and 4 or 2 and 0 or 9 and 7
# 解 3 : 8
# print(8 or 3 and 4 or 2 and 0 or 9 and 7)
# >>>>>>4: 0 or 2 and 3 and 4 or 6 and 0or 3
# 解 4 : 4
# print(0 or 2 and 3 and 4 or 6 and 0 or 3)
# >>>>>>5 : 6 or 2 > 1
# 解 5 : 6 $$$$总结 算大于小于.然后计算or 遵循定律
# print(6 or 2 > 1)
#>>>>>6 :3 or 2 > 1
# 解 6: 3
# print(3 or 2 > 1)
# >>>>>>7: 0 or 5 < 4
# 解 7 : False
# print(0 or 5 < 4)
# >>>>>8: 5 < 4 or 3
# 解 8: 3
# print(5 < 4 or 3)
# >>>>> 9 : 2 > 1 or 6
# 解 9 :True
# print(2 > 1 or 6)
# >>>> 10 : 3 and 2 > 1
# 解 10 : True
# print(3 and 2 > 1)
# >>>>>11 : 0 and 3 > 1
# 解 11 :True X 答案 0
# print(0 and 3 > 1)
# >>>>12 :2 > 1 and 3
# 解 12 :3
# print(2 > 1 and 3)
# >>>>>13 :3 > 1 and 0
# 解13 : 0
# print(3 > 1 and 0)
#>>>>> 14 : 3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2
# 解14 :2
# print(3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2)
# >>>>>>15 : while 循环语句基本结构
'''
while 循环语句基本结构
1
满足条件循环
while 条件
循环体
2
while 条件
循环体
else
### 3个方式
1 改变条件退出
2 break
>continue 退出当前次数循环
3 exit() quit()
'''
# >>>>>>16 :利用while语句写出猜大小的游戏:
# # 设定一个理想数字比如:66,让用户输入数字,如果比66大,
# 则显示猜测的结果大了;如果比66小,则显示猜测的结果小了;
# 只有等于66,显示猜测结果正确,然后退出循环。
# 解 16 :
# num1 = 66
#
# while True:
# conut = int(input('请输入数字'))
# if num1 ==conut:
# print('输入正确')
# break
# elif num1 > conut :
# print('输入小了')
# else:print('输入大了')
# >>>>>>17 :# 6.在5题的基础上进行升级:
# # 给用户三次猜测机会,如果三次之内猜测对了,
# 则显示猜测正确,退出循环,如果三次之内没有猜测正确,
# 则自动退出循环,并显示‘太笨了你...’。
# 解 17
# count = 3
# num1 = 66
# while 0<count<=3:
# count =count -1
# shuru = int(input('请输入一个数字'))
# if num1 ==shuru:
# print('回答正确,退出程序')
# break
# elif num1 >shuru:
# print('小了','你还有 %s 次机会'%(count))
# else:print('大了','你还有 %s 次机会'%(count))
# else:print('么机会了都用完了')
## >>>>>>18 :.使用while循环输出 1 2 3 4 5 6 8 9 10 多种方法,对了就可以。
# 解 18:
# ^^^^^ 方法1
# i = 0
# while True:
# i = i+1
# print(i)
# if i ==10:
# break
# ^^^^ 方法2
# i= 1
# while i<=10:
# print(i)
# i =i+1
# ^^^^ 方法3 标志法
# count = True
# i = 1
# while count:
# print(i)
# i = i + 1
# if i ==11:
# count =False
# >>>>>> 19 :# 8.求1-100的所有数的和(两种方法)
# 解 19 :
# ^^^^方法1
# sun = 0
# i = 1
# while i<101:
# sun = sun +i
# i= i+1
# print(sun)
# ^^^^方法2
# sun1 = 0
# for i in range(101):
# sun1 = sun1 +i
# print(sun1)
# ^^^^方法3
# sun2 = 0
# i = 1
# flag = True
# while flag:
# sun2 = sun2+ i
# i = i+1
# if i ==101:
# flag= False
# print(sun2)
# >>>>>> 20 :输出 1-100 内的所有奇数(两种方法)
# 解 20 :
# ^^^^方法1
# i =0
# while i<101 :
# if i %2==0 :
# print(i)
# i = i +1
# ^^^^方法2
# for i in range(101):
# if i % 2 == 0:
# print(i)
# >>>> 21 : 输出 1-100 内的所有偶数(两种方法)
# 解 21 :
# ^^^^^方法1
# i =0
# while i<101 :
# if i %2==1 :
# print(i)
# # i = i +1
# ^^^^方法2
# for i in range(101):
# if i % 2 == 1:
# print(i)
# >>>>>>>22 : .求1-2+3-4+5 ... 99的所有数的和
# 解 22
# i = 0
# sun = 0
# while i <100:
#
# if i % 2 ==1:
# sun =sun+i
# else:sun =sun-i
# i= i+1

# print(sun)
# >>>>>>23 :12.⽤户登陆(三次输错机会)
# 且每次输错误时显示剩余错误次数(提示:使⽤字符串格式化)
# 解 23
# ^^^^^方法1
# count = 3
# username = 'wang'
# password = '123'
# while 0<count<=3:
# count= count-1
# username1 = input('亲输入账号')
# password1 = input('亲输入密码')
# if username == username1 and password ==password1:
# print('亲登进来了哦')
# break
# else:print('你还有% s次机会哦'%(count))
# else:print('亲你没机会了呢')
#^^^^^^方法2
# username = 'wang'
# password = '123'
# for i in range(3):
# username1 = input('亲输入账号')
# password1 = input('亲输入密码')
# count = 2 -i
# if username ==username1 and password==password1:
# print('亲登录进来了哦')
# break
# else:print('亲账号或者密码错了了呢,你还有%s 次机会了呢'%(count))
# if count ==0 :print('亲都错了呢没机会了的说')
# >>>>>>>>>>24:简述ASCII、Unicode、utf-8编码关系?
# 解 24 :
'''
ASCII是 世界上第一个编码本
由 8位表达 英文,数字,符号
0000 0000
在ascii 中 8 个字符表示1 位
unicode 是万国码 ,期初由16位表达,之后由 32 位表达 ,浪费资源
utf - 8 是最少8位的码 ,中国字由 24位组成
'''
# >>>>>>>>25 简述位和字节的关系?
#解 25 :
'''
8位表示一个字节 ,一个字节表示一个bit
'''
#>>>>>26 :.“⽼男孩”使⽤UTF-8编码占⽤⼏个字节?使⽤GBK编码占⼏个字节?
# 解 26 :
'''
utf -8
9 字节
gbk
6 字节
'''
原文地址:https://www.cnblogs.com/baili-luoyun/p/10150076.html