Wednesday, 6 November 2019

Python Programs 2


Question 1:- Write a program to convert the temperature into Celsius to farehnite, farehnite to Celsius, farehnite to Kelvin, Kelvin to farehnite, Celsius to Kelvin and Kelvin to Celsius.
Answer:-
print("\n\n         MENU      \n")
print("   1. to convert celsius to fahrenheit\n")
print("   2. to convert fahrenheit to celsius\n")
print("   3. to convert fahrenheit to kelvin\n")
print("   4. to convert kelvin to fahrenheit\n")
print("   5. to convert celsius to kelvin\n")
print("   6. to convert kelvin to celsius\n")
ch=eval(input("   enter your choice\n"))
if(ch==1):
    t=eval(input("   enter temperature in celsius\n"))
    t=(t*9/5)+32
    print("   temperature in fahrenheit is",round(t,2))
elif(ch==2):
    t=eval(input("   enter temperature in fahrenheit\n"))
    t=(t-32)*5/9
    print("   temperature in celsius is",round(t,2))
elif(ch==3):
    t=eval(input("   enter temperature in fahrenheit\n"))
    t=((t-32)*(5/9)+273.15)
    print("   temperature in kelvin is",round(t,2))
elif(ch==4):
    t=eval(input("   enter temperature in kelvin\n"))
    t=((t-273.15)*(9/5)+32)
    print("   temperature in fahrenheit is",round(t,2))
elif(ch==5):
    t=eval(input("   enter temperature in celsius\n"))
    t=t+273.15
    print("   temperature in kelvin is",round(t,2))
elif(ch==6):
    t=eval(input("   enter temperature in kelvin\n"))
    t=t-273.15
    print("   temperature in celsius is",round(t,2))
print("\n   Made By Aakash Pramanik Of Class XI-B\n")
Question 2:- Write a program to input 3 sides of the triangle. Find the semi-perimeter and the area by using heron’s formula.
Answer:-
import math
a=eval(input("\n\n   enter the first side\n"))
b=eval(input("   enter the second side\n"))
c=eval(input("   enter the third side\n"))
s=1/2*(a+b+c)
area=math.sqrt(s*(s-a)*(s-b)*(s-c))
print("   semi perimeter of the circle is",s)
print("   area of the trianlge is",round(area,2))
print("\n   Made By Aakash Pramanik Of Class XI-B\n")






Question 3:- Write a program to find the circumference and area of a circle.
Answer:-
pi=3.14
r=eval(input("\n\n   enter the radius\n"))
circum=2*pi*r
area=pi*r*r
print("   circumference of the circle is",round(circum,2))
print("   area of the circle is",round(area,2))
print("\n   Made By Aakash Pramanik Of Class XI-B\n")









Question 4:- Write a program to find area of the park whose inner dimensions has been given.
Answer:-
h=eval(input("\n\n   enter the height\n"))
b=eval(input("   enter the width\n"))
area=h*b
print("   the area of the park is",area)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")










Question 5:- Write a program to find area of the ring whose outer radius and width is given.
Answer:-
pi=3.14
R=eval(input("\n\n   enter the outer radius\n"))
r=eval(input("   enter the inner radius\n"))
area=(pi*R*R)-(pi*r*r)
print("   the area of the ring is",round(area,2))
print("\n   Made By Aakash Pramanik Of Class XI-B\n")










Question 6:- Write a program to input 5 digit numbers and find the sum of the square of the digit and reverse of digit.
Answer:-
n=eval(input("\n\n   enter the five digit number\n"))
m=n
sum=0
rev=0
while(n>=1):
    dig=n%10
    sum=sum+dig*dig
    n=n//10
print("   sum of square of the digit is",sum)
while(m>=1):
    p=m%10
    rev=rev*10+p
    m=m//10
print("   reverse of the digit is",rev)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")

Question 7:- Write a program to find principal, rate and time. Find the simple interest and amount, compound interest and amount.
Answer:-
import math
p=eval(input("\n\n   enter the principal\n"))
r=eval(input("   enter the rate\n"))
t=eval(input("   enter the time\n"))
si=(p*r*t)/1000
a=p*math.pow((1+r/100),t)
ci=a-p
print("   simple interest is",round(si,2))
print("   amount is",round(a,2))
print("   compound interest is",round(ci,2))
print("\n   Made By Aakash Pramanik Of Class XI-B\n")




