0% found this document useful (0 votes)
4 views

CS Work (1)

The Unit Converter is a Python program designed to convert measurements in temperature, length, and weight, making it user-friendly for various users. It features categories for Celsius to Fahrenheit, meters to kilometers, and grams to kilograms conversions, with error handling for invalid inputs. The program is beneficial for education, daily life, science, engineering, and business, providing time-saving, accurate, and convenient conversions.

Uploaded by

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

CS Work (1)

The Unit Converter is a Python program designed to convert measurements in temperature, length, and weight, making it user-friendly for various users. It features categories for Celsius to Fahrenheit, meters to kilometers, and grams to kilograms conversions, with error handling for invalid inputs. The program is beneficial for education, daily life, science, engineering, and business, providing time-saving, accurate, and convenient conversions.

Uploaded by

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

1.

Introduction

A Unit Converter is a useful tool that helps in


converting measurements from one unit to
another. Whether it's converting temperature
from Celsius to Fahrenheit, length from meters
to kilometers, or weight from grams to
kilograms, this program simplifies the task.
This project is designed using Python and
focuses on applying basic programming
concepts such as conditional statements, loops,
and arithmetic operations. It is an easy-to-use
program for students, professionals, and
anyone who needs quick and accurate
conversions.
2. Explanation of the Project

The Unit Converter program is divided into


three categories:
1. Temperature Conversion: Converts
between Celsius and Fahrenheit.
2. Length Conversion: Converts between
meters and kilometers.
3. Weight Conversion: Converts
between grams and kilograms.
The user selects the desired category and
follows the prompts to input the value to be
converted. Based on the input, the program
performs the conversion using simple
arithmetic formulas and displays the result.
The program also handles invalid inputs to
ensure a user-friendly experience.
3. Source Code
def temperature_converter():
print("1. Celsius to Fahrenheit")
print("2. Fahrenheit to Celsius")
choice = int(input("Choose an option (1 or 2): "))
if choice == 1:
celsius = float(input("Enter temperature in Celsius: "))
fahrenheit = (celsius * 9/5) + 32
print(f"{celsius}°C is equal to {fahrenheit}°F.")
elif choice == 2:
fahrenheit = float(input("Enter temperature in
Fahrenheit: "))
celsius = (fahrenheit - 32) * 5/9
print(f"{fahrenheit}°F is equal to {celsius}°C.")
else:
print("Invalid choice!")
def length_converter():
print("1. Meters to Kilometers")
print("2. Kilometers to Meters")
choice = int(input("Choose an option (1 or 2): "))

if choice == 1:
meters = float(input("Enter length in meters: "))
kilometers = meters / 1000
print(f"{meters} meters is equal to {kilometers}
kilometers.")
elif choice == 2:
kilometers = float(input("Enter length in kilometers: "))
meters = kilometers * 1000
print(f"{kilometers} kilometers is equal to {meters}
meters.")
else:
print("Invalid choice!")
def weight_converter():
print("1. Grams to Kilograms")
print("2. Kilograms to Grams")
choice = int(input("Choose an option (1 or 2): "))
if choice == 1:
grams = float(input("Enter weight in grams: "))
kilograms = grams / 1000
print(f"{grams} grams is equal to {kilograms}
kilograms.")
elif choice == 2:
kilograms = float(input("Enter weight in kilograms: "))
grams = kilograms * 1000
print(f"{kilograms} kilograms is equal to {grams}
grams.")
else:
print("Invalid choice!")
# Main program
print("Unit Converter")
print("1. Temperature")
print("2. Length")
print("3. Weight")
main_choice = int(input("Choose a category (1, 2, or 3): "))
if main_choice == 1:
temperature_converter()
elif main_choice == 2:
length_converter()
elif main_choice == 3:
weight_converter()
else:
print("Invalid choice!")
4.Output
5.. Applications
1.
2. Education: Students can use the
program to perform conversions quickly
during study sessions or assignments.
3. Daily Life: Helpful for people in
everyday scenarios, such as converting
weights while shopping or converting
temperatures when traveling.
4. Science and Research: Scientists and
researchers can use it to convert units
while conducting experiments.
5. Engineering: Engineers often need
unit conversions while designing systems
or solving problems.
6. Business: Useful in industries like
logistics and manufacturing for measuring
and converting units efficiently.
6. Importance

1. Time-Saving: The Unit Converter


eliminates the need for manual
calculations, saving time.
2. Accuracy: Ensures accurate results,
reducing the chances of errors in
calculations.
3. Convenience: Provides an easy and
interactive way to perform unit
conversions for various fields.
4. Learning Tool: Helps beginners learn
about different units and their
relationships.
5. Scalability: The project can be
expanded to include more units or
categories, making it a versatile tool for
broader applications.

You might also like