Commit 530f8bdc by masiluo

second homework

parent 1dfb2250
#山脉数组下标获取
list1 = [0,3,2,1,0]
print(list1.index(max(list1)))
#设计针对于给定数据的规则,并通过正则以及条件控制来完成
import re
while True:
reg = input('请输入问题:')
if (re.findall('贪心',reg) or re.findall('贪心学院',reg)) and re.findall('做什么',reg):
print('贪心学院是一家高端重视售后服务的在线教育培训机构')
elif re.findall('项目式',reg):
print('项目式培训')
elif (re.findall('贪心',reg) or re.findall('贪心学院',reg)) and re.findall('课程',reg) and re.findall('方式',reg):
print('贪心学院的项目式培训结合了西方项目式培训的优点和国内的现状,最终变化成以训练营的方式进行。做项目为主,老师负责解决部分知识的问题,学生负责自学部分知识,和不停的做项目,把知识巩固。在项目练习中,不仅仅学习到了知识,同时也培养起来良好的学习习惯和解决问题的能力。')
elif re.findall('强',reg):
print('贪心学院')
elif re.findall('Python',reg) and re.findall('课程',reg) and re.findall('学习',reg):
print('无编程基础,并且想学习编程的同学。')
elif re.findall('Python',reg) and re.findall('人群',reg):
print('人群包含很广泛。')
elif re.findall('优势',reg):
print('强大的服务体系,我们拥有每天跟学员沟通的良好服务机制。')
elif re.findall('\d',reg) and re.findall('数字',reg):
print('总共有:',len(re.findall('\d',reg)),'个')
elif re.findall('号码',reg) and re.search('(((13[0-9])|(18[0-9])|(17[0-9]))\d{8}\,){1,9}',reg).group(0):
result = re.search('(((13[0-9])|(18[0-9])|(17[0-9]))\d{8}\,){1,9}',reg).group(0)
print(result)
elif re.findall('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}',reg):
print('总共有:',re.findall('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}',reg))
elif re.findall('bye',reg) or re.findall('拜拜',reg) or re.findall('再见',reg):
print('再见')
break
#大小排序
list1 = [4,6,5,4,3,225,634,653,0]
for i in range(0,len(list1)-1):
for j in range(0,len(list1)-i-1):
if list1[j] > list1[j+1]:
list1[j],list1[j+1] = list1[j+1],list1[j]
print(list1)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment