zoukankan      html  css  js  c++  java
  • 3-课后习题记录-就放这里了

    # 1、 使用while循环输入1 2 3 4 5 6   8 9 10
    count = 1
    while count <= 10:
        if count != 7:
            print(count)
        count += 1
    
    # 2、求1-100的和
    count = 1
    sum = 0
    while count <=100:
        sum += count
        count += 1
    print(sum)
    
    # 3、输出1-100的所有奇数
    count = 1
    while count <= 100:
        if count % 2:
            print(count)
        count += 1
    
    # 4、输出1-100的所有偶数
    count = 1
    while count <= 100:
        if count % 2 == 0:
            print(count)
        count += 1
    
    # 5、求1-2+3-4+5 ... 99的所有数的和
    count = 1
    sum = 0
    while count < 100:
        if count % 2 ==1:
            sum += count
        else:sum -= count
        count += 1
    print(sum)
    
    # 6、用户登录(失败则重试三次)
    users = {'wangjing':'jingjing','wangxiao':'xiaoxiao'}
    
    count = 1
    while count <=3:
        username = input('请输入您的用户名:')
        pasword = input('请输入您的密码:')
        if username in users.keys() and pasword == users[username]:
            print('登录成功')
        elif count != 3:
            print('登录失败,您还可以登录' + str(3-count) + '次')
            count += 1
        else:print('登录失败,您不能再登录了')
    

      

  • 相关阅读:
    如何仅仅修改每一页的页眉
    resize
    Linux搭建深度学习环境
    Image.open、cv2.imread
    any、all
    cookie
    any、all
    库文件
    出来混总要还的,要提醒自己提高核心竞争力
    “行百里者半九十”(现在才逐渐真正理解这些道理)
  • 原文地址:https://www.cnblogs.com/txbbkk/p/12528398.html
Copyright © 2011-2022 走看看