Conditional Statements:
- Conditional Statement is used to control the flow of the execution of the program based on specific condition.
If Statement:
- This condition is used to execute the code whether the given condition is true.
mark=90
if mark>=80:
print("pass")
output:
pass
If-else statement:
- This condition is used to execute the code whether the given condition is True otherwise its execute false
age=18
if age>=18:
print("eligible to vote")
else:
print("not eligible to vote")
output:
eligible to vote
If-Elif-else statement:
- This condition is used to execute the code whether the given condition is true if the given condition false means it goes to the next condition and check the condition is true or not if true means it execute the code otherwise it execute the else part.
a=10
b=20
if a>b:
print("a is greater")
Elif b>a:
print("b is greater")
else:
print("a and b are same")
output:
b is greater
Programming Rules:
Never say "I don't know", say "Let me try"
Known to unknown
Don't think about entire output
think about very next step
Introduce a variable only when it simplifies the solution
Micro to macro
Dry run before you run
Every big problem split three part input, progress, output
Logic first and syntax next
Top comments (0)