import random import streamlit as st # Define the list of jokes jokes = [ "Why couldn't the bicycle stand up by itself? Because it was two-tired.", "Why did the tomato turn red? Because it saw the salad dressing!", "Why did the chicken cross the playground? To get to the other slide!", "Why did the teddy bear say no to dessert? Because it was already stuffed!", "Why do seagulls fly over the sea? Because if they flew over the bay, they'd be bagels!", "Why did the scarecrow win an award? Because he was outstanding in his field!", "Why do elephants never use computers? Because they're afraid of mice!", "Why do bees have sticky hair? Because they use honeycombs!", "Why did the cookie go to the doctor? Because it was feeling crummy!", "Why did the hipster burn his tongue? Because he drank his coffee before it was cool!", "Why don't scientists trust atoms? Because they make up everything!", "Why don't zombies eat brains? Because they're on a no-brain diet!", "Why did the banana go to the doctor? Because it wasn't peeling well!", "Why did the tomato turn green? Because it saw the salad dressing!", "Why did the chicken go to the seance? To talk to the other side!", "Why did the teddy bear say no to candy? Because it was trying to be a little bit bear-y!", "Why don't sharks live in the jungle? Because they can't climb trees!", "Why did the scarecrow go to the gym? To work on his straw-nth!", "Why did the computer go to the doctor? Because it had a virus!", "Why did the pencil go to the doctor? Because it had a broken lead!" ] # Define the UI elements st.title("No Pun Intended Joke Application") if st.button("Tell Me a Joke!"): # Randomly select a joke joke = random.choice(jokes) st.write(joke) # Define the file IO elements st.header("File IO for Jokes") # Load the jokes from a text file with st.expander("Load Jokes"): uploaded_file = st.file_uploader("Choose a file", key="load") if uploaded_file is not None: jokes = uploaded_file.read().decode().split("\n") st.success("Loaded {} jokes from the file!".format(len(jokes))) # Save the jokes to a text file with st.expander("Save Jokes"): uploaded_file = st.file_uploader("Choose a file", key="save") if uploaded_file is not None: uploaded_file.write("\n".join(jokes)) st.success("Saved {} jokes to the file!".format(len(jokes))) markdown = """ # ðŸ“Ģ Press Release: "No Pun Intended" Joke App on HuggingFace! 🎉 We're excited to announce the launch of our new program, the "No Pun Intended" Jokes to make you laugh! 🎉 ðŸĪŠ Are you tired of boring jokes that make you yawn? Do you want to laugh until your tummy hurts? Look no further than "No Pun Intended" Joke App for All! ðŸĪĢ 😎 With 20 hilarious jokes to choose from, you'll never run out of funny puns to tell your friends and family. Whether you're in the classroom, on the playground, or at home, our joke app is the perfect way to brighten up your day. 😃 📚 And the best part? You can even add your own jokes to the joke book! Use the file IO elements to load and save jokes to the program. 📝 ðŸ‘Ķ👧 So what are you waiting for? Bookmark and like the "No Pun Intended" Joke App today and start laughing out loud! 😂 """ st.markdown(markdown)