Question 8:- Write a program to find the T.S.A, C.S.A and volume of cone, cylinder and sphere.
Answer:-
r=eval(input("\n\n   enter the radius\n"))
h=eval(input("   enter the height\n"))
l=eval(input("   enter the length\n"))
pi=3.14
csaofc=pi*r*l
tsaofc=(pi*r*l)+(pi*r*r)
volumeofc=1/3*(pi*r*r*h)
csaofcy=2*pi*r*h
tsaofcy=(2*pi*r*h)+(2*pi*r*r)
volumeofcy=pi*r*r*h
csaofs=4*pi*r*r
tsaofs=4*pi*r*r
volumeofs=4/3*(pi*r*r*r)
print("   csa of cone is",csaofc)
print("   tsa of cone is",round(tsaofc,2))
print("   volume of cone is",round(volumeofc,2))
print("   csa of cylinder is",csaofcy)
print("   tsa of cylinder is",round(tsaofcy,2))
print("   volume of cylinder is",round(volumeofcy,2))
print("   csa of sphere is",round(csaofs,2))
print("   tsa of sphere is",round(tsaofs,2))
print("   volume of sphere is",round(volumeofs,2))
print("\n   Made By Aakash Pramanik Of Class XI-B\n")













Question 9:- In a departmental store, provides the discount of various items for electrical item 10%, for electronic items 20%, for medicine 25% and for garments 15%.
Write a program to prepare a bill inputting the category of the item, name of the item, unit price and quantity. Calculate the discount and GST of 12%. Make a final bill.
Answer:-
category=input("\n\n   enter the category of item\n")
name=input("   enter the name of item\n")
price=eval(input("   enter the  unit price of item\n"))
quantity=eval(input("   enter the quantity of item\n"))
bill=price*quantity
if(category=='electrical'):
    bill=bill-bill*10/100
elif(category=='electronic'):
    bill=bill-bill*20/100
elif(category=='medicine'):
    bill=bill-bill*25/100
elif(category=='garments'):
    bill=bill-bill*15/100
bill=bill+bill*12/100
print("   after adding gst total bill is",round(bill,2))
print("\n   Made By Aakash Pramanik Of Class XI-B\n")

   













Question 10:- Write a program to input 2 numbers and display the largest number.
Answer:-
a=eval(input("\n\n   enter the first numebr\n"))
b=eval(input("   enter the second numebr\n"))
if(a>b):
    print("  ",a,"is greater")
else:
    print("  ",b,"is greater")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")










Question 11:- Write a program to find the smallest number out of 3 numbers.
Answer:-
print("\n\n")
small=100000
for i in range(1,3+1):
    print("   enter",i,"number")
    dig=eval(input())
    if(small>dig):
        small=dig
print("   the smallest number is",small)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")








Question 12:- Write a program to find the greatest of five numbers.
Answer:-
print("\n\n")
big=0
for i in range(1,5+1):
    print("   enter",i,"number")
    dig=eval(input())
    if(dig>big):
        big=dig
print("   the biggest number is",big)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")






Question 13:- Write a program to input the vertices of the triangle and find the area of the triangle.
Answer:-
import math
a=eval(input("\n\n   enter the first side\n"))
b=eval(input("   enter the second side\n"))
c=eval(input("   enter the third side\n"))
s=(a+b+c)/2
area=math.sqrt(s*(s-a)*(s-b)*(s-c))
print("   area of the triangle of the given vertices is",round(area,2))
print("\n   Made By Aakash Pramanik Of Class XI-B\n")







Question 14:- Write a program to input 3 sides of the triangle and check whether it is forming a triangle or not. If it is forming a triangle. What triangle is it and find the area of the triangle.
Answer:-
import math
a=eval(input("\n\n   enter the first side\n"))
b=eval(input("   enter the second side\n"))
c=eval(input("   enter the third side\n"))
if((a+b>c)or(b+c>a)or(c+a>b)):
    print("   sides are forming a triangle")
else:
    print("   sides are not forming a triangle")
