Coding Lab Record
Coding Lab Record
#WAP to input two numbers and find the largest and smallest number amongst them.
if(a>b):
else:
Output:
#WAP to input three numbers and display the largest and smallest number.
if b>c:
print("Greatest number:",a)
print("Smallest number:",c)
else:
print("Greatest number:",a)
print("Smallest number:",b)
if a>c:
print("Greatest number:",b)
print("Smallest number:",c)
else:
print("Greatest number:",b)
print("Smallest number:",a)
else:
if b>a:
print("Greatest number:",c)
print("Smallest number:",a)
else:
print("Greatest number:",c)
print("Smallest number:",b)
if a==b==c:
Output:
Enter first number=78
Smallest number: 78
PROGRAM III
if b>c:
else:
if a>c:
else:
else:
if a>b:
else:
Output:
for i in range(6,1,-1):
for j in range(1,i):
print(j, end=" ")
print()
Output:
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Program IV(III)
Name: Natasha Kishore Pandaran
Grade XI A 2023-24
Date of execution: 24-07-2023
#WAP to generate the following pattern using loop
A
A B
A B C
A B C D
for i in range(65,70):
for j in range(65,i):
print(chr(j), end="")
print()
Output:
A
AB
ABC
ABCD
Program V
Name: Natasha Kishore Pandaran
Grade XI A 2023-24
Date of execution: 24-07-2023
#WAP to find the factorial of a number
n=int(input("Enter a number:"))
fact=1
a=1
while a<=n:
fact=fact*a
a=a+1
print("The factorial of",n,"is",fact)
Output:
Enter a number:8
The factorial of 8 is 40320
Program VI
Name: Natasha Kishore Pandaran
Grade XI A 2023-24
Date of execution: 24-07-2023
#WAP to find whether a given number is Armstrong number or not.
num=int(input("Enter a three digit number:"))
summ=0
temp=num
while(temp>0):
digit=temp%10
summ+=digit**3
temp=temp//10
if num==summ:
print(num,"is an Armstrong number.")
else:
print(num,"is not an Armstrong number.")
Output:
Enter a three digit number:407
407 is an Armstrong number.
Program VII
Name: Natasha Kishore Pandaran
Grade XI A 2023-24
Date of execution: 24-07-2023
#WAP to find whether a given number is a Palindrome number or not.
n=int(input("Enter number:"))
temp=n
rev=0
while(n>0):
dig=n%10
rev=rev*10+dig
n=n//10
if(temp==rev):
print("This number is a palindrome")
else:
print("This number isn't a palindrome")
Output:
Enter number:121
The number is a palindrome