Condition Programs (if statement)

 

##Program 1

 

'''To check number is even or odd'''

num = int(input('Enter any number '))

if num%2==0:

          print('This is even number')

else:

          print('This is odd number ')

 

##############################################################

 

## Program 2

 

'''Program to Calculate Incentive'''

sale = int(input('Enter your sale amount '))

if sale>=100000:

          inc = sale * 5 / 100

else:

          inc = sale * 2 / 100

print('Your Incentive Amount is Rs.',inc)

 

##############################################################

 

## Program 3

 

''' Program to find Largest number among three number '''

A = int(input('Enter First Number (A) :'))

B = int(input('Enter Second Number (B) :'))

C = int(input('Enter Third Number (C) :'))

if A>B and A>C:

          print('Largest value is (A) =',A)

elif B>A and B>C:

          print('Largest value is (B) =',B)

else:

          print('Largest value is (C) =',C)

 

##############################################################

 

## Program 4

 

'''Program to find Largest number among three number without 'and' & 'elif' '''

A = int(input('Enter First Number (A) :'))

B = int(input('Enter Second Number (B) :'))

C = int(input('Enter Third Number (C) :'))

large=A

if B>A:

          large=B

if C>large:

          large=C

print('Largest value is :',large)

 

##############################################################

 

## Program 5

 

'''Program to Find Largest number among three number using Nested Loop'''

A = int(input('Enter First Number (A) :'))

B = int(input('Enter Second Number (B) :'))

C = int(input('Enter Third Number (C) :'))

if A>B:

          if A>C:

                    print('Largest value is (A) :',A)

          else:

                    print('Largest value is (C) :',C)

elif B>C:

          print('Largest value is (B) :',B)

else:

          print('Largest value is (C) :',C)

 

##############################################################

 

## Program 6

 

'''Program to Check Leap Year'''

year = int(input('Enter any year :'))

if((year%100!=0 and year%4==0) or (year%400==0)):

          print('It is Leap Year')

else:

          print('It is not Leap Year')

 

##############################################################

 

## Program 7

 

'''Program to Check Leap Year'''

year = int(input('Enter any year :'))

if year%100==0:

          if year%400==0:

                    print('It is Leap Year')

          else:

                    print('It is not Leap Year')

elif year%4==0:

          print('It is Leap Year')

else:

          print('It is not Leap Year')

 

##############################################################

 

## Program 8

 

'''Program to Calculate Total, Per and Division'''

name = input('Enter Student Name :')

physics = int(input('Enter Physics Marks :'))

chemistry = int(input('Enter Chemistry Marks :'))

maths = int(input('Enter Maths Marks :'))

cs = int(input('Enter Comp. Sc. Marks :'))

english = int(input('Enter English Marks :'))

total = physics+chemistry+maths+cs+english

per = total / 5

if per>=60:

          div = 'First'

elif per>=45 and per<60:

          div = 'Second'

elif per>=33 and per<45:

          div = 'Third'

else:

          div = '---'

if physics>=33 and chemistry>=33 and maths>=33 and cs>=33 and english>=33:

          result='Pass'

else:

          result='Fail'

print('NAME        :',name)

print('TOTAL SCORE :',total)

print('PERCENTAGE  :',per)

print('DIVISION    :',div)

print('RESULT      :',result)

 

##############################################################

 

## Program 9

 

'''Checking for teenager'''

age = int(input('Enter your age :'))

if age>=13 and age<=19:

          print('You are Teenager')

else:

          print('You are not Teenager ')

 

##############################################################

 

## Program 10

 

'''Program to check wether a triangle is Equilateral or isoceles or scalene'''

A = int(input('Enter Side 1 of triangle'))

B = int(input('Enter Side 2 of triangle'))

C = int(input('Enter Side 3 of triangle'))

if A==B and B==C:

          print('Equilateral Triangle')

elif A!=B and B!=C and C!=A:

          print('Scalene Triangle')

else:

          print('Isoceles Triangle')

 

##############################################################

 

## Program 11

 

''Program to check Voting eligibility'''

age = int(input('Enter your age :'))

if age>=18:

          print('You are eligible for voting')

else:

          print('You are not eligible for voting ')

 

##############################################################

 

## Program 12

 

'''Program to find the state of water'''

temp = int(input('Enter Temperature of water :'))

if temp<0:

          print('Solid State')

elif temp>100:

          print('Gaseous State')

else:

          print('Liquid State')

 

##############################################################

 

## Program 13

 

'''Program to Count how many Vowels present in a Sentence'''

s = input("Enter Your Sentence =").lower()

vcount=0

for ch in s:

    if ch=='a' or ch=='e' or ch=='i' or ch=='o' or ch=='u' :

        vcount+=1

print("Vowels In Sentence",vcount)

       

No comments:

Post a Comment