0% found this document useful (0 votes)
5 views3 pages

Practical Record File

The document contains a practical record file with five programming exercises. Each exercise includes an aim, source code, and sample output for tasks such as finding the maximum of three numbers, checking for Armstrong numbers, generating number patterns, calculating factorials, and summing even numbers while multiplying odd numbers. The provided source codes are written in Python.

Uploaded by

shivanshjerk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Practical Record File

The document contains a practical record file with five programming exercises. Each exercise includes an aim, source code, and sample output for tasks such as finding the maximum of three numbers, checking for Armstrong numbers, generating number patterns, calculating factorials, and summing even numbers while multiplying odd numbers. The provided source codes are written in Python.

Uploaded by

shivanshjerk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

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

You might also like