_username='Lily'
_password='' username=input("username:")
password=input("password:") if _username==username and _password==password:
print("Welcome user {name} login....".format(name=username))
else:
print("Invalid username or password")

输入结果

F:\py\pyProject\venv\Scripts\python.exe F:/py/pyProject/Day3.py
username:Lily
password:123
Welcome user Lily login.... Process finished with exit code 0

2.

grade_of_Lucy = 85
guess_grade = int(input("guess grade:"))
if guess_grade == grade_of_Lucy:
print("yes,you got it")
elif guess_grade > grade_of_Lucy:
print("think bigger")
else:
print("think smaller")
04-26 23:39