0% found this document useful (0 votes)
6 views4 pages

Practical Exam Programs

Uploaded by

hlohlo032004
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)
6 views4 pages

Practical Exam Programs

Uploaded by

hlohlo032004
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/ 4

List of 16 Programs for Practical Exam

1. Program to Find Area of Circle

radius = float(input("Enter the radius of the circle: "))

area = 3.14159 * radius * radius

print(f"The area of the circle is: {area}")

2. Program to Find Area of Square

side = float(input("Enter the side length of the square: "))

area = side * side

print(f"The area of the square is: {area}")

3. Program to Find Area of Rectangle

length = float(input("Enter the length of the rectangle: "))

width = float(input("Enter the width of the rectangle: "))

area = length * width

print(f"The area of the rectangle is: {area}")

4. Program to Find Area of Triangle

base = float(input("Enter the base of the triangle: "))

height = float(input("Enter the height of the triangle: "))

area = 0.5 * base * height

print(f"The area of the triangle is: {area}")

5. Program to Find Average of 3 Numbers

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

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

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

average = (a + b + c) / 3
print(f"The average of the three numbers is: {average}")

6. Program to Convert Kilometers to Miles

km = float(input("Enter distance in kilometers: "))

miles = km * 0.621371

print(f"The distance in miles is: {miles}")

7. Program to Find Largest Number

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

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

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

largest = max(a, b, c)

print(f"The largest number is: {largest}")

8. Program to Check if Year is Leap Year

year = int(input("Enter a year: "))

if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):

print(f"{year} is a leap year.")

else:

print(f"{year} is not a leap year.")

9. Program Creating List (Numbers, Strings, Numbers and Strings)

numbers = [1, 2, 3, 4, 5]

strings = ["apple", "banana", "cherry"]

mixed = [1, "apple", 2.5, "banana"]

print("Numbers List:", numbers)

print("Strings List:", strings)

print("Mixed List:", mixed)


10. Program to Check if Number is Positive, Negative, or Zero

num = float(input("Enter a number: "))

if num > 0:

print("The number is positive.")

elif num < 0:

print("The number is negative.")

else:

print("The number is zero.")

11. Program to Find Square Root of a Number

num = float(input("Enter a number: "))

sqrt = num ** 0.5

print(f"The square root of {num} is: {sqrt}")

12. Program to Swap Two Variables

a = input("Enter the first variable: ")

b = input("Enter the second variable: ")

a, b = b, a

print(f"After swapping: First variable = {a}, Second variable = {b}")

13. Program to Display Multiplication Table from 1 to 10

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

for i in range(1, 11):

print(f"{num} x {i} = {num * i}")

14. Program to Convert Fahrenheit to Celsius

fahrenheit = float(input("Enter temperature in Fahrenheit: "))

celsius = (fahrenheit - 32) * 5/9

print(f"The temperature in Celsius is: {celsius}")


15. Program to Create Tuple

t = (1, "apple", 3.5, "banana")

print("The created tuple is:", t)

16. Program to Check Eligibility for Voting

age = int(input("Enter your age: "))

if age >= 18:

print("You are eligible to vote.")

else:

print("You are not eligible to vote.")

You might also like