py

#_cvvh:"chenxi"
#date:  2019/6/24

# for i in range(101):
#     if i < 50 or i > 70:
#         print(i)
# exit_flag = False
# for i in
# username = "chenxi"
# passwed = "testki"

# #h = 9
# for i in range(3):
#     user = input("用户名:")
#     passi = input("密码:")
#     if user == username and passi == passwed :
#         print("登录成功")
#         break
#     else:
#         if i < 2:
#             print("用户名或密码错误")
#         else:
#             print("请重新登录")
# 小于5 不打印
# exit_flag = False   #设置exit_flag初始值
# for i in range(10):
#     if i < 5 :
#         continue  # 结束本次循环
#     print ("chenxi:",i)
#     for j in range(10):
#         print(j)
#         if j == 6 :
#             exit_flag = True# 当j = 6 时;修改exit_flag变量值为True
#             break   #当j=6时跳出循环体
#     if exit_flag: #判断exit_flag=True时,跳出第二层循环体
#         break
# c=['cx','zrd','danier','dne','chenxi','ajt','whd','zrd','qwe'] #定义一个列表,有4个元素
# c.append('hshs')
# c[1]='cfsd'
# print(c)
#c.remove('cx')
# b=c.pop(1)
# print(c)
# print(b)
# print(c.index('danier'))
# first_lg_index= c.index("zrd")
# print(first_lg_index)
# little_list = c[first_lg_index+1:]
# second_lg_index = little_list.index("zrd")
# print(second_lg_index)
# second_lg_index_in_dig_list = first_lg_index + second_lg_index +1
# print(second_lg_index_in_dig_list)
# print(c[second_lg_index_in_dig_list])
# c.reverse()
# x=[5,8,1,3,6,2,7,4]
# x.sort()
# print(x)
all_list = [
    ('mac',9000),
    ('kindle',900),
    ('tesla',800),
    ('python',105),
    ('bile',2000),
]
saving=input('输入价格:')
#判断用户是否输入数字i
if saving.isdigit():
    saving=int(saving)
    # for i in all_list:
    while True:

        for i,v in enumerate(all_list):  #自己添加序号类  ,分别赋值
            # print(all_list.index(i)+1,i)
            print(i+1,'>>>>>',v) #展示商品列表
        choice=input('购买商品编号[退出q]:')
        if choice.isdigit():
            choice=int(choice)  #字符串转换数字
            if choice > 0 and choice<=len(all_list): #判断输入的超出范围
                p_item=all_list[choice-1]
                print(p_item)
            else:
                print('编码不存在')

        elif choice=='q':
            print('退出')

  

上一篇:7.逻辑回归实践


下一篇:7.逻辑回归实践