Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

25.

#program to check no is greater than 25


n=int(input("Enter the number"))
if n>25:
print("The number is greater")

26. #program for check even/odd


n=int(input("Enter any number"))
if(n%2==0):
print("The number is even")
else:
print("The number is odd")

27. year=int(input("Enter the year"))


if year%4==0:
print("leap year")
else:
print("non leap year")

28. x=int(input("Enter the value of x"))


y=int(input("Enter the value of y"))
if x==y:
print("The numbers are equal")
else:
print("The numbers are not equal")

29. age=int(input("Enter the age"))


if age>=18:
print("eligible to vote")
else:
print("not eligibe to vote")

30. a=int(input("Enter the value of a"))


b=int(input("Enter the value of b"))
if a>b:
print("a is larger")
else:
print("b is larger")

31. a=int(input("Enter the value of a"))


b=int(input("Enter the value of b"))
if a<b:
print("a is smaller")
else:
print("b is smaller")

32. print("Equation: ax^2 + bx + c ")


a=int(input("Enter the value of a: "))
b=int(input("Enter the value of b: "))
c=int(input("Enter the value of c: "))
d=b**2-4*a*c
d1=d**0.5
if(d<0):
print("The roots are imaginary. ")
else:
r1=(-b+d1)/2*a
r2=(-b-d1)/2*a
print("The first root: ",round(r1,2))
print("The second root: ",round(r2,2))

32b). import math


a=int(input("Enter the value of a"))
b=int(input("Enter the value of b"))
c=int(input("Enter the value of c"))
d=(b*b)-(4*a*c)
if d>=0:
r1=((-b+math.sqrt(d))/(2*a))
r2=((-b-math.sqrt(d))/(2*a))
print("r1= ,r2= ",r1,r2)
else:
print("Roots are imaginary")

33. a=int(input("Enter the value of a "))


b=int(input("Enter the value of b "))
c=int(input("Enter the value of c "))
if a>b and a>c:
print("a is largest")
elif b>a and b>c:
print("b is largest")
else:
print("c is largest")

34. a=int(input("Enter the value of a "))


b=int(input("Enter the value of b "))
c=int(input("Enter the value of c "))
if a<b and a<c:
print("a is smallest")
elif b<a and b<c:
print("b is smallest")
else:
print("c is smallest")

35. while :
#print the no's from 1 to 10
i=1
print("The no's from 1 to 10 are ")
while(i<=10):
print(i)
i=i+1

36. #print the no's from 10 to 1


i=10
print("The no's from 1 to 10 are ")
while(i>=1):
print(i)
i=i-1

37. n=int(input("Enter any number"))


i=1
sum=0
while(i<=n):
sum=sum+i
i=i+1
print("The sum of n natural no's is: ",sum)

38. num = int(input("Enter a number: "))


sum = 0
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10
if num == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")
39. #printing the evn no's from 1 to n
n=int(input("Enter any number"))
i=2
print("The even no's from 1 to n ")
while(i<=n):
print(i)
i=i+2

40. n=int(input("Enter a number"))


fact=1
i=1
while(i<=n):
fact=fact*i
i=i+1
print("The factorial of given number is",fact)

41. # Python program to Reverse a number in Python


num = int(input("Enter any number"))
rev = 0
while num > 0:
rem = num % 10
rev = (rev*10) + rem
num = num//10
print("The reverse of the given number is ",rev)

42. #print numbers from 1 to 5:


i=1
while(i<=5):
print(i)
i += 1

43. #print odd numbers from 1 to n


n=int(input("Enter the value for n"))
i=1
print("The odd no's from 1 to n")
while(i<=n):
print(i)
i=i+2

44. n = int(input("Enter a value for n"))


Temp = n
rev = 0
while(n >= 0):
dig = n % 10
rev= (rev * 10) + dig
n = n // 10
if(n == rev):
print("This value is a palindrome number: ",n)
else:
print("This value is not a palindrome number: ",n)

You might also like