# -*- coding: utf-8 -*-
# @Time : 2018/12/27 10:10
# @Author : Endless-cloud
# @Site :
# @File : 第一周所有左右作业重做.py
# @Software: PyCharm
'''
用的是and 和or的知识点,
() >not >and >or
and 与 T and T 为T 其他为假,
or 只有两边都为F 是才为F
'''#判断True 和Flase
# 1)1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
# 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
# False
# print(not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6)
'''
知识点
or 如果or 前面不是0 那么返回or 前面的值 ,如果是0 那么返回or 后面的值
and 和or 相反
'''
# 2.求出下列逻辑语句的值。
#8 or 3 and 4 or 2 and 0 or 9 and 7
8
# print(8 or 3 and 4 or 2 and 0 or 9 and 7)
# 2),0 or 2 and 3 and 4 or 6 and 0 or 3
# 0 正确答案: 4 # XXXXX
# print(0 or 2 and 3 and 4 or 6 and 0 or 3)
# print(0 and 3)
# print(1 and 3)
# print(0 or 3)
# print(1 or 3 )
'''
知识点
先判断 大小于号, 之后再按照,and 和or 的操作
'''
#3 # 3.下列结果是什么?
# 1)、6 or 2 > 1
6
# print(6 or 2 > 1)
# 2)、3 or 2 > 1
# 3
# print(3 or 2 > 1)
# 3)、0 or 5 < 4
# False
# print(0 or 5 < 4)
# 4)、5 < 4 or 3
3
# print(5 < 4 or 3)
# 5)、2 > 1 or 6
# True
# print(2 > 1 or 6)
# 6)、3 and 2 > 1
# 3 正确:True XXXX
# print(3 and 2 > 1)
# 7)、0 and 3 > 1
# True 正确:0 XXXX
# print(0 and 3 > 1)
# 8)、2 > 1 and 3
# 3
# print(2 > 1 and 3)
# 3 > 1 and 0
# 0
# print(3 > 1 and 0)
# 10)、3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2
# 2
# print(3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2)
'''
改变while 3个条件
改变条件,
quit() exit()
break
'''
# 4.while循环语句基本结构?
# while 条件 :
# 代码块
# 5.利用while语句写出猜大小的游戏:
# 设定一个理想数字比如:66,让用户输入数字,
# 如果比66大,则显示猜测的结果大了;如果比66小,
# 则显示猜测的结果小了;只有等于66,显示猜测结果正确,然后退出循环。
# while True:
# number = 66
# chiose = input('请输入数字')
# if chiose.isdigit():
# chiose_num = int(chiose)
# if chiose_num>66:
# print('dale')
# else:print('xuaike')
# sun = 0
# for i in range(101):
# sun +=i
# print(sun)
# for i in range(1,101,2):
# print(i)
# sun = 0
# for i in range(100):
# if i %2 ==0:
# sun-=i
# else:sun+=i
# print(sun)
# name = "aleX leNb"
# # l2 =name.strip('ab')
# # print(l2)
# # l3 =name.replace('l','L',1)
# # print(l3)
# l3 =name.split('l',1)
# name.is
# 2,有字符串s = "123a4b5c"
# 1)通过对s切片形成新的字符串s1,s1 = "123"
# 2)通过对s切片形成新的字符串s2,s2 = "a4b"
# 3)通过对s切片形成新的字符串s3,s3 = "1345"
# 4)通过对s切片形成字符串s4,s4 = "2ab"
# 5)通过对s切片形成字符串s5,s5 = "c"
# 6)通过对s切片形成字符串s6,s6 = "ba2"
# s = "123a4b5c"
# print(s[0:3])
# print(s[3:6])
# print(s[::2])
# print(s[1:-2:2])
# print(s[-1:])
# print(s[-3:0:-2])
# 如:content = input("请输入内容:") 用户输入:5+9或5+ 9或5 + 9,然后进行分割再进行计算。两种方式
# content =input('请输入内容').strip()
# new_list =content.split()
# print(int(new_list[0])+int(new_list[2]))
# 10、写代码,完成下列需求:
# 用户可持续输入(用while循环),用户使用的情况:
# 输入A,则显示走大路回家,然后在让用户进一步选择:
# 是选择公交车,还是步行?
# 选择公交车,显示10分钟到家,并退出整个程序。
# 选择步行,显示20分钟到家,并退出整个程序。
# 输入B,则显示走小路回家,并退出整个程序。
# 输入C,则显示绕道回家,然后在让用户进一步选择:
# 是选择游戏厅玩会,还是网吧?
# 选择游戏厅,则显示 ‘一个半小时到家,爸爸在家,拿棍等你。’并让其重新输入A,B,C选项。
# 选择网吧,则显示‘两个小时到家,妈妈已做好了战斗准备。’并让其重新输入A,B,C选项。
# while
# 11、写代码:计算 1 - 2 + 3 ... + 99 中除了88以外所有数的总和?
# dic ={}
# dic1={}
# l1='123'
# l2=666
# dic.fromkeys('123',666)
# print(dic)
# l2 = dic1.fromkeys(l1,l2)
# print(l2)
# l2 ='1,2,3'
# l3 =l2.split(',')
# print(l3)
# l1 =['1', '2', '3']
# # l2 =','.join(l1)
# # print(l2)
lis = [['哇',['how',{'good':['am',100,'99']},60],'I']]
#将am 大写
# lis[0][1][1]['good'][0] = lis[0][1][1]['good'][0].upper()
# print(lis)
#将100通过数字相加转化成10010 在转化成字符串
# lis[0][1][1]['good'][1]=int(str(lis[0][1][1]['good'][1])+'10')
# lis[0][1][1]['good'][1]=str(lis[0][1][1]['good'][1]+10010-100)
#将99通过字符串替换的方式换成66
# lis[0][1][1]['good'][2]=lis[0][1][1]['good'][2].replace('99','66')
# print(lis)
# dic = {'k1':'v1','k2':['alex','sb'],(1,2,3):{'k3':['2',100,'wer']}}
#将k3 对应的值最后面追加一个元素'23'
# dic[(1,2,3)]['k3'].append('23')
# print(dic)
# 将k2 对应0 的位置上插入元素'a'
# dic['k2'].insert(0,'a')
# print(dic)
# #将(1,2,3)对应得值添加一个键值对'k4','v4'
# dic[(1,2,3)]['k4']='v4'
# print(dic)
#
# for i in range(100,-1,-1):
# print(i)
#生成1-3+5-7 到100
# i =0
# sun =0
# lis =[]
# while i <100:
# if i%2 ==1:
# lis.append(i)
# i = i +1
# print(lis)
# for i in range(len(lis)):
# if i %2==1:
# sun =sun-lis[i]
# else:sun =sun + lis[i]
# print(sun)
# fuhao =1
# sun = 0
# for i in range(1,100,2):
# sun =sun +i*fuhao
# fuhao=-1*fuhao
# print(sun)
# dic ={'周杰伦':8000,'林俊杰':5000,'太白':5,'alex':5}
# sun =0
# pinjun = 0
# dic2 ={}
# for i,j in dic.items():
# sun =j+sun
# # print(sun)
# pinjun =sun/len(dic)
# print(pinjun)
# for j in dic:
# if dic[j] >pinjun:
# dic2[j] =dic[j]
#
# print(dic2)
# with open('f:/a.txt','r',encoding='utf-8') as f1:
# l2 =f1.readlines()
# l3 =l2[1:]
# lis1 =[]
# title = l2[:1:][0].strip().split(',')
# print(title)
# for i in title :
# dic = {}
# for j in l3:
# l1 = j.strip().split(',')
# dic =dict(zip(title,l1))
# lis.append(dic)
# for i in l3:
# lis =i.strip().split(',')
# dic ={}
# for j in range(len(title)):
# dic[title[j]]=lis[j]
# lis1.append(dic)
# print(lis1)
# 敏感词汇过滤
# int_put = input('请输入内容')
# lis = ['苍井空','小泽玛利亚','明日香','天海翼','真白稚名']
# for i in lis:
# if i in int_put:
# int_put =int_put.replace(i,len(i)*'*')
# print(int_put)
# 求所有的质数的和
# 质数指的是除了1 以外,还有本身的能整除的数
# lst =[11,8,16,8,5,44,7,5,3]
# # n =11
# sun =0
# lis2 =[]
# for n in lst:
#
# for i in range(2,n):
# if n%i ==0:
# # print('这是一个不是质数')
# break
# else:
# sun =sun + n
# print(sun)
# 求1到100所有质数的和
# sun =0
# for n in range(1,101):
# for i in range(2,n):
# if n %2==0:
# break
# else:sun+=n
# print(sun)
''''
整理到博客上
'''
#求每个省有多少量车
cars =['鲁A123','鲁A322','京B342','黑C131','黑C323','沪V3123','黑C244']
locations ={'沪':'上海','黑':'黑龙江','鲁':'山东','鄂':'湖北','湘':'湖南','京':'北京'}
result ={}
for pai in cars:
result[locations[pai[0]]] =result.get(locations[pai[0]],0) +1
print(result)
# '''
# # 7. 按要求完成下列转化。(8分)
# # list3 = [
# # {"name": "alex", "hobby": "抽烟"},
# # {"name": "alex", "hobby": "喝酒"},
# # {"name": "alex", "hobby": "烫头"},
# # {"name": "alex", "hobby": "Massage"},
# # {"name": "wusir", "hobby": "喊麦"},
# # {"name": "wusir", "hobby": "街舞"},
# # ]
# # list4 = [
# # {"name": "alex", "hobby_list": ["抽烟", "喝酒", "烫头", "Massage"]},
# # {"name": "wusir", "hobby_list": ["喊麦", "街舞"]},
# # ]
# # 将list3 这种数据类型转化成list4类型,你写的代码必须支持可拓展,
# # 比如list3 数据在加一个这样的字典{"name": "wusir", "hobby": "溜达"},
# # 你的list4{"name": "wusir", "hobby_list": ["喊麦", "街舞", "溜达"],
# # 或者list3增加一个字典{"name": "太白", "hobby": "开车"},
# # 你的list4{"name": "太白", "hobby_list": ["开车"],无论按照要求加多少数据,
# # 你的代码都可以转化.如果不支持拓展,则4分,支持拓展则8分
# '''
# list3 = [
# {"name": "alex", "hobby": "抽烟"},
# {"name": "alex", "hobby": "喝酒"},
# {"name": "alex", "hobby": "烫头"},
# {"name": "alex", "hobby": "Massage"},
# {"name": "wusir", "hobby": "喊麦"},
# {"name": "wusir", "hobby": "街舞"},
# ]
# list4 = [
# {"name": "alex", "hobby_list": ["抽烟", "喝酒", "烫头", "Massage"]},
# {"name": "wusir", "hobby_list": ["喊麦", "街舞"]},
# ]
# resust =[]
# for el in list3: #{'name': 'alex', 'hobby': '抽烟'}
# for new_el in resust:
# if el['name'] ==new_el['name']:
# new_el['hobby_list'].append(el['hobby'])
# break
#
# else:
# resust.append({'name':el['name'],'hobby_list':[el['hobby']]})
# #[{'name': 'alex', 'hobby_list': ['抽烟']},
# print(resust)
年与时驰,意与日去,遂成枯落,
多不接世,悲守穷庐,将复何及。