if((a*a+b*b==c*c)or(b*b+c*c==a*a)or(c*c+a*a==b*b)):
    print("   triangle is right angled triangle")
elif((a==b)and(b==c)):
    print("   traingle is equilateral triangle")
elif((a==b)or(b==c)or(c==a)):
    print("   triangle is isosceles triangle")
s=(a+b+c)/2
area=math.sqrt(s*(s-a)*(s-b)*(s-c))
print("   area of the triangle is",area)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")
















Question 15:- Write a program to find the age of a person if current date, month and year and birth date, month and year are given.
Answer:-
y1=int(input("\n\n   enter the current year\n"))
m1=int(input("   enter the current month\n"))
d1=int(input("   enter todays date\n"))
y2=int(input("   enter your year of birth\n"))
m2=int(input("   enter your month of birth\n"))
d2=int(input("   enter your date of birth\n"))
if(d1>d2 or d1==d2):
    d=d1-d2
else:
    if(m1==2):
        if(y1%4==0):
            d=d1+29
        else:
            d1=d1+28
    elif(m1==4 or m1==6 or m1==9 or m1==11):
        d1=d1+30
    else:d=d1+31
    d=d1-d2
    m1=m1-1
if(m1>m2 or m1==m2):
    m=m1-m2
else:
    m1=m1+12
    m=m1-m2
    y1=y1-1
if(y1>y2 or y1==y2):
    y=y1-y2
print("   you are ",y,"years",m,"months",d,"days old")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")





Question 16:- Write a program to input the year and check it is a leap year or not.
Answer:-
year=eval(input("\n\n   enter the year\n"))
if(year%4==0):
    print("  ",year,"is leapy year")
else:
    print("  ",year,"is not leapy year")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")










Question 17:- Write a program to input the cost price and selling price of an item .find the transaction is profit , loss or no loss no profit and find the profit percent and loss percent.
Answer:-
cp=eval(input("\n\n   enter the cost price\n"))
sp=eval(input("   enter the selling price\n"))
if(sp>cp):
    print("   transaction is profit")
    pp=cp/sp*100
    print("   profit percentage is",round(pp,2))
elif(sp==cp):
    print("   no loss and no profit")
else:
    print("   transaction is loss")
    lp=sp/cp*100
    print("   lost percentage is",round(lp,2))
print("\n   Made By Aakash Pramanik Of Class XI-B\n")

Question 18:- Write a program to input 4 digit numbers to find greatest, smallest and second largest number.
Answer:-
big=0
a=b=0
small=100000
print("\n\n")
for i in range(1,4+1):
    print("   enter",i,"number")
    dig=eval(input())
    if(dig>a):
        b=a
        a=dig
    elif(dig>b):
        b=dig
    if(dig>big):
        big=dig
    if(small>dig):
        small=dig
print("   greatest number is",big)
print("   second largest number is",b)
print("   smallest number is",small)
print("\n   made By Aakash Pramanik Of Class XI-B\n")














Question 19:- The marks of 5 subjects of a student are input through keyboard the student get a division as per the following rule:
Greater than or equal to 60% :- 1st division
(50-59)% :- 2nd division
(40-49)% :- 3rddivision
Less than 40%:- 4th division
Write a program to calculate the division of student along report card and put the grade in each subject.
Greater than or equal to 60% :- A1
(50-59)% :- B1
(40-49)% :-C1
Less than 40%:-D1
Answer:-
a=eval(input("\n\n   enter the first subject marks\n"))
b=eval(input("   enter the second subject marks\n"))
c=eval(input("   enter the third subject marks\n"))
d=eval(input("   enter the fourth subject marks\n"))
e=eval(input("   enter the fifth subject marks\n"))
avg=(a+b+c+d+e)/5;
print("   average of the student is",avg)
if(avg>=60):
    print("   1st division")
    print("   Grade=A1")
elif(avg>=50 and avg<=59):
    print("   2nd devision")
    print("   Grade=B1")
elif(avg>=40 and avg<=49):
    print("   3rd devision")
    print("   Grade=C1")
elif(avg>=50 and avg<=59):
    print("   4th devision")
    print("   Grade=D1")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")



