Lesson For Programming 3
Lesson For Programming 3
c:\python_files>python condition1.py
Enter a number: 5
No! its less than 10
c:\python_files>python condition1.py
Enter a number: 20
Yes!its more than 10
=======================
c:\python_files>python condition2.py
Math Grade: 70
Math Science: 71
Math English: 72
71.0
Sorry! You failed.
c:\python_files>python condition2.py
Math Grade: 85
Math Science: 89
Math English: 88
87.33333333333333
You passed the semester!
==========================
if u == "admin":
if p == "1234":
print("Welcome admin")
else:
print("Error!")
else:
print("Error!")
c:\python_files>python condition3.py
Enter username: admin
Enter password: 4566
Error!
c:\python_files>python condition3.py
Enter username: monna
Enter password: 1234
Error!
c:\python_files>python condition3.py
Enter username: admin
Enter password: 1234
Welcome admin
=========================
YOU CAN USE "AND" MANY TIMES.
c:\python_files>python condition3.py
Enter username: admin
Enter password: 4566
Error!
c:\python_files>python condition3.py
Enter username: monna
Enter password: 1234
Error!
c:\python_files>python condition3.py
Enter username: admin
Enter password: 1234
Welcome admin
c:\python_files>python condition4.py
Enter username: admin
Enter password: 456
Account Error!
c:\python_files>python condition4.py
Enter username: monna
Enter password: 1234
Account Error!
c:\python_files>python condition4.py
Enter username: admin
Enter password: 1234
Welcome Admin
==============
elif - means you want to check multiple
if fruit == "apple":
print("Red Apple!")
else:
print("Not Available!")
c:\python_files>python condition5.py
Type a fruit: guava
Not Available!
c:\python_files>python condition5.py
Type a fruit: banana
Yellow Banana!
c:\python_files>python condition5.py
Type a fruit: apple
Red Apple!
c:\python_files>python condition5.py
Type a fruit: guava
Green Guava!
=====================