zoukankan      html  css  js  c++  java
  • python练习

    第三周

    第一题

    list_i=["咖啡","牛奶","咖啡","橘子","苹果","香蕉"]
    print(list_i)
    while True:
        value = input("请输入您要删除的东西:");
        j = 0
        temp = 1
        for i in range(len(list_i)):
            if list_i[j] == value:
                list_i.pop(j)
                temp = 0
            else:
                j += 1
    
        if temp:
            print("没有您要删除的东西")
        print(list_i)
    

    image-20210401130939493

    第二题

    coin=int(input("请输入您的钱币数:"))
    if coin<1500:
        print("您的金额是:",coin)
    else:
        print("您的可乐出来了
    ","剩余金额",coin-1500,"元")
    
    

    image-20210401132117128

    第三题

    a=input("Tell me what your name is.")
    b=input("Tell me where you will go.")
    c=input("Tell me the purpose of travel.")
    d=input("Tell me how long you will stay.")
    print("Name:"+a,"
    ","Destination:"+b,"
    ","Purpose:"+c,"
    ","Length of stay:"+d)
    

    image-20210401132743064

    第四题

    numbers=[273,101,50,200,50,70,150,99,8,1500]
    a=0
    while a<len(numbers):
        print(numbers[a],"是",len(str(numbers[a])),"位数字")
        a=a+1
    
    

    image-20210401133614950

    第五题

    numbers=[273,101,50,200,50,70,150,99]
    b=len(numbers)
    print(numbers)
    print(len(numbers))
    while b:
        a = 0
        if len(str(numbers[a]))>=3:
            print("一百以上的有:", numbers[a])
        a=a+1
        b=b-1
    

    image-20210401134417779

    第六题

    import random
    list=[" Sexiness wears thin after a while and beauty fades, but to be married to a man who makes you laugh every day, ah, now that's a real treat. (Joanne Woodward)",
          "There's a way of transferring funds that is even faster than electronic banking. It's called marriage. (James Holt McGavran)",
          "I've had bad luck with both my wives. The first one left me and the second one didn't.(Patrick Murray)",
          "A good wife always forgives her husband when she's wrong.(Milton Berle)",
          "Marriage is an institution in which a man loses his bachelor's degree and the woman gets her master's.(Socrates)",
          "Marriage is the only war where one sleeps with the enemy.(Anonymous)"
          ]
    from random import choice
    print("-------------------------------------------------
    "
          ,"                    每日一句
    ","-------------------------------------------------
    ")
    print(choice(list))
    

    image-20210401135231495

    第七题

    import random
    l=[random.randint(1,45) for n in range(6)]
    #print(l)
    l.sort(reverse=False)
    print("本期大乐透号码是:
    ",l,"
    恭喜发财!!!
    ")
    
    

    image-20210401141316844

  • 相关阅读:
    python基础008----Python中类/函数/模块的简单介绍
    linux基础004---用户管理、用户登录注销、系统关机重启
    python基础006----流程控制&推导式&深浅拷贝
    python基础005----字典&集合
    python基础004----列表&元组
    难缠的布隆过滤器,这次终于通透了
    C# 位图BitArray 小试牛刀
    以步步为营的风格解读 Redis分布式锁
    你是不是对MD5算法有误解?
    最适合新手的Redis Cluster搭建过程
  • 原文地址:https://www.cnblogs.com/Weber-security/p/14606113.html
Copyright © 2011-2022 走看看