Question 20:- Write a program to input any integer and check the integer is positive or negative or odd or even.
Answer:-
n=int(input("\n\n   enter the number\n"))
print("   number is",end=" ")
if(n>0):
    print("positive",end=",")
if(n<0):
    print("negative",end=",")
if(n%2==0):
    print("even",end=" ")
if(n%2!=0):
    print("odd",end=" ")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")
           



Question 21:- Given 3 points (x1, y1), (x2, y2),(x3,y3). Check the given points are collinear or not.
Answer:-
x=eval(input("\n\n   enter the values of x\n"))
y=eval(input("   enter the values of y\n"))
x1=eval(input("   enter the values of x1\n"))
x2=eval(input("   enter the values of x2\n"))
y1=eval(input("   enter the values of y1\n"))
y2=eval(input("   enter the values of y2\n"))
s=(y2-y1)*x+(x1-x2)*y+(x2*y1-x1*y2)
if(s<0 or s>0):
    print("   points are not collinear")
else:
    print("   points are collinear")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")




Question 22:- Write a program to find the point is lying in which quadrant.
Answer:-
c1=eval(input("\n\n   enter the first co-ordintes\n"))
c2=eval(input("   enter the second co-ordintes\n"))
if(c1>0 and c2>0):
    print("   point is lying in 1st quadrant")
elif(c1<0 and c2>0):
    print("   point is lying in 2nd quadrant")    
elif(c1<0 and c2<0):
     print("   point is lying in 3rd quadrant")
elif(c1>0 and c2<0):
     print("   point is lying in fourth quadrant")
elif(c1==0 and c2==0):
     print("   point is lying at the origin")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")



Question 23:- Write a program to find the square roots of the quadratic equation ax2+bx+c=0, with all possible conditions.
Answer:-
import math
a=eval(input("\n\n   enter the first side\n"))
b=eval(input("   enter the second side\n"))
c=eval(input("   enter the third side\n"))
d=(b*b-4*a*c)
e=math.sqrt(d)
if(d<0):
    print("   roots are complex root")
elif(d>0):
    print("   roots are real and unequal")
    x1=(-b+e)/2
    x2=(-b-e)/2
    print("  ",round(x1,2))
    print("  ",round(x2,2))
elif(d==0):
    print("   roots are real and equal")
    x=-b/2
    print("  ",round(x,2))
    print("  ",round(x,2))
print("\n   Made By Aakash Pramanik Of Class XI-B\n")













Question 24:- Write a program to input 4 digit numbers. Check  the number is form palindrome or not (the reverse of the digit should be equal to original number)
Answer:-
num=int(input("\n\n   enter the four digit number\n"))
p=num
rev=0
for i in range(1,4+1):
          dig=num%10
          rev=rev*10+dig
          num=num//10
if(rev==p):
    print("   number is palindrome")
else:
    print("   number is not a palindrome")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")
           


Question 25:- Write a program to input 3 digit numbers. Check that number is Armstrong number or not. (sum of the cube of the digit equal to the original number)
Answer:-
n=int(input("\n\n   enter the three digit number\n"))
a=n
sum=0
for i in range(1,3+1):
        dig=n%10
        sum=sum+dig*dig*dig
        n=n//10
if(sum==a):
    print("   number is armstrong")
else:
    print("   number is not a armstrong")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")



Question 26:- Write a program to input 4 digit numbers. Check that the number is buzzle number or not. (if the number is divisible by 7 or 700).
Answer:-
n=eval(input("\n\n   enter the four digit number\n"))
if((n%7==0) or (n%700==0)):
    print("   buzzle number")
else:
    print("   not a buzzle number")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")









Question 27:- Write a program to input 4 digit numbers. Check that the number is odd or even .if it is odd interchange the unit digit with thousand digit else interchange the tenth digit with hundredth digit.
Answer:-
n=eval(input("\n\n   enter the four digit number\n"))
if(n%2==0):
    n*=1000
else:
    n*=100
print("   now the number is",n)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")







Question 28:- Write a program to find the sum of  n natural numbers by using:-
1. While loop                                    2.for loop
                                   

(1)              
Answer:-
n=eval(input("\n\n   enter the n\n"))
sum=0
i=0
while(i<=n):
    sum+=i
    i+=1
