Day 001 Exercise

Posted evicxixi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Day 001 Exercise相关的知识,希望对你有一定的参考价值。

# 1、使用while循环输入 1 2 3 4 5 6     8 9 10
count = 0
while count < 10:
    count  += 1
    if  count == 7:
        continue
    print(count)


# 2、求1 - 100的所有数的和
sum = 0
x = 1
while x < 101:
    sum = sum + x
    x +=1
print(sum)


# 3、输出 1-100 内的所有奇数
odd = 0
while odd < 100:
    odd += 1
    if odd % 2 == 1:
        print(odd)


# 4、输出 1-100 内的所有偶数
even = 0
while even < 100:
    even += 1
    if even % 2 == 0:
        print(even)


# 5、求1-2+3-4+5 ... 99的所有数的和
num = 1
sum = 0
while num < 100:
    if num % 2 == 1:
        sum = sum + num
    elif num % 2 == 0:
        sum = sum - num
    num += 1
print(sum)


# 6、用户登陆(三次机会重试)
count = 0
while count < 3:
    count += 1
    user = input("请输入用户名")
    passWord = input("请输入密码")
    if user == "evic" and passWord == "123":
        print("Welcome")
    elif count > 2:
        print("go away")
    else:
        print(please try again)

 

以上是关于Day 001 Exercise的主要内容,如果未能解决你的问题,请参考以下文章

Python 百例--001

Oracle笔记-day001

DAY 001--python常见7种数据类型

Python_Day001

Python_Day001

day06-jsp