Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Program I

Name: Natasha Kishore Pandaran


Grade XI A 2023-24
Date of execution: 24-07-2023

#WAP to input two numbers and find the largest and smallest number amongst them.

a=int(input("Enter first number:"))

b=int(input("Enter second number:"))

if(a>b):

print("The greatest number is",a)

print("The smallest number is",b)

else:

print("The greatest number is",b)

print("The smallest number is",a)

Output:

Enter first number:678

Enter second number:988

The greatest number is 988

The smallest number is 678


Program II
Name: Natasha Kishore Pandaran
Grade XI A 2023-24
Date of execution: 24-07-2023

#WAP to input three numbers and display the largest and smallest number.

a=int(input("Enter first number="))

b=int(input("Enter second number="))

c=int(input("Enter third number="))

if a>b and a>c:

if b>c:
print("Greatest number:",a)
print("Smallest number:",c)

else:

print("Greatest number:",a)

print("Smallest number:",b)

elif b>a and b>c:

if a>c:

print("Greatest number:",b)

print("Smallest number:",c)

else:

print("Greatest number:",b)

print("Smallest number:",a)

else:

if c>a and c>b:

if b>a:

print("Greatest number:",c)

print("Smallest number:",a)

else:

print("Greatest number:",c)

print("Smallest number:",b)

if a==b==c:

print("all the numbers are equal")

Output:
Enter first number=78

Enter second number=98

Enter third number=677

Greatest number: 677

Smallest number: 78
PROGRAM III

Name: Natasha Kishore Pandaran


Grade XI A 2023-24
Date of execution: 24-07-2023

#WAP to input three numbers and arrange them in ascending order.

a=int(input("Enter first number:"))

b=int(input("Enter second number:"))

c=int(input("Enter third number:"))

if a>b and a>c:

if b>c:

print("The given numbers in ascending order are:",c,b,a)

else:

print("The given numbers in ascending order are:",b,c,a)

elif b>c and b>a:

if a>c:

print("The given numbers in ascending order are:",c,a,b)

else:

print("The given numbers in ascending order are:",a,c,b)

else:

if c>a and c>b:

if a>b:

print("The given numbers in ascending order are:",b,a,c)

else:

print("The given numbers in ascending order are:",a,b,c)

Output:

Enter first number:455

Enter second number:677

Enter third number:9000

The given numbers in ascending order are: 455 677 9000


Program IV (I)

Name: Natasha Kishore Pandaran


Grade XI A 2023-24
Date of execution: 24-07-2023
#WAP to generate the following pattern using loop
*
**
***
****

for i in range (1,5):


for j in range (1,i+1):
print("*",end="")
print()
Output:
*
**
***
****
Program IV(II)
Name: Natasha Kishore Pandaran
Grade XI A 2023-24
Date of execution: 24-07-2023
#WAP to generate the following pattern using loop
12345
1234
123
12
1

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

You might also like