print("   sum of first",n,"natural numbers is",sum)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")
                                           








(2)
Answer:-
n=eval(input("\n\n   enter the n\n"))
sum=0
for i in range(1,n+1):
    sum+=i
print("   sum of first",n,"natural numbers is",sum)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")

   





Question 29:- Find the sum of odd natural numbers by using:-
1. While loop                                    2.for loop
                                      


          (1)
Answer:-
n=eval(input("\n\n   enter the n\n"))
sum=0
i=1
while(i<=n):
    sum+=i
    i+=2
print("   sum of first",n,"odd natural numbers is",sum)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")








 (2)
Answer:-
n=eval(input("\n\n   enter the n\n"))
sum=0
for i in range(1,n+1,2):
    sum+=i
print("   sum of first",n,"odd natural numbers is",sum)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")






Question 30:- Write a program to list the following from 100 to 500:-
1. Armstrong numbers
2.  palindrome numbers
3. Pythagoras triplets numbers
4. Buzzle  numbers
5. Reversing of numbers
6. Prime numbers
7. Composite numbers













(1)
Answer:-
print("\n\n")
for i in range(100,500+1):
    j=i
    sum=0
    while(i>0):
        dig=i%10
        sum=sum+dig*dig*dig
        i=i//10
    if(sum==j):
        print("  ",j,end=" ")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")


                                        



(2)
Answer:-
print("\n\n")
for i in range(100,500+1):
    j=i
    rev=0
    while(i>0):
        dig=i%10
        rev=rev*10+dig
        i=i//10
    if(rev==j):
        print("    ",j,end="")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")


          





(3)
Answer:-
print("\n\n")
for i in range(100,500+1):
    for j in range(100,500+1):
        for k in range(100,500+1):
            if((i*i + j*j)==k*k):
                print("    ",i,j,k,end="  , ")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")












(4)
Answer:-
print("\n\n")
for i in range(100,500+1):
    if((i%7==0)or(i%700==0)):
        print(" ",i,end=",")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")













(5)
Answer:-
print("\n\n")
for i in range(100,500+1):
    rev=0
    while(i>0):
        dig=i%10
        rev=rev*10+dig
        i=i//10
    print("    ",rev,end=",")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")







(6)
Answer:-
print("\n\n")
for i in range(100,500+1):
    count=0
    for j in range(1,i+1):
        if(i%j==0):
            count+=1
    if(count==2):
        print("    ",i,end=",")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")



   







(7)
Answer:-
print("\n\n")
for i in range(100,500+1):
    count=0
    for j in range(1,i+1):
        if(i%j==0):
            count+=1
    if(count>2):
            print("",i,end=",")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")



Question 31:- Write a program to convert the following:-
1. Decimal to binary
2. Decimal to octal
3. Decimal to hexadecimal
(1)
Answer:-
bn=[]
i=0
dn=eval(input("\n\n   enter the decimal number\n"))
while(dn>=1):
    b=dn%2
    bn.insert(i,b)
    i+=1
    dn=dn//2
bn.reverse()
print("   binary form of the number is",bn)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")



(2)
Answer:-
on=[]
i=0
dn=eval(input("\n\n   enter the decimal number\n"))
while(dn>=1):
    o=dn%8
    on.insert(i,o)
    i+=1
    dn=dn//8
on.reverse()
print("   octal form of the number is",on)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")





(3)
Answer:-
hn=[]
i=0
dn=eval(input("\n\n   enter the decimal number\n"))
while(dn>=1):
    h=dn%16
    if(h<10):
        hn.insert(i,h)
    elif(h==10):
        hn.insert(i,'A')
    elif(h==11):
        hn.insert(i,'B')
    elif(h==12):
        hn.insert(i,'C')
    elif(h==13):
        hn.insert(i,'D')
    elif(h==14):
        hn.insert(i,'E')
    elif(h==15):
        hn.insert(i,'F')
    i+=1
    dn=dn//16
hn.reverse()
print("   hexadecimal  form of the number is",hn)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")













Question 32:- Write a program to convert the following:-
1. Binary to decimal
2. Binaryto octal
3. Binary to hexadecimal

