Computer Science Record Programs
Computer Science Record Programs
Computer Science Record Programs
OUTPUT
enter a number 2
enter another number 2
2+2=4
2-2=0
2*2=4
2 / 2 = 1.0
Program2
OUTPUT
Program3
OUTPUT
a=int(input("enter a number"))
b=int(input("enter the second number "))
c=int(input("enter the third number "))
if a>b and a>c:
print (a, " is the greatest number out of the three")
elif b>a and b>c:
print (b, " is the greatest number out of the three")
else:
print (c,' is the greatest number out of the three')
OUTPUT
enter a number4
enter the second number 2
enter the third number 6
6 is the greatest number out of the three
Program5
OUTPUT:
Program 6
fact=1
a=int(input("enter a number "))
for i in range (1,a+1):
fact=fact*i
print ("factorial of the entered number is ",fact)
OUTPUT
enter a number 3
factorial of the entered number is 6
Program 7
OUTPUT
OUTPUT:
enter a number 45
9
Program 9
d=0
n=int(input("enter a number "))
l=len(str(n))
for i in range (l):
r=n%10
d=d*10+r
n=n//10
print (d)
OUTPUT:
Program 10
d=0
n=int(input("enter a number "))
t=n
l=len(str(n))
for i in range (l):
r=n%10
d=d*r**l
n=n//10
if d==t:
print ("the entered number is an amstrong number ")
else:
print ("the entered number is not an amstrong number ")
OUTPUT:
enter a number 22
the entered number is not an amstrong number
Program 11
OUTPUT:
enter a number 6
the entered number is a perfect number
Program 12
OUTPUT
OUTPUT
Program 14
OUTPUT
Program 15
OUTPUT
(i)
a=ord('A')
b=int(input("enter the number of rows: "))
for i in range(b):
for j in range (i+1):
print (chr(a+j),end='')
print ()
OUTPUT
(ii)
a=int(input("enter the number of rows: "))
b=1
for i in range (a):
for j in range (i+1):
print(b,end='')
b=b+1
print()
OUTPUT
(iii)
a=int(input("enter the number of rows: "))
for i in range (a):
for j in range (i+1):
print ('*',end='')
print()
OUTPUT
Program 17