Python-if Else Process judgment--006

Source: Internet
Author: User

One, the password input does not display

Method: Getpass

Import Getpass

Username = input ("Username:")

Password = getpass.getpass ("Password:")

Print (Username,password)

Result output:

[[Email protected]~]#./hello.py

Username:user

Password

(' user ', ' 123 ')

[[Email protected]~]#

Second, if judgment

#Author: Robinwen

_username = "Robin"

_password = "123456"

Username = input ("Username:")

Password = input ("Password:")

If_username = = Username and _password = = password:

Print ("Welcome User {name} logo in!". Format (name=username))

Else

Print ("Invalid username or password!")

Result output:

(1) True

Username:robin

password:123456

Welcome User Robin logo in!

(2) False

Username:robin

password:111

Invalid Username or password!

Three, age guessing-if judgment

#Author: Robinwen

My_age=25

guess_age = Int (Input ("Age:"))

if guess_age = = My_age:

Print ("Yes,you got It!")

Elif guess_age > My_age:

Print ("Bigger ...")

Else

Print ("smaller ...")

Python-if Else process judgment--006

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.