Computer Science Project
Computer Science Project
science project
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)
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 (%): "))
time = int(input("Enter time (years): "))
simple_interest = (principal * rate * time) / 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()
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.
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 figure for product 2: "))
p3 = int(input("Enter sales figure for product 3: "))
# 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 = float(input("Enter your height in meters: "))
weight = float(input("Enter your weight in kilograms: "))
print("Your BMI is:", weight / height ** 2)
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")
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")
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("Positive")
else:
print("Negative")
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 = float(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")
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 option (1 or 2): "))
if choice == 1:
print("The area of the circle is: ", math.pi * float(input("Enter the radius of the
circle: ")) ** 2)
elif choice == 2:
print("The perimeter of the circle is: ", 2 * math.pi * float(input("Enter the radius of
the circle: ")))
else:
print("Invalid choice. Please choose a valid option.")
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 = float(input("Enter first number: "))
b = input("Enter operator (+, -, * , /): ")
c = float(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")
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 = float(input("Enter coefficient a: "))
b = float(input("Enter coefficient b: "))
c = float(input("Enter coefficient 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 equation")
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)
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 positive integer: "))
factorial = 1
for i in range(1, n+1):
factorial *= i
print("The factorial of", n, "is:", factorial)