| import streamlit as st |
| from sympy import symbols, Eq, solve, sympify, binomial, factorial |
| import matplotlib.pyplot as plt |
| import numpy as np |
| from tkinter import ttk |
| from fractions import Fraction |
| from datetime import datetime |
|
|
| |
| def solve_user_equation(): |
| equation_str = st.text_input("Enter the equation:") |
| |
| if equation_str: |
| x, y = symbols('x y') |
| try: |
| equation = Eq(sympify(equation_str), 0) |
| solution = solve(equation, x) |
| st.text(f"x values: {solution}") |
| except SympifyError: |
| st.text("Invalid equation format. Please enter a valid equation.") |
| else: |
| st.text("Please enter an equation.") |
|
|
|
|
| |
| def calculate_expression(): |
| expression_str = st.text_input("Enter the expression:") |
| expression = sympify(expression_str) |
| result = expression.evalf() |
| st.text(f"Result: {result}") |
|
|
| |
| def calculate_custom_expression(): |
| custom_expression_str = st.text_input("Enter the custom expression:") |
| x, y = symbols('x y') |
| custom_expression = sympify(custom_expression_str) |
| result = custom_expression.evalf(subs={x: 3, y: 5}) |
| st.text(f"Result: {result}") |
|
|
| |
| def factor_and_expand(): |
| |
| pass |
|
|
| |
| def calculate_days_remaining(): |
| target_date_str = st.text_input("Enter the target date (YYYY-MM-DD):") |
| try: |
| target_date = datetime.strptime(target_date_str, "%Y-%m-%d") |
| current_date = datetime.now() |
| days_remaining = (target_date - current_date).days |
| st.text(f"Days remaining: {days_remaining} days") |
| except ValueError: |
| st.text("Invalid date format. Use YYYY-MM-DD.") |
|
|
| |
| def calculate_combination(): |
| n = int(st.text_input("Enter n:")) |
| m = int(st.text_input("Enter m:")) |
| result = binomial(n, m) |
| st.text(f"{n}C{m} is {result}") |
|
|
| |
| def calculate_permutation(): |
| n = int(st.text_input("Enter n:")) |
| m = int(st.text_input("Enter m:")) |
| result = factorial(n) / factorial(n - m) |
| st.text(f"{n}P{m} is {result}") |
|
|
| |
| def calculate_intersection(): |
| |
| pass |
|
|
| |
| def calculate_probability(): |
| n = int(st.text_input("Enter n (number of faces on the dice):")) |
| min_value = int(st.text_input("Enter the minimum value:")) |
| values = st.text_input("Enter values (comma-separated):").split(',') |
| target_option = st.selectbox("Select target option:", ["Comma Separated", "Multiples", "Factors", "Custom Function"]) |
| target_value = st.text_input("Enter target value:") |
| as_fraction = st.checkbox("Display result as fraction") |
|
|
| |
|
|
| |
| def main(): |
| st.title("Combined Streamlit App") |
|
|
| st.header("Equation Solver") |
| solve_user_equation() |
| calculate_expression() |
| calculate_custom_expression() |
|
|
| st.header("Factorization and Expansion") |
| factor_and_expand() |
|
|
| st.header("Dice App") |
| calculate_probability() |
|
|
| st.header("Intersection Calculator") |
| calculate_intersection() |
|
|
| st.header("Days Remaining Calculator") |
| calculate_days_remaining() |
|
|
| st.header("Combination and Permutation Calculator") |
| calculate_combination() |
| calculate_permutation() |
|
|
| if __name__ == "__main__": |
| main() |
|
|