0% found this document useful (0 votes)
4 views5 pages

Mini Project 1 Solutions

The document provides solutions for a mini project involving various Python programming tasks, including string formatting, temperature conversion, number swapping, calculating Euclidean distance, simple interest, and more. Each question is followed by a Python code solution that demonstrates how to implement the required functionality. The tasks cover a range of topics suitable for beginners to practice their coding skills.

Uploaded by

23pp3010
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)
4 views5 pages

Mini Project 1 Solutions

The document provides solutions for a mini project involving various Python programming tasks, including string formatting, temperature conversion, number swapping, calculating Euclidean distance, simple interest, and more. Each question is followed by a Python code solution that demonstrates how to implement the required functionality. The tasks cover a range of topics suitable for beginners to practice their coding skills.

Uploaded by

23pp3010
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/ 5

Python Solutions for Mini Project - 1

Q1: Print strings in a specific format

Solution:

print("Data-Science-Mentorship-Program-started-By-Wayspire")

Q2: Celsius to Fahrenheit

Solution:

celsius = float(input("Enter temperature in Celsius: "))

fahrenheit = (celsius * 9/5) + 32

print("Temperature in Fahrenheit:", fahrenheit)

Q3: Swap numbers without Python's built-in swap

Solution:

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

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

# Using arithmetic

a=a+b

b=a-b

a=a-b

print("After swapping: a =", a, ", b =", b)

Q4: Euclidean distance between two coordinates


Solution:

import math

x1, y1 = map(float, input("Enter first coordinate (x1 y1): ").split())

x2, y2 = map(float, input("Enter second coordinate (x2 y2): ").split())

distance = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)

print("Euclidean Distance:", distance)

Q5: Simple Interest

Solution:

p = float(input("Enter principal: "))

r = float(input("Enter rate of interest: "))

t = float(input("Enter time period in years: "))

si = (p * r * t) / 100

print("Simple Interest:", si)

Q6: Dogs and chickens

Solution:

heads = int(input("Enter total heads: "))

legs = int(input("Enter total legs: "))

dogs = (legs // 2 - heads) // 2

chickens = heads - dogs


print("dogs ->", dogs)

print("chickens ->", chickens)

Q7: Sum of squares of first n natural numbers

Solution:

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

sum_of_squares = sum(i**2 for i in range(1, n+1))

print("Sum of squares:", sum_of_squares)

Q8: Nth term of an Arithmetic Series

Solution:

a = int(input("Enter first term: "))

d = int(input("Enter common difference: "))

n = int(input("Enter the term number: "))

nth_term = a + (n - 1) * d

print("Nth term:", nth_term)

Q9: Sum of two fractions

Solution:

numerator1 = int(input("Enter numerator of first fraction: "))

denominator1 = int(input("Enter denominator of first fraction: "))

numerator2 = int(input("Enter numerator of second fraction: "))

denominator2 = int(input("Enter denominator of second fraction: "))


# Find common denominator

common_denominator = denominator1 * denominator2

sum_numerator = (numerator1 * denominator2) + (numerator2 * denominator1)

print("Sum of the fractions:", sum_numerator, "/", common_denominator)

Q10: Glasses of milk from tank

Solution:

H = float(input("Enter height of tank in cm: "))

L = float(input("Enter length of tank in cm: "))

B = float(input("Enter breadth of tank in cm: "))

h = float(input("Enter height of glass in cm: "))

r = float(input("Enter radius of glass in cm: "))

tank_volume = H * L * B

glass_volume = 3.14 * (r ** 2) * h

glasses = tank_volume / glass_volume

print("Number of glasses:", int(glasses))

Q11: Monthly salary calculation after deductions

Solution:

ctc = float(input("Enter CTC in Lakhs: "))

hra = ctc * 0.10

da = ctc * 0.05
pf = ctc * 0.03

tax = 0

if ctc < 5:

tax = 0

elif 5 <= ctc < 10:

tax = 10

elif 10 <= ctc < 20:

tax = 20

else:

tax = 30

tax_deduction = ctc * tax / 100

net_salary = ctc - (hra + da + pf + tax_deduction)

print("Net Monthly Salary:", net_salary)

You might also like