Computer Practical Record File
Q1. Find Maximum of Three Numbers
Aim:
To write a program to find the maximum number out of three given numbers.
Source Code:
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))
print("Maximum number is:", max(a, b, c))
Sample Output:
Enter first number: 12
Enter second number: 25
Enter third number: 9
Maximum number is: 25
Q2. Check Armstrong Number
Aim:
To write a program to check whether a given number is an Armstrong number or not.
Source Code:
n = int(input("Enter a number: "))
s = sum(int(d)**3 for d in str(n))
print("Armstrong number" if s == n else "Not an Armstrong number")
Sample Output:
Enter a number: 153
Armstrong number
Q3. Generate Number Pattern
Aim:
Computer Practical Record File
To write a program to generate the given pattern.
Source Code:
n=1
for i in range(1, 6):
for j in range(i):
print(n, end=" ")
n += 1
print()
Sample Output:
23
456
7 8 9 10
11 12 13 14 15
Q4. Find Factorial of a Number
Aim:
To write a program to find the factorial of a given number.
Source Code:
n = int(input("Enter a number: "))
f=1
for i in range(1, n+1):
f *= i
print("Factorial is:", f)
Sample Output:
Enter a number: 5
Factorial is: 120
Computer Practical Record File
Q5. Sum of Even and Product of Odd (1 to 10)
Aim:
To write a program to find the sum of even numbers and the product of odd numbers in the range 1 to 10.
Source Code:
s=0
p=1
for i in range(1, 11):
if i % 2 == 0:
s += i
else:
p *= i
print("Sum of even:", s)
print("Product of odd:", p)
Sample Output:
Sum of even: 30
Product of odd: 945