Sub PDF
Sub PDF
Problem
Statement Identifying whether a number is odd or even
Program
a=int(input("enter the number"))
if a%2==0:
print("number is even")
else:
print("number is odd")
output
enter the number8
number is even
enter the number5
number is odd
Problem
Statement Basic calculator(add, subtract,multiply,divide)
Program
a=int(input('enter a number'))
b=int(input('enter a number'))
print("1 is for adition, 2 is for subtraction,3 is for multiplication,4 is for
division")
select=int(input("please enter a corresponding number for performing an
operation"))
if select==1:
c=a+b
print(c)
elif select==2:
d=a-b
print(d)
elif select==3:
e=a*b
print(e)
elif select==4:
f=a/b
print(f)
else:
print("enter a valid number")
Output
enter a number2
enter a number3
1 is for adition, 2 is for subtraction,3 is for multiplication,4 is for division
please enter a corresponding number for performing an operation1
5
enter a number3
enter a number7
1 is for adition, 2 is for subtraction,3 is for multiplication,4 is for division
please enter a corresponding number for performing an operation2
-4
enter a number6
enter a number8
1 is for adition, 2 is for subtraction,3 is for multiplication,4 is for division
please enter a corresponding number for performing an operation3
48
enter a number7
enter a number2
1 is for adition, 2 is for subtraction,3 is for multiplication,4 is for division
please enter a corresponding number for performing an operation4
3.5
Problem
Statement
Printing the grade of the students when the marks are input
Program
a=int(input("enter the marks"))
if a>=90:
print("A grade")
elif 90>a>=80:
print("B grade")
elif 80>a>=60:
print("C grade")
elif 60>a>=40:
print("D grade")
else:
print("failed")
Output
enter the marks92
A grade
enter the marks80
B grade
enter the marks52
D grade
enter the marks63
C grade
enter the marks35
failed
Problem
Statement Finding whether a given year is leap or not
Program
year = int(input("Enter a year"))
if (year % 4) ==0:
if (year % 100) == 0:
if (year % 400) == 0:
print("year is a leap year")
else:
print("year is not a leap year")
else:
print("year is a leap year")
else:
print("year is not a leap year")
Output
enter the year2019
year is not a leap year
Enter a year2000
year is a leap year
Enter a year1400
year is not a leap year
Conclusion I have implemented the use of conditional statements for the above given
programs