Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.5 函数 打卡 如有错误希望大佬指点 #7

Open
RanDengShiFu opened this issue Jan 13, 2019 · 2 comments
Open

1.5 函数 打卡 如有错误希望大佬指点 #7

RanDengShiFu opened this issue Jan 13, 2019 · 2 comments

Comments

@RanDengShiFu
Copy link

RanDengShiFu commented Jan 13, 2019

# 将1.4节的练习题的实现都封装到函数中,传入不同的参数进行调用测试
# 实现用户输入用户名和密码,当用户名为 seven且密码为123时,显示登陆成功,否则登陆失败!
def login(Username,Password):
    while True:
        Username = str(input("请输入用户名"))
        Password = int(input("请输入密码"))
        if Username == str("seven") and Password == int("123"):
            print("成功登录")
            break
Username = str(input("请输入用户名"))
Password = int(input("请输入密码"))
login(Username,Password)

# 用while循环实现输出2-3+4-5+6.....+100的和
def sum(if1=100):
    i = s1 = c = 0
    while True:
        i += 1
        if i % 2 == 0:
            s1 += i
        else:
            s1 -= i
        if i == int(if1):
            break
    print(s1 + 1)
if1 = int(float(input("请你输入最后的数字:")))
sum(if1)
@xuanhun
Copy link
Owner

xuanhun commented Apr 11, 2019

int("123") 不太恰当,都处理成字符串就好了。场景是密码。

@RanDengShiFu
Copy link
Author

int("123") 不太恰当,都处理成字符串就好了。场景是密码。

好的!!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants