top of page

Weather Forecast with wttr

We teach and learn by making – even with the weather!


At Haruki Robotics Lab, we love to mix fun with learning by doing. Today, we’re not building robots (well, not yet 😉) — instead, we’re grabbing the weather forecast using Python. The same way robots use sensors to “see” the world, we’ll use code to “see” the sky!


ree

Python Code

Here’s a tiny program that asks for your city, connects to the internet, and shows you today’s weather:

import requests

city = input("Enter a city name: ")
url = "https://www.wttr.in/" + city
info = requests.get(url)
print(info.text)
    

How it Works 🌍

  • Step 1: Ask the user which city they want.

  • Step 2: Connect to wttr.in, a free weather service.

  • Step 3: Print the forecast right in your terminal — clouds, sun, rain, and all!



Fun Ideas to Try

  • Ask for your parents’ hometown and see the weather there too!

  • Create a daily robot weatherman in Python that greets you each morning.

  • Extend this program to say, “Don’t forget your umbrella!” if it’s raining.

Comments


bottom of page