(1)
Answer:-
import math
bn=eval(input("\n\n   enter the binary number\n"))
p=0
dn=0
while(bn>=1):
    d=bn%10
    dn=dn+d*math.pow(2,p)
    p+=1
    bn=bn//10
print("   decimal form of the number is",int(dn))
print("\n   Made By Aakash Pramanik Of Class XI-B\n")


(2)
Answer:-
import math
bn=eval(input("\n\n   enter the binary number\n"))
p=0
dn=0
on=[]
i=0
while(bn>=1):
    d=bn%10
    dn=dn+d*math.pow(2,p)
    p+=1
    bn=bn//10
while(dn>=1):
    o=int(dn%8)
    on.insert(i,o)
    i+=1
    dn=dn//8
on.reverse()
print("   octal form of the number is",on)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")


















(3)
Answer:-
import math
bn=eval(input("\n\n   enter the binary number\n"))
p=0
dn=0
hn=[]
i=0
while(bn>=1):
    d=bn%10
    dn=dn+d*math.pow(2,p)
    p+=1
    bn=bn//10
while(dn>=1):
    h=int(dn%16)
    if(h<10):
        hn.insert(i,h)
    elif(h==10):
        hn.insert(i,'A')
    elif(h==11):
        hn.insert(i,'B')
    elif(h==12):
        hn.insert(i,'C')
    elif(h==13):
        hn.insert(i,'D')
    elif(h==14):
        hn.insert(i,'E')
    elif(h==15):
        hn.insert(i,'F')
        i+=1
    dn=dn//16
print("   hexadecimal form of the number is",hn)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")






Question 33:- Write a program to display a multiplication table each up to 10.
Answer:-
n=eval(input("\n\n   enter the number\n"))
for i in range(1,10+1):
    print("  ",n,"*",i,"=",n*i)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")













Question 34:- Write a program to input the age and sex of n no. of students and find the average of each category.
Answer:-
n=eval(input("\n\n   enter the total number of students\n"))
boys=0
girls=0
for i in range(1,n+1):
    print("   enter age of",i,"student")
    age=int(input("   "))
    print("   enter sex of",i,"student (m/f)")
    sex=input("   ")
    if(sex=='m'):
        boys+=1
    else:
        girls+=1
print("   number of boys are",boys)
print("   number of girls are",girls)
boysavg=(boys*100)//n
girlsavg=(girls*100)//n
print("   boys average is",boysavg)
print("   girls average is",girlsavg)
print("   Made By Aakash Pramanik Of Class XI-B\n")
















Question 35:- Find the H.C.F and L.C.M of 2 numbers.
Answer:-
a=eval(input("\n\n   enter the first number\n"))
b=eval(input("   enter the second number\n"))
lcm=a*b
while(a!=b):
    if(a>b):
        a-=b
    else:
        b-=a
lcm//=a
print("   lcm of the numbers is",lcm)
print("   hcf of the numbers is",a)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")





Question 36:- Write a program to display an alphabet A to Z and ascll code of each alphabet.
Answer:-
print("\n\n")
for i in range(65,90+1):
    ch=chr(i)
    print(ch,"=",i,end=",")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")











Question 37:- Write a program to count the no. of digits in given number.
Answer:-
n=12345
count=0
while(n>0):
    n=n//10
    count+=1
print("\n\n   number of digits are",count)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")










Question 39:- Write a program to input a number and find the no. of digit.
Answer:-
n=eval(input("\n\n   enter the number\n"))
count=0
while(n>0):
    n=n//10
    count+=1
print("   number of digits are",count)
print("\n   Made By Aakash Pramanik Of Class XI-B\n")










Question 40:- Write a program to input to
display the following program:-


(1)
Answer:-
print("\n\n")
for i in range(1,5+1):
        print("\n")
        for j in range(1,i+1):
                print("*",end="")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")











(2)
Answer:-
print("\n\n")
for i in range(1,5+1):
        print("\n")
        for j in range(1,i+1):
                print("1",end="")
print("\n   Made By Aakash Pramanik Of Class XI-B\n")











(3)
Answer:-
print("\n\n")
for i in range(1,5+1):
        print("\n")
        for j in range(1,i+1):
                print(j,end="")
print("\n\n\nMade By Aakash Pramanik Of Class XI-B")



No comments:

Post a Comment