Spaces:
Sleeping
Sleeping
| # calculator_app.py | |
| import streamlit as st | |
| st.set_page_config(page_title="Interactive Calculator", page_icon="๐งฎ", layout="centered") | |
| st.markdown("<h1 style='text-align: center;'>๐งฎ Simple Calculator App</h1>", unsafe_allow_html=True) | |
| st.markdown("<p style='text-align: center; color: gray;'>Perform basic math operations easily and quickly๐!</p>", unsafe_allow_html=True) | |
| # --- Layout with columns and containers --- | |
| with st.container(): | |
| col1, col2 = st.columns(2) | |
| with col1: | |
| num1 = st.number_input("๐ข Enter First Number", value=0.0, step=1.0) | |
| with col2: | |
| num2 = st.number_input("๐ข Enter Second Number", value=0.0, step=1.0) | |
| with st.container(): | |
| operation = st.radio( | |
| "๐งฉ Choose Operation", | |
| options=["โ Addition", "โ Subtraction", "โ๏ธ Multiplication", "โ Division"], | |
| horizontal=True | |
| ) | |
| # --- Perform calculation --- | |
| st.markdown("---") | |
| if st.button("๐ฏ Calculate"): | |
| st.subheader("๐ Result Details:") | |
| if operation == "โ Addition": | |
| result = num1 + num2 | |
| st.success(f"โ {num1} + {num2} = {result}") | |
| elif operation == "โ Subtraction": | |
| result = num1 - num2 | |
| st.success(f"โ {num1} - {num2} = {result}") | |
| elif operation == "โ๏ธ Multiplication": | |
| result = num1 * num2 | |
| st.success(f"โ {num1} ร {num2} = {result}") | |
| elif operation == "โ Division": | |
| if num2 == 0: | |
| st.error("โ Cannot divide by zero!") | |
| else: | |
| result = num1 / num2 | |
| st.success(f"โ {num1} รท {num2} = {result}") | |
| else: | |
| st.info("Please enter values and select an operation, then press 'Calculate'.๐ค") | |
| # Footer | |
| st.markdown("---") | |
| st.markdown("<p style='text-align: center; font-size: 12px; color: gray;'>Build by ALISHBA๐</p>", unsafe_allow_html=True) |