Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import plotly.express as px
- import pandas as pd
- # Collect user inputs
- countries = []
- values = []
- print("Enter country names and values (1–100). Type 'done' when finished.\n")
- while True:
- country = input("Enter country name (or 'done'): ").strip()
- if country.lower() == 'done':
- break
- try:
- value = float(input(f"Enter value for {country} (1–100): ").strip())
- if 1 <= value <= 100:
- countries.append(country)
- values.append(value)
- else:
- print("Value must be between 1 and 100.")
- except ValueError:
- print("Please enter a valid number.")
- # Create DataFrame
- data = pd.DataFrame({
- 'Country': countries,
- 'Values': values
- })
- # Plot
- fig = px.choropleth(
- data,
- locations='Country',
- locationmode='country names',
- color='Values',
- color_continuous_scale='Inferno',
- title='how hot was it today'
- )
- fig.show()
Advertisement
Add Comment
Please, Sign In to add comment