Skip to content

Instantly share code, notes, and snippets.

@sheriffff
Created April 1, 2025 21:47
Show Gist options
  • Save sheriffff/d63c75fd21b843c233de251442bbb801 to your computer and use it in GitHub Desktop.
Save sheriffff/d63c75fd21b843c233de251442bbb801 to your computer and use it in GitHub Desktop.
import numpy as np
import streamlit as st
def is_prime(n):
"""Check if a number is prime."""
if n <= 1:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
st.title("Prime Number Checker")
st.text("Hola amigo")
st.markdown("Si tienes alguna duda, visita [Google](https://www.google.com)")
st.markdown("Si *tienes* alguna **duda**, visita [Google](https://www.google.com)")
col1, _, col2 = st.columns([2, 0.5, 2])
with col1:
number = st.slider("Enter a number", min_value=2, max_value=50)
if st.button("Check if prime"):
if is_prime(number):
st.info(f"{number} is a prime number")
else:
st.error(f"{number} is not a prime number")
text = st.text_input("Enter your name")
st.info(f"Your name in uppercase is: {text.upper()}")
option = st.radio("Select a colour", ("Red", "Green", "Blue"))
if option == "Red":
st.success("You selected Red")
elif option == "Green":
st.warning("You selected Green")
else:
st.error("You selected Blue")
is_cool = st.checkbox("Are you cool?")
if is_cool:
st.success("You are cool")
else:
st.error("You are not cool")
country = st.selectbox("Select a country", ("USA", "Canada", "Mexico"))
novel = st.file_uploader("Upload your novel", type=["txt", "pdf", "docx"])
if novel:
# count words of txt file
if novel.type == "text/plain":
text = novel.read().decode("utf-8")
word_count = len(text.split())
st.text(f"Word count: {word_count}")
image = st.camera_input("Take a picture")
if image:
size_mb = len(image.getvalue()) / (1024 * 1024)
st.text(f"File size: {size_mb:.2f} MB")
st.download_button("Download your picture", image, file_name="image.png", mime="image/png")
# with col2:
# insert image of a cool image
# st.image("https://images.unsplash.com/photo-1506748686214-e9df14d4d9d0?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwzNjUyOXwwfDF8c2VhcmNofDJ8fGltYWdlJTIwc3RyZWFtJTIwY29vbHxlbnwwfHx8fDE2OTI5NTQ1NzE&ixlib=rb-4.0.3&q=80&w=1080", caption="Cool Image")
st.header("Data Analysys")
# df = sns.load_dataset("penguins")
#
# st.dataframe(df.head())
import streamlit as st
if "messages" not in st.session_state:
st.session_state.messages = []
for msg in st.session_state.messages:
with st.chat_message("user"):
st.write(msg)
with st.chat_message("assistant", avatar="🤖"):
st.write(msg.upper())
user_input = st.chat_input("Say something")
if user_input:
st.session_state.messages.append(user_input)
st.rerun()
st.header("Money")
col1, _, col2 = st.columns([2, 0.5, 2])
with col1:
money = st.number_input("Cuánto dinero inicial", min_value=0, step=1)
tipo = st.radio("Tipo de interés", ("Fijo", "Variable"))
perc = st.slider("Porcentaje de interés", min_value=1, max_value=10, step=1)
n_years = st.number_input("Número de años", min_value=1, step=1)
if tipo == "Fijo":
money_final = money * (1 + perc / 100) ** n_years
elif tipo == "Variable":
money_final = money * (1 + perc / 100) ** n_years * (1 + 0.01) ** n_years
st.text(f"Money final: {money_final:.2f}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment