DEV Community

R.Shobika CSE
R.Shobika CSE

Posted on

PYTHON3 - DAY4

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")
Enter fullscreen mode Exit fullscreen mode

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")
Enter fullscreen mode Exit fullscreen mode

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")
Enter fullscreen mode Exit fullscreen mode

output:
b is greater

Programming Rules:

  1. Never say "I don't know", say "Let me try"

  2. Known to unknown

  3. Don't think about entire output

  4. think about very next step

  5. Introduce a variable only when it simplifies the solution

  6. Micro to macro

  7. Dry run before you run

  8. Every big problem split three part input, progress, output

  9. Logic first and syntax next

Top comments (0)