Saturday, 13 April 2019

#Program 1: +ve or –ve Using simple if
n=int(input("Enter input :"))
if n>0 :
    print ("+ve number")
---------------------------------------------------
#Program 2: +ve or –ve Using simple if else
n=int(input("Enter input :"))
if n>0 :
    print ("+ve number")
else :
    print ("-ve number")
---------------------------------------------------
#Program 3: Even or Odd number using simple if else
n=int(input("Enter input :"))
if (n%2)==0 :
    print ("even number")
else :
    print ("odd number")
---------------------------------------------------------
#Program 4: Biggest in 2 numbers using simple if else
a=int(input("Enter First input :"))
b=int(input("Enter Second input :"))
if a>b :
    print ("a is biggest")
else :
    print ("b is biggest")
--------------------------------------------------
#Program 5: Biggest in Three Numbers using else if ladder
a=int(input("Enter First input :"))
b=int(input("Enter Second input :"))
c=int(input("Enter Third input :"))
if a>b and a>c:
    print ("a is biggest")
elif  b>c :
    print ("b is biggest")
else:
    print ("c is biggest")
--------------------------------------------------
#Program 6: Using else If ladder
n=int(input("Enter input :"))
if n>0 :
    print ("+ve number")
elif n==0 :
    print ("Given input is zero")
else :
    print ("-ve number")
------------------------------------------------
#Program 7: Using Nested If
roll=int(input("Enter Roll : "))
name=input("Enter Name : ")
m1=int(input("Enter Mark1 : "))
m2=int(input("Enter Mark2 : "))
m3=int(input("Enter Mark3 : "))
tot=m1+m2+m3
avg=tot/3

if(m1>=35 and m2>=35 and m3>=35):
    result="pass"
    if(avg>=90):
        grade="A++"
    elif(avg>=80):
        grade="A+"
    elif(avg>=70):
        grade="A"
    elif(avg>=60):
        grade="B"
    elif(avg>=50):
        grade="c"
    else:
        grade="Nil"
else:
    result="Fail"
    grade="Nill"

print("Roll \t Name \t Total \t Average \t Result \t Grade")
print("-----------------------------------------------------")
print(roll,"\t",name,"\t",tot,"\t",avg,"\t",result,"\t",grade)
-----------------------------------------------------------------------------------------
#Program 8: Using Nested If
a=int(input("Enter First input :"))
b=int(input("Enter Second input :"))
c=int(input("Enter Third input :"))
if a>b:
    if a>c:
        print ("a is biggest")
    else:
        print ("c is biggest")
else:
    if b>c :
        print ("b is biggest")
    else:
        print ("c is biggest")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

No comments:

Post a Comment