❮ Previous Next ❯

Python if-else Statements

If-else is a control statement. The if statement is used to test specified condition and if the condition is true, if block executes, otherwise else block executes.

Let’s see the following code for better understanding:
n=int(input("Enter a number"))
if n<0:
    print("The absolute value of",n,"is",-n)

Output
python-ifelse1

n=int(input("Enter a number"))
if n<0:
    print("The absolute value of",n,"is",-n)
else:
    print("The absolute value of",n,"is",n)
   


Output
python-ifelse2
❮ Previous Next ❯

Follow Us




  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved