/ Python And R Data science skills: 09 ds python If statement in telugu vlr training

Sunday 4 February 2018

09 ds python If statement in telugu vlr training

09 If Statement in Python
In [1]:
#https://www.programiz.com/python-programming/if-elif-else
In [3]:
"""
if expression:
   statement(s)
else:
   statement(s)
"""
Out[3]:
'\nif expression:\n   statement(s)\nelse:\n   statement(s)\n'
In [10]:
age=17
if(age>=18):
    print("eligible")
    print("welcome")
print("vlr training")
vlr training
In [11]:
age=17
if(age>=18):
    print("eligible")
else:
    print("not eli")
  
not eli
In [12]:
"""
if test expression:
    Body of if
elif test expression:
    Body of elif
else: 
    Body of else"""
Out[12]:
'\nif test expression:\n    Body of if\nelif test expression:\n    Body of elif\nelse: \n    Body of else'
In [13]:
# 1 12 child 13 19 teange 20 young
In [36]:
a=-1
if (a>=0 and a<=5):
    print("small chaild")
elif (a>=5 and a<=12):#(t and f)
    print("big chaild")

elif (a>=13 and a<=19):#(t and f)
    print("teen")

else:
    print("young")
young
In [37]:
# In this program, we input a number
# check if the number is positive or
# negative or zero and display
# an appropriate message
# This time we use nested if
In [41]:
num=0
if num >= 0: #t
    if num==0:#f
        print("Zero")
    else:
        print("Positive number")
else:
    print("Negative number")
  File "<tokenize>", line 5
    else:
    ^
IndentationError: unindent does not match any outer indentation level

No comments:

Post a Comment