Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Computer Practical File

Uploaded by

ansh.bhatia
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)
2 views

Computer Practical File

Uploaded by

ansh.bhatia
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/ 14

C o m p u t e r

practical le
1. A company is developing a payroll management system. They need a program that
takes two integers representing employee hours worked and hourly rate, and
calculates the total salary for the employee.
hours = int(input("Enter the number of hours worked: "))
rate = int(input("Enter the hourly rate: "))
salary = hours*rate
print("Your salary is:", salary)

2. A landscaping company wants to create an application to estimate the materials


needed for circular flower beds. They require a program that takes the radius
of the circular flower bed as input and calculates the amount of mulch required.
radius = oat(input("Enter the radius of the ower bed: "))
area = 3.14 * (radius ** 2)
print("The area of the ower bed is:", area)
fl
fl
fl
fi
3. An architect is designing a building with triangular-shaped windows. They need a
program that accepts the base and height of the triangular window and calculates
the amount of glass needed for each window
base = int(input("Enter the base of the window: "))
height = int(input("Enter the height of the window: "))
area = 0.5 * base * height
print("The area of the window is:", area)

4. A teacher wants to track student performance in a course. They need a program


that takes the marks of three assignments as input and calculates the overall
percentage of the student's performance.
marks1 = int(input("Enter the mark of assignment 1: "))
marks2 = int(input("Enter the mark of assignment 2: "))
marks3 = int(input("Enter the mark of assignment 3: "))
total_marks = marks1 + marks2 + marks3
percentage = (total_marks / 300) * 100
print("The student's overall percentage is:", percentage)

5. A home improvement store wants to offer customers a tool to estimate flooring


requirements. They need a program that calculates the area of both a square room
and a triangular hallway based on user input dimension
6. A bank is updating its loan management system. They require a program that
calculates the simple interest on loans based on user-input principal amount,
interest rate, and time period.
principal = int(input("Enter principal: "))
rate = int(input("Enter rate (%): "))
me = int(input("Enter me (years): "))
simple_interest = (principal * rate * me) / 100
print("Simple interest:", simple_interest)

7. A shipping company needs a program to calculate shipping costs. They require a


program that takes two numbers representing weight and distance, and calculates
both the shipping cost and any applicable discounts.
def calculate_shipping_cost():
weight = int(input("Enter weight: "))
distance = int(input("Enter distance: "))
base_cost = weight * distance
if base_cost > 100:
print("Base cost:", base_cost)
print("Discount:", base_cost * 0.1)
print("Total cost:", base_cost - (base_cost * 0.1))
else:
print("Base cost:", base_cost)
calculate_shipping_cost()
ti
ti
ti
8. A gaming company is developing a number guessing game. They need a program
that determines whether a user-input number is even or odd to provide feedback to
the player.

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


if number % 2 == 0:
print("The number is even.")
else:
print("The number is odd.")

9. A hiring manager wants to streamline the interview process. They need a program
that compares the performance scores of three job candidates and identifies the
candidate with the highest score.

