0% found this document useful (0 votes)
9 views

Ravi Python

Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Ravi Python

Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

SIMPLE IF STATEMENT

1) # WAP TO PRINT A GIVEN STRING IF THE STRING IS PALINDROME ELSE IGNORE


string=input("enter the string:")
if string[: :-1]==string:
print("it is a palindrome")

2)#wap print the reverse string if length of the string should be odd and last
character of the string should be vowel character else ignore
string=(input("enter the string:"))
length=len(string)
vowel="aeiouAEIOU"
if len(string)%2!=0 and string[::-1] in vowel:
print( "reverse string",string [::-1])

3)#WAP TO CHECK WHEATHER THA LAST DIGIT OF THE GIVEN INTEGER NUMBER IS LESSER THAN
5 OR NOT.IF IT IS TRUE,THE GIVEN NYMBER AS IT IS ELSE IGNORE
demo=int(input("enter the integer:"))
lastdigt=demo%10
if lastdigt<5:
print("The given number is",demo)

IF ELSE STATEMENT
4)#WAP TO ACCEPT TWO INTEGERS AND CHECK WHETHER THEY ARE EQUAL OR NOT
a=int(input("enter the value1:"))
b=int(input("enter the value2:"))
if a==b:
print("it is a equal")
else:
print("it is a not equal")

5)#WAP TO FIND GRAETEST OF TWO NUMBERS


num1=int(input("enter the number1:"))
num2=int(input("enter the number2:"))
if num1>num2:
print("num1 is greater")
else:
print("num2 is greater")

6)#WAP TO READ THE AGE OF A CANDIDATE AND DETERMINE WHETHER THE CANDIDATE IS
ELIGIBLE TO CASE HIS OWN VOTE
age=int(input("enter the age:"))
if age>18:
print("both are eligible person")
else:
print("not eligible person")

7)#WAP TO CHECK WHETHER THE GIVEN 4 VALUES REPRESENT PERFECTLY EITHER SQUARE OR
RECTANGLE OR NOT.ELSE PRINT INVALID SHAPE ANGLE
val1=int(input("enter the value1:"))
val2=int(input("enter the value2:"))
val3=int(input("enter the value3:"))
val4=int(input("enter the value4:"))
if(val1==val2==val3==val4)or(val1==val3 and val2==val4):
print("it is valid shape")
else:
print("it is a invalid shape")

8)#WAP TO CHECK THE GIVEN NUM IS ODD OR EVEN


num=int(input("enter the number:"))
if num%2==0:
print(".....The number is a even.....")
else:
print(".....The number is odd......")

9)#WAP TO CHECK THE GIVEN CHARACTER IS LOWERCASE ALPHABET OR NOT


char=input("enter the character:")
if 'a'<=char<='z':
print("it is a lowercase")
else:
print("it is a uppercase")

10)#WAP TO CHECK THE GIVEN CHRACTER IS ALPHABET OR DIGIT


char=input("enter the character or digit:")
if 'a'<=char<='z' or 'A'<=char<='Z':
print("it is a alphabet")
elif '0'<=char<='9':
print("it is a number")
else:
print("it is a symbol")

11)#WAP TO CHECK THE LAST DIGIT OF THE GIVEN NUMBER IS ODD. IF IT TRUE PRINT THE
LAST OF THE NUMBER ELSE PRINT THE NUMBER
num=int(input("enter the digit:"))
lastdigit=num%10
if lastdigit%2==1:
print("last digit",lastdigit)
else:
print(" the num",num)

12)#WAP TO CHECK WHEATHER THE GIVEN CHRACTER IS DIGIT OR NOT


char=input("enter the digit:")
if'0'<=char<='9':
print(" it is a digit")
else:
print("it is a not digit")

13)#WAP TO CHECK THE GIVEN CHARACTER IS SPECIAL CHRACTER OR NOT


char=input("enter the special character:")
if not('0'<=char<='9' or 'a'<=char<='z' or 'A'<=char<='Z'):
print(" it is a symbol")
else:
print("it is a not symbol")

IF ELIF ELSE STATEMENT


14)#wap to find the relations between the two numbers.[greater or lesser or equal]
num1=int(input("enter the number1"))
num2=int(input("enter the number2"))
if num1>num2:
print("num1 is greater than num1 or num2 is lesser than num1")
elif num2>num1:
print("num2 is greater than num1 or num1 is lesser than num2")
elif num1==num2:
print("both num1 and num2 are equal")
else:
print("enter a number not alphabet")
15)#wap to accept the age of 4 people and display the youngest one
pep1=int(input("enter a age of person 1:"))
pep2=int(input("enter a age of person 2:"))
pep3=int(input("enter a age of person 3:"))
pep4=int(input("enter a age of person 4:"))
if pep1<pep2 and pep1<pep3 and pep1<pep4:
print("person1 is youngest")
elif pep2<pep3 and pep2<pep4:
print("person 2 is youngest")
elif pep3<pep4:
print("person3 is youngest")
else:
print("person4 is youngest")

16) #wap to consolidate the subject grade from 5 subject marks.Print 'A' grade if
their percentage is >90 or print'B' grade if their percentage is >75 and <=90 or
print 'C' grade
if their percentage is >65 and<=75 or print 'D' grade if their percentage is <=65
mark1=int(input("enter mark1"))
mark2=int(input("enter mark2"))
mark3=int(input("enter mark3"))
mark4=int(input("enter makr4"))
mark5=int(input("enter mark5"))
percent=(mark1+mark2+mark3+mark4+mark5)//5
print("The percentage is ",percent)
if percent>90:
print("Grade A")
elif percent>75 and percent<=90:
print("Grade B")
elif percent>65 and percent<=75:
print("Grade C")
else:
print("Grade D")

17)#wap to print 'fizz' if the given number divisible by 3 or print 'buzz' if the
given number divisible by 5 or print 'fizz bizz' if the given number divisible by
both 3
and 5 print else print the number as it is
num=int(input("enter a number"))
if num%3==0 and num%5==0:
print("FIZZ BUZZ")
elif num%3==0:
print("FIZZ")
elif num%5==0:
print("BUZZ")
else:
print(num)

You might also like