1. Simple If/else condition judgment
judge_flow.py
Name = input ("Please input name:")ifName = ='Master': Print('Hello Master') Password= Input ('Please input password:') ifPassword = ='abc123': Print('Access granted.') Else: Print('wrong password!')Else: Print('Invalid user!')
Operation Result:
Please input Name:david
Invalid user!
Please input Name:master
Hello Master
Please input PASSWORD:AAA
Wrong password!
Please input Name:master
Hello Master
Please input password:abc123
Access granted.
2. Multiple condition Judgments
elif statements
judge_flow_multiple.py
age = Int (input ("Input your Age:"))ifAge < 5: Print('Hi, Baby.')elifAge < 12: Print('Hi Child.')elifAge < 100: Print('Hi Mans')Else: Print('Your Majesty')
Operation Result:
Input your Age:3
Hi, Baby.
Input your age:90
Hi Mans
Input your age:1000
Your Majesty
Python-Basic knowledge-conditional judgment