Weather App Project (Teacher's Choice)
There are several different mini-projects on this page. You can build them all, or your teacher may only ask you to work on one or two.
For each activity, you will scrape a weather website for data to build an algorithm for a weather app.
Building Current Temperature
and Current Weather
Reporters
Many websites provide current weather and forecast data. Some, such as Weather Underground, give location-specific information through the use of URL tags. Weather Underground can accept locations and ZIP codes.
Note that there is no space between city and state: Boston,MA. For cities with multiple words, add a plus: New+York,NY. These requirements are particular to this website, not general to the entire Web.
-
First read and then click these URLs:
- Follow the same pattern to create a URL that links to the weather for a different city.
Note that the degrees symbol (°) is written with an HTML character code: °
.
- Use your browser to view the source (HTML) for the resulting page. Where in the HTML is the current temperature shown? How could you most easily locate this specific line?
-
Remember not to include the "http://" in the
http
block input slot.
Starting from the U4L3-HttpBlock project, design a
block that accepts a ZIP code or a city and state as input and reports the current temperature in degrees Fahrenheit:
"U4L3-WeatherApp"
-
Build a similar block to give the current weather conditions for the location you specified.
Building A Multi-City Weather Report App
You can query wunderground.com for current temperature and weather conditions in a list of cities like this...
As part of this work you can choose to create "cleaner" entry of city names. To do this, you'll need to convert names like New York, NY to New+York,NY. Snap! blocks that convert words to lists, and lists to words, can make this possible.
It's ok if yours doesn't look like this.
...to produce a report like this:
- Use the methods you used in the shopping list app to build an
Add Location
command that lets the user populate the list of locations.
- Then use your
current temperature
and current weather
reporters to build a weather report table (a list of lists) for multiple cities.
-
First plan the design; if there were only one city in the list, how would you produce this list as the report?
- Use list operations to produce the weather report table for all cities entered.
- Then test it by adding more cities and requesting the report again.
-
You could a weather reporter sprite:
- Modify the weather report so that it will also include the forecasted temperature and conditions for tomorrow.
Building an Umbrella?
Predicate
You can build an algorithm to tells you if you'll need an umbrella today.
- Build an
umbrella?
predicate that takes a location as input. You'll need to figure out what information should make the block report
.
- To make
know the user's location automatically, use an IP address
reporter.
- Change the
to a reporter that can return a wider variety of information, including outputs such as tonight, tomorrow, it's complicated, and wear boots instead.
- Build a
reporter that returns the sunset time at a given location; if no location is provided, use the current location.