create an app that tracks the live price of selected cryptocurrencies using an API like CoinGecko.
To upload files, please first save the app
import streamlit as st
import requests
import pandas as pd
st.title("Crypto Price Tracker")
# Get selected cryptocurrencies
crypto_list = ["bitcoin", "ethereum", "ripple", "litecoin"]
selected_crypto = st.selectbox("Select a cryptocurrency:", crypto_list)
# Fetch price data from CoinGecko API
url = f"https://api.coingecko.com/api/v3/simple/price?ids={selected_crypto}&vs_currencies=usd"
response = requests.get(url)
price_data = response.json()
if selected_crypto in price_data:
price = price_data[selected_crypto]["usd"]
st.write(f"Current price of {selected_crypto.capitalize()}: $ {price}")
else:
st.write(f"Could not retrieve data for {selected_crypto}. Please try again.")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?