Weather Program
Create an application to interacts with a web service in order to obtain data.
Program must prompt the user for their city or zip code and request weather forecast data from OpenWeatherMap (https://openweathermap.org). Program must display the weather information in a READABLE format to the user.
Requirements:
Url: 'http://samples.openweathermap.org/data/2.5/weather?'+key+'&appid=b1b15e88fa797225412429c1c50c122a1'
This is can be found in the OpenWeather site, it's a demo URL.
the api key used is default provided by the site.
the key parameter contains the user zip code or city name as requested in the question.
import requests
import json
country_code = 'IN'
while True:
input1 = input('Enter zip code or City name: ')
if input1.isdigit():
key = f"zip={input1},{country_code}"
else:
key = f'q={input1},{country_code}'
request_url =
'http://samples.openweathermap.org/data/2.5/weather?'+key+'&appid=b1b15e88fa797225412429c1c50c122a1'
print(request_url)
print('requesting...')
request = requests.get(request_url)
if request.status_code == 200:
print('sucessfull received data')
#request.text contains data in json format
#using json.loads() that converts data to python dict.
data = json.loads(requet.text)
print('OUTPUT::')
print('name',data['name'])
print('temperature',data['main']['temp'],'in fahrenheit')
print('wind
speed',data['wind']['speed'],'deg',data['wind']['deg'])
print('pressure',data['main']['pressure'])
print('humidity',data['main']['humidity'])
print('cordinates',data['coord'])
print('clouds',data['clouds'])
print('weather',data['weather'][0]['main'])
print('weather
description::',data['weather'][0]['description'])
else:
print(request.status_code)
print(request.text)
output:
Enter zip code or City namemapusa http://samples.openweathermap.org/data/2.5/weather?q=mapusa,IN&appid=b1b15e88fa797225412429c1c50c122a1 requesting... sucessfull received data OUTPUT:: name London temperature 280.32 in fahrenheit wind speed 4.1 deg 80 pressure 1012 humidity 81 cordinates {'lon': -0.13, 'lat': 51.51} clouds {'all': 90} weather Drizzle weather description:: light intensity drizzle
Note: the loop will run infinitely and need to be stoped manually my the user
Weather Program Create an application to interacts with a web service in order to obtain data....
This assignemnt for Android development using Java Weather Forecaster App Goal: Create an app to display a weather forecast for the user’s current location Create the app titled Weather Forecaster The first screen will have a textbox for the user to enter a zip code and a button to submit When the user enters the zip code and clicks the button, the app will navigate to the weather forecast screen. The weather forecast screen will show the current weather for...
Using Microsoft Visual Studio C# In this lab assignment, you'll write code that parses an email address and formats the ci and zip code portion of an address. String Handling Email: [email protected] Parse City: Fresno State: ca Zp code: 93722 Format ให้ 2 Parsed String Formatted String User name: anne Domain name: murach.comm City, State, Zip: Fresno, CA 93722 OK OK Create a new Windows Forms Application named StringHandling and build the form as shown above. 1. Add code to...
Flowchart for Python program: Design and create a program for the ULM Coffee Shop to provide some customer market research data. When a customer places an order, a clerk asks for the customer’s zip code and age. The clerk enters that data as well as the number of items the customer orders. The program operates continuously until the clerk enters a 0 for zip code at the end of the day. When the clerk enters an invalid zip code (more...
Create a Python list (use first three letters of your name followed by the letter L as the name of the list.) with the following data: 10, 20.0, 50.00, 7000, 7500, 7700, 7800, 8000, 9000, ‘python’. Display the entire list with an appropriate message. Display the 4th element in the list with an appropriate message. Display the first 3 values of the list only. Display all the values starting from the sixth element to the end of the list. Change...
Java(Eclipse). The task will create a server and client and send a message from the client to the server. We will have two classes NetworkClient and NetworkServerListener classes. These will each have a main to run from the command line The NetworkServerListener class will listen for a client connection from NetworkClient , receive a message, display the message to the console (stdout) and exit. The NetworkClient class will create a connection to the NetworkServerListener and send a message to the...
Case Problem 11 - 1: Modify the GreenvilleRevenue program created in the previous chapter so that it performs the following tasks: The program prompts the user for the number of contestants in this year’s competition; the number must be between 0 and 30. Use exception-handling techniques to ensure a valid value and display the error message: Number must be between 0 and 30 The program prompts the user for talent codes. Use exception-handling techniques to ensure a valid code and...
Problem Statement You are to create a Visual Basic(VB) project for a census bureau to obtain and analyze household income survey data within the Pittsburgh area (including Morgantown Ky). Data Collected: Home identification code (4 alphanumeric characters) – required Program should generate it using a random number generator. You won’t use this anywhere it just need to be generated. Generate the first number in the Form Load event and then each subsequent number in the button click. See attached code...
create java application with the following specifications: -create an employee class with the following attibutes: name and salary -add constuctor with arguments to initialize the attributes to valid values -write corresponding get and set methods for the attributes -add a method in Employee called verify() that returns true/false and validates that the salary falls in range1,000.00-99,999.99 Add a test application class to allow the user to enter employee information and display output: -using input(either scanner or jOption), allow user to...
In this assessment, you will design and code a Java console application that validates the data entry of a course code (like IT4782) and report back if the course code is valid or not valid. The application uses the Java char and String data types to implement the validation. You can use either the Toolwire environment or your local Java development environment to complete this assignment. The requirements of this application are as follows: The application is to read a...
Write a Python program that uses a tuple. Create a tuple of your matric subjects. The program must display the first element, the last element, and the length of the tuple. An explanation message should also be included. E.g. The length of the tuple is 4. The user needs to be prompted for a subject, and the code needs to find the subject in the tuple. The user needs to be informed whether or not the subject is included in...