10. A retail store wants to optimize inventory management. They require a program
that compares the sales figures of three products and identifies the product with the
lowest sales. p1 = int(input("Enter sales figure for product 1: "))
p2 = int(input("Enter sales gure for product 2: "))
p3 = int(input("Enter sales gure for product 3: "))
fi
fi
# Print the product with the lowest sales
print("Product", min(p1, p2, p3) == p1 and "1" or min(p1, p2, p3) == p2 and "2" or "3", "
has the lowest sales.")

11. An interior designer is planning carpeting for a room. They need a program that
calculates the total area of the room based on user input dimensions of length and
width.
print("Enter room dimensions in meters:")
length = int(input("Length: "))
width = int(input("Width: "))
print("Room area:", length * width, "square meters.")

12. A fitness app wants to offer users a BMI calculator. They require a program that
calculates BMI based on user-input weight in kilograms and height in meters
height = oat(input("Enter your height in meters: "))
weight = oat(input("Enter your weight in kilograms: "))
print("Your BMI is:", weight / height ** 2)
fl
fl
13. A scientist is conducting research on numerical patterns. They need a program that
calculates and displays the square, cube, and fourth power of a user-input number
x =int(input("Enter a number: "))
print("Square:", x**2)
print("Cube:", x**3)
print("Fourth Power:", x**4)

14. A teacher is evaluating student performance over multiple subjects. They need a
program that calculates the average marks of a student based on input marks for
five subjects.
marks1 = oat(input("Enter the mark of 1: "))
marks2 = oat(input("Enter the mark of 2: "))
marks3 = oat(input("Enter the mark of 3: "))
marks4 = oat(input("Enter the mark of 4: "))
marks5 = oat(input("Enter the mark of 5: "))
total_marks = marks1 + marks2 + marks3 + marks4 + marks5
percentage = (total_marks / 500) * 100
print("The student's overall percentage is:", percentage)
fl
fl
fl
fl
fl
15. A real estate agency wants to offer a tool for converting property dimensions. They
need a program that converts height from centimeters to feet and inches.
cm = int(input("Enter height in cm: "))
print(f"{cm} cm is {cm/2.54} feet")

16. An election commission wants to facilitate voter registration. They require a


program that checks the age of a user and determines whether they are eligible to
vote.
age = int(input("Enter your age: "))
print("Eligible to vote" if age >= 18 else "Not eligible to vote")
17. A construction company is estimating materials for a project. They require a
program that calculates the area and perimeter of a parallelogram based on user-
input dimensions.
num1 = int(input("Enter the rst number: "))
num2 = int(input("Enter the second number: "))
if num1 % num2 == 0:
print("Divisible")
else:
print("Not Divisible"

18. A calendar application wants to include a feature for identifying leap years. They
need a program that checks whether a user-input year is a leap year.
year = int(input("Enter the year: "))
if year % 4 == 0:
print(year, "is a leap year")
else:
print(year, "is not a leap year")

19. A scientific research team is conducting simulations. They require a program that
calculates a complex mathematical expression based on user-input values for x, y,
and z.
x = int(input("Enter the value of x: "))
fi
y = int(input("Enter the value of y: "))
z = int(input("Enter the value of z: "))
result = (x**3 + 2*y**2 - 3*z) / (x**2 + y*z + z**2)
print("The result is:", result)

20. A math tutor wants to provide personalized exercises for students. They need a
program that calculates the square of a user-input number if it is odd, or the square
root if it is even.
num = int(input("Enter a number: "))
if num % 2 != 0:
result = num ** 2
else:
result = math.sqrt(num)
print(f"The result is: {result}")

21. A sentiment analysis tool wants to categorize user feedback. They require a
program that determines whether a user-input number is positive, negative, or zero.
num = int(input("Enter a number: "))
if num:
if num > 0:
print("Posi ve")
else:
print("Nega ve")
ti
ti
else:
print("Zero")

22. A teacher wants to automate grading for a class. They require a program that
assigns a grade (A, B, C, or D) to a student based on their percentage marks
marks = oat(input("Enter the student's marks: "))
if marks >= 90:
print("Grade: A")
elif marks >= 80:
print("Grade: B")
elif marks >= 70:
print("Grade: C")
else:
print("Grade: D")

23. A number theorist wants to identify prime numbers. They require a program that
checks whether a user-input number is prime or not.
n = int(input("Enter a number: "))
if n <= 1:
print(n, "is not a prime number")
elif any(n % i == 0 for i in range(2, n)):
print(n, "is not a prime number")
fl
else:
print(n, "is a prime number")

24. A geometry application wants to provide various calculations for users. They
require a program that displays a menu allowing users to choose between
calculating the area or perimeter of a circle.
print("Geometry Calculator")
print("1. Calculate Area")
print("2. Calculate Perimeter")
choice = int(input("Choose an op on (1 or 2): "))
if choice == 1:
print("The area of the circle is: ", math.pi * oat(input("Enter the radius of the circle: "))
** 2)
elif choice == 2:
print("The perimeter of the circle is: ", 2 * math.pi * oat(input("Enter the radius of the
circle: ")))
else:
print("Invalid choice. Please choose a valid op on.")

25. A calculator application wants to offer advanced features. They require a program
that takes two numbers, an arithmetic operator (+, -, *, /), and displays the result of
the operation.
def calculator():
a = oat(input("Enter rst number: "))
b = input("Enter operator (+, -, * , /): ")
fl
fi
ti
fl
ti
fl
c = oat(input("Enter second number: "))
if b == "+":
print(a + c)
elif b == "-":
print(a - c)
elif b == "*":
print(a * c)
elif b == "/":
if c != 0:
print(a / c)
else:
print("Error! Division by zero is not allowed.")
else:
print("Invalid operator. Please enter +, -, * or /.")
calculator()

26. A data validation tool wants to classify user-input characters. They require a
program that determines whether a character is uppercase, lowercase, a digit, or
any other character.
char = input("Enter a character: ")

if char.isupper():
print("Uppercase")
elif char.islower():
print("Lowercase")
elif char.isdigit():
print("Digit")
else:
print("Something else")
fl
27. A math solver application wants to solve quadratic equations. They require a
program that calculates and prints the roots of a quadratic equation provided by the
user.
a = oat(input("Enter coe cient a: "))
b = oat(input("Enter coe cient b: "))
c = oat(input("Enter coe cient c: "))
d = b**2 - 4*a*c
if d > 0:
print("Roots are: ", (-b + math.sqrt(d)) / (2*a), " and ", (-b - math.sqrt(d)) / (2*a))
elif d == 0:
print("Root is: ", -b / (2*a))
else:
print("No real roots for this equa on")

28. A math tutor wants to teach addition to students. They require a program that prints
the sum of natural numbers between 1 to 7 progressively.
total = 0
for i in range(1, 8):
total += i
print("The sum of natural numbers between 1 to 7 is:", total)
fl
fl
fl
ffi
ffi
ffi
ti
29. A math enthusiast wants to explore factorials. They require a program that
calculates the factorial of a user-input number.
n = int(input("Enter a posi ve integer: "))
factorial = 1
for i in range(1, n+1):
factorial *= i
print("The factorial of", n, "is:", factorial)
ti

You might also like