3. Python Program to Check if a Number is Odd or Even CLICK
4.Python Program to Find the Largest Among Three Numbers CLICK
5. Python Program to Check Leap Year CLICK
1. Check Whether a Number is Positive or Negative
num=int(input("Enter a number: "))
ifnum>=0:
("Positive Number")
else:
("Negative Number")
2. Check Whether a Number is Even or Odd
num=int(input("Enter a number: "))
ifnum%2==0:
("Even Number")
else:
("Odd Number")
3. Find Larger of Two Numbers
a=int(input("Enter first number: "))
b=int(input("Enter second number: "))
ifa>b:
("Largest =",a)
else:
("Largest =",b)
4. Check Voting Eligibility
age=int(input("Enter age: "))
ifage>=18:
("Eligible for Voting")
else:
("Not Eligible for Voting")
5. Check Whether a Number is Divisible by 5
num=int(input("Enter a number: "))
ifnum%5==0:
("Divisible by 5")
else:
("Not Divisible by 5")
6. Find Smaller of Two Numbers
a=int(input("Enter first number: "))
b=int(input("Enter second number: "))
ifa<b:
("Smaller =",a)
else:
("Smaller =",b)
7. Check Leap Year
year=int(input("Enter year: "))
ifyear%4==0:
("Leap Year")
else:
("Not a Leap Year")
8. Check Pass or Fail
marks=int(input("Enter marks: "))
ifmarks>=40:
("Pass")
else:
("Fail")
9. Check Whether Character is Vowel
ch=input("Enter a character: ")
ifchin"AEIOUaeiou":
("Vowel")
else:
("Consonant")
10. Find Greatest of Three Numbers
a=int(input("Enter first number: "))
b=int(input("Enter second number: "))
c=int(input("Enter third number: "))
ifa>banda>c:
("Greatest =",a)
elifb>c:
("Greatest =",b)
else:
("Greatest =",c)
11. Check Whether Number is Zero
num=int(input("Enter a number: "))
ifnum==0:
("Zero")
else:
("Not Zero")
12. Check Driving Eligibility
age=int(input("Enter age: "))
ifage>=18:
("Eligible for Driving")
else:
("Not Eligible")
13. Find Absolute Value
num=int(input("Enter a number: "))
ifnum<0:
num=-num
("Absolute Value =",num)
14. Check Number is Multiple of 10
num=int(input("Enter a number: "))
ifnum%10==0:
("Multiple of 10")
else:
("Not a Multiple of 10")
15. Check Whether Number is Three-Digit
num=int(input("Enter a number: "))
if100<=num<=999:
("Three-Digit Number")
else:
("Not a Three-Digit Number")
16. Calculate Grade
marks=int(input("Enter marks: "))
ifmarks>=90:
("Grade A")
elifmarks>=75:
("Grade B")
elifmarks>=50:
("Grade C")
else:
("Grade D")
17. Check Whether a Number is Divisible by 2 and 3
num=int(input("Enter a number: "))
ifnum%2==0andnum%3==0:
("Divisible by 2 and 3")
else:
("Not Divisible by 2 and 3")
18. Find Largest Among Three Numbers
a=int(input("Enter first number: "))
b=int(input("Enter second number: "))
c=int(input("Enter third number: "))
ifa>=banda>=c:
("Largest =",a)
elifb>=c:
("Largest =",b)
else:
("Largest =",c)
19. Check Whether a Character is Alphabet
ch=input("Enter a character: ")
if('A'<=ch<='Z')or('a'<=ch<='z'):
("Alphabet")
else:
("Not an Alphabet")
20. Calculate Electricity Bill
units=int(input("Enter units consumed: "))
ifunits<=100:
bill=units*2
else:
bill=units*5
("Electricity Bill =",bill)
21. Check Triangle Validity
a=int(input("Enter side 1: "))
b=int(input("Enter side 2: "))
c=int(input("Enter side 3: "))
ifa+b>c:
ifb+c>a:
ifc+a>b:
("Valid Triangle")
else:
("Invalid Triangle")
else:
("Invalid Triangle")
else:
("Invalid Triangle")
22. Check Character Type
ch=input("Enter a character: ")
if'A'<=ch<='Z'or'a'<=ch<='z':
ifchin"AEIOUaeiou":
("Vowel")
else:
("Consonant")
else:
("Not an Alphabet")
No comments:
Post a Comment