Project Overview 💡
In this real-world project, you’ll build a lightweight Streamlit app that allows users to convert distances between kilometers and miles in both directions. This project helps reinforce your knowledge of functions, user input handling, and interactive UI design with Streamlit.
Challenge Yourself! 🚀
Before checking the solution, try creating a Streamlit interface that lets users enter a value and select between kilometers-to-miles or miles-to-kilometers conversion.
Task:
Create a Streamlit app that:
Provides a radio button to select conversion direction
Accepts a numeric input for distance
Displays the converted value upon clicking a button
Expected Output:
The output is an interactive browser-based UI where the user selects a direction, enters a number, clicks a button, and sees the conversion result displayed below.
Give it a shot! Scroll down when you're ready for the step-by-step guide.
Spoiler Alert!
Step-by-Step Guide
Step 1️⃣: Import Streamlit
Start by importing the Streamlit module.
import streamlit as st
Step 2️⃣: Define Conversion Functions
Create two helper functions for both directions of conversion.