# 1.要求用戶输入两个数啊a,b,如果a能被b整除或a+b大于1000,
# 则输出a,否则输出b,(无线循环)
# while True:
# a = int(input("请输入a:"))
# b = int(input("请输入b:"))
# if b % a == 0 or a + b > 1000:
# print("a为:", a)
# else:
# print("b为:",b)
# 2.输入一个年份,判断是否为闰年,(闰年成立的第一个条件是可以被整除且
# 不能被100整除,第二个条件可以被400整除的年也是闰年,尝试使用循环)
# while True:
# year = int(input("请输入需要判断的年份:"))
# if year%4==0 and year%100!=0:
# print("%d年是闰年"%year)
# elif year%400==0:
# print("%d年是闰年" % year)
# else:
# print("%d年不是闰年" % year)
# 3.求1-100的和,奇数和,偶数和。
# sum01 = 0
# sum02 = 0
# sum03 = 0
# for i in range(1, 101):
# if i % 2 == 0:
# sum02 += i
# elif i % 2 == 1:
# sum03 += i
# sum01 = sum02 + sum03
# print("1到100和为%d" % sum01)
# print("1到100偶数和为%d" % sum02)
# print("1到100基数和为%d" % sum03)
# 4.根据成绩输出对应的等级
# score = int(input("请输入你的分数:"))
# if 85 <= score <= 100:
# print("恭喜你,你是最优秀的")
# elif 60 <= score < 85:
# print("及格万岁")
# elif 0 <= score < 60:
# print("不及格,回家种田吧")
# else:
# print("请输入合格的分数")
# 5.自动拨号
# num = int(input("请输入要拨打的号码对应的num:"))
# if num == 1:
# print("拨爸爸的号")
# elif num == 2:
# print("拨妈妈的号")
# elif num == 3:
# print("拨爷爷的号")
# elif num == 4:
# print("拨奶奶的号")
# else:
# print("未定义")
# 6.输出所有三位回文数
# for i in range(100, 1000):
# if str(i) == str(i)[::-1]:
# print(i)
# 7.三角及9*9乘法表
# for i in range(1, 6):
# print("*"*i)
#
# for i in range(1, 10):
# for j in range(1, i+1):
# print("%dX%d=%d" % (j, i, i * j), end=" ")
# print()
# 8.季节判断
# month = int(input("请输入月份:"))
# for month in range(1, 13):
# if 3 <= month <= 5:
# print("第%d月是春" % month)
# elif 6 <= month <= 8:
# print("第%d月是夏" % month)
# elif 9 <= month <= 11:
# print("第%d月是秋" % month)
# else:
# print("第%d月是冬" % month)
# 9.水仙花
# for i in range(100, 1000):
# bai = int(str(i)[0])
# shi = int(str(i)[1])
# ge = int(str(i)[2])
# if bai**3 + shi**3 + ge**3 == i:
# print(i)
# 10 键盘输入
# name = input("请输入自己的姓名:")
# home = input("请输入自己的家乡:")
# age = int(input("请输入自己的年龄:"))
# if age >= 18:
# print("哥叫%s,已成年,来自%s,终于可以执剑走天涯了" % (name, home))
# else:
# print("还未断奶,果断回家吃奶")
# 11.判断能否进动物园
# high = int(input("请输入你的身高:"))
# if high <= 150:
# print("不用买票喽")
# else:
# print("请购票")
# 12 公交题
# money = int(input("请输入余额:"))
# if money >= 2:
# print("可以上车")
# zuowei = int(input("请输入座位数:"))
# if zuowei > 0:
# print("请找坐就坐")
# else:
# print("请扶稳站好")
# else:
# print("余额不足,请充值")
# 13.
# a = 10
# b = 20
# c = 30
# if a > b:
# print("a大于b")
# else:
# print("a小于b")
# if a > c:
# print("a大于c")
# else:
# print("a小于c")
# if b > c:
# print("b大于c")
# else:
# print("b小于c")
# 课堂作业
# 1.
# str = "helloword"
# print(str[::-1])
# 2.
# str = "my name is baobao"
# print(str.replace(" ", ","))
# 3.
# str = "HELLO WORD HELLO PYTHON"
# print(str.lower())
# 4.
# str = " "
# li = ["lisi", "love", "xuexi"]
# print(str.join(li))
"""
经典面试算法题----股票问题
1.给定一天内的股票情况,从中选择一个买点买和一个卖点买,
求盈利的最大值,最小值,亏损的最大值,最小值等
注:卖点不能在买点之前
有些面试官还会要求不能使用python自定义的方法
"""
list01 = [27, 58, 95, 54, 87, 63, 99, 56, 12, 59, 30]
list02 = []
list03 = []
for index in range(1, len(list01)):
yinli = list01[index] - min(list01[:index+1])
if yinli == 0:
continue
list02.append(yinli)
kuisong = max(list01[:index+1]) - list01[index]
if kuisong == 0:
continue
list03.append(kuisong)
print(list02)
print("盈利的最大值为%d" % max(list02))
print("盈利的最小值为%d" % min(list02))
print(list03)
print("亏损的最小值为%d" % min(list03))
print("亏损的最大值为%d" % max(list03))