-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment1.py
More file actions
29 lines (22 loc) · 1.01 KB
/
Assignment1.py
File metadata and controls
29 lines (22 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import streamlit as st
# Function to calculate Simple Interest
def calculate_simple_interest(principal, rate, time):
simple_interest = (principal * rate * time) / 100
return simple_interest
# Function to calculate Compound Interest
def calculate_compound_interest(principal, rate, time):
compound_interest = principal * (1 + rate / 100) ** time - principal
return compound_interest
# Streamlit App
def main():
st.title("Interest Calculator")
principal = st.number_input("Enter Principal Amount:", min_value=0.0)
rate = st.number_input("Enter Rate of Interest (%):", min_value=0.0)
time = st.number_input("Enter Time (years):", min_value=0.0)
if st.button("Calculate Interest"):
simple_interest = calculate_simple_interest(principal, rate, time)
compound_interest = calculate_compound_interest(principal, rate, time)
st.write(f"Simple Interest: {simple_interest:.2f}")
st.write(f"Compound Interest: {compound_interest:.2f}")
if __name__ == "__main__":
main()