0% found this document useful (0 votes)
12 views25 pages

Weather App Project in Python API

The document outlines two Python projects: a Weather App that fetches real-time weather data using the OpenWeatherMap API, and a program to display the atomic masses of the first 30 elements in the periodic table. The Weather App project includes system requirements, implementation details, and future enhancements, while the atomic mass project focuses on user input for retrieving element data from a dictionary. Both projects aim to enhance programming skills and understanding of APIs and data structures.

Uploaded by

mansipr008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views25 pages

Weather App Project in Python API

The document outlines two Python projects: a Weather App that fetches real-time weather data using the OpenWeatherMap API, and a program to display the atomic masses of the first 30 elements in the periodic table. The Weather App project includes system requirements, implementation details, and future enhancements, while the atomic mass project focuses on user input for retrieving element data from a dictionary. Both projects aim to enhance programming skills and understanding of APIs and data structures.

Uploaded by

mansipr008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

KENDRIYA VIDYALAYA,

DHRANGADHRA
CLASS: 11TH A
PROJECT FILE
SESSION 2024-25
TOPIC: WEATHER APP USING API
(PYTHON)

---------
CONTENT---------
1. Certificate
2. Acknowledgement
3. Introduction
4. System Requirements
5. Project Design and
Implementation
6. Output Screenshots
7. Future Enhancements
8. Conclusion
9. References

---------
CERTIFICATE----------
This is to certify that Mansi Raval of
class: XI A of PM SHRI KENDRIYA
VIDYALAYA DHRANGADHRA has done
her project on WEATHER APP USING
API under my supervision. She has taken
interest and has shown at most sincerity
in completion of this project. I certify
this project up to my expectation & as
per guidelines issued by CBSE.

-------
ACKNOWLEDGEMENT------
It is with pleasure that I acknowledge
my sincere gratitude to our teacher, Dr.
P. MANGAL Sir who taught and
undertook the responsibility of teaching
the subject computer science. I have
been greatly benefited from his classes. I
am especially indebted to our Principal
MR. OM PRAKASH Sir who has always
been a source of encouragement and
support and without whose inspiration
this project would not have been a
successful I would like to place on
record heartfelt thanks to him. Finally, I
would like to express my sincere
appreciation for all the other students
for my batch their friendship & the fine
time that we all shared together.
----------INTRODUCTION---------
1.1 Overview
A Weather App is a software application that
fetches real-time weather data using an API
(Application Programming Interface) and
displays essential information like temperature,
humidity, and weather conditions. This project
uses Python and OpenWeatherMap API to
provide weather updates for any city user enters.

1.2 Objective
 To develop a Python-based Weather App
that fetches real-time weather data.
 To understand how APIs work and how to
retrieve JSON data from a web service.
 To display temperature, humidity, wind
speed, and weather conditions based on user
input.
 To enhance problem-solving and
programming skills in Python.
System Requirements
2.1 Hardware Requirements
 Processor: Intel Core i3 or higher
 RAM: 4GB or more
 Storage: 500MB free space
 Internet Connection: Required for API calls
2.2 Software Requirements
 Python (version 3.x)
 OpenWeatherMap API Key (free sign-up
required)
 Required Python Libraries: requests,
JSON
To install the requests library, use the
command:
pip install requests
Project Design and
Implementation
3.1 Working Principle
The project works by:
1. Taking city name input from the user.
2. Sending a request to OpenWeatherMap
API.
3. Retrieving weather data in JSON
format.
4. Extracting relevant information such as
temperature, weather condition, humidity,
and wind speed.
5. Displaying the extracted data in the
console.
3.2 Project Flowchart
User Inputs City Name → API Request Sent →
JSON Data Received → Data Processed →
Output Displayed.
3.3 Code Implementation[SOURCE CODE]
The following is the Python code for the
Weather App:
import requests

def get_weather(city):
API_KEY = "your_api_key_here" #
Replace with your OpenWeatherMap API
key
URL =
f"[Link]
5/weather?
q={city}&appid={API_KEY}&units=metric"

try:
response = [Link](URL)
data = [Link]()

if data["cod"] != 200:
print("City not found.
Please enter a valid city name.")
return

temp = data["main"]["temp"]
weather = data["weather"][0]
["description"]
humidity = data["main"]
["humidity"]
wind_speed = data["wind"]
["speed"]

print(f"\nWeather in {city}:")
print(f"Temperature: {temp}\
u00B0C")
print(f"Condition: {weather}")
print(f"Humidity: {humidity}%")
print(f"Wind Speed:
{wind_speed} m/s")
except Exception as e:
print(f"Error fetching weather
data: {e}")

# User input
city_name = input("Enter city name: ")
get_weather(city_name)

Output Screenshots
Example Output:

Enter city name: London

Weather in London:
Temperature: 15°C
Condition: clear sky
Humidity: 60%
Wind Speed: 4.1 m/s

Future Enhancements
 Graphical User Interface (GUI) using
Tkinter or PyQt.
 5-day weather forecast feature.
 Save weather reports in a text file or CSV
format.
 Voice command integration for hands-free
usage.
Conclusion
This project successfully demonstrates
how to integrate APIs in Python to fetch
and display real-time weather data. It
provides a great learning experience for
understanding API requests, JSON
handling, and basic data parsing in
Python. The Weather App can be further
expanded with graphical enhancements
and additional functionalities for a more
interactive user experience.

References
 OpenWeatherMap API:
[Link]
 Python Documentation:
[Link]
 Requests Library: [Link]
[Link]/

Topic2- Finding atomic mass of


first 30 elements
---------CONTENT---------
1. INTRODUCTION
2. APPROACH
3. SCOPE
4. TOOLS AND TECHNOLOGIES USED
5. EXAMPLE OF DATA STRUCTURE
6. PROJECT OVERVIEW
7. ALGORITHM AND METHODOLOGY
8. CODE IMPLEMENTATION
9. HOW IT WORKS
10. CONCLUSION
11. FUTURE IMPROVEMENTS
12. REFERENCES
Introduction:
In this project, we will create a program to
display the atomic masses of the first 30
elements in the periodic table. Each element
has a unique atomic number and mass,
which are essential for understanding its
properties and behavior. The atomic mass is
crucial in fields such as chemistry and
physics, helping us understand molecular
composition and reactions.
Approach:
1. Data Structure: We'll store the atomic
masses of the first 30 elements in a Python
dictionary. Each element's atomic number
will be the key, and the corresponding
atomic mass will be the value.
2. Input and Output: The user can input
an element’s atomic number (from 1 to 30),
and the program will output the name of the
element along with its atomic mass.
3. Atomic Masses: The atomic masses for
the first 30 elements can be found from a
reliable source like the periodic table.
Scope
The project will:
 Include only the first 30 elements of the periodic
table.
 Provide the atomic mass for each element.
 Allow the user to input an atomic number and
receive the corresponding element's name and
atomic mass.

 Tools and Technologies Used


 Programming Language: Python
 Data Structure: Dictionary (for storing
element names and atomic masses)
 Development Environment: Any
Python IDE (PyCharm, VSCode, etc.)
Example of Data Structure:
elements = {
1: {"name": "Hydrogen", "atomic_mass": 1.008},
2: {"name": "Helium", "atomic_mass": 4.0026},
3: {"name": "Lithium", "atomic_mass": 6.94},
# ... continue for other elements
}

This approach allows users to query the atomic mass of


any of the first 30 elements easily.

Project Overview
This project allows users to find the atomic
mass of elements by entering the element name
or atomic number. The data is stored in a Python
dictionary.

Algorithm / Methodology
Step 1: Store Data in a Dictionary
To manage and retrieve the atomic mass of elements
efficiently, a dictionary is chosen as the data structure.
The dictionary will store the atomic number as the key
and the element's name and atomic mass as the values.
Example:

python
CopyEdit
elements = {
1: {"name": "Hydrogen",
"atomic_mass": 1.008},
2: {"name": "Helium",
"atomic_mass": 4.0026},
# Continue for elements up to
30
}
Step 2: User Input
The program will prompt the user to input the
atomic number of an element (from 1 to 30). The
input will be validated to ensure it falls within the
valid range.
Step 3: Display Results
Once a valid atomic number is entered, the program
will search for the corresponding element in the
dictionary and display its name and atomic mass.
Step 4: Error Handling
If the user enters an invalid atomic number (e.g., a
number outside the range 1-30), the program will
notify the user and prompt for valid input.

Code Implementation
# Dictionary storing the atomic masses of the first
30 elements
atomic_masses = {
1: ("Hydrogen", 1.008),
2: ("Helium", 4.0026),
3: ("Lithium", 6.94),
4: ("Beryllium", 9.0122),
5: ("Boron", 10.81),
6: ("Carbon", 12.011),
7: ("Nitrogen", 14.007),
8: ("Oxygen", 15.999),
9: ("Fluorine", 18.998),
10: ("Neon", 20.180),
11: ("Sodium", 22.990),
12: ("Magnesium", 24.305),
13: ("Aluminium", 26.982),
14: ("Silicon", 28.085),
15: ("Phosphorus", 30.974),
16: ("Sulfur", 32.06),
17: ("Chlorine", 35.45),
18: ("Argon", 39.948),
19: ("Potassium", 39.098),
20: ("Calcium", 40.078),
21: ("Scandium", 44.956),
22: ("Titanium", 47.867),
23: ("Vanadium", 50.942),
24: ("Chromium", 51.996),
25: ("Manganese", 54.938),
26: ("Iron", 55.845),
27: ("Cobalt", 58.933),
28: ("Nickel", 58.693),
29: ("Copper", 63.546),
30: ("Zinc", 65.38)
}

def get_atomic_mass(query):
# Check if the query is an integer
(atomic number)
if [Link]():
atomic_number = int(query)
if atomic_number in atomic_masses:
element, mass =
atomic_masses[atomic_number]
print(f"Element: {element},
Atomic Mass: {mass} u")
else:
print("Invalid atomic number!
Please enter a number between 1 and
30.")
else:
# Check if the query matches any
element name (case-insensitive)
for num, (element, mass) in
atomic_masses.items():
if [Link]() ==
[Link]():
print(f"Element: {element},
Atomic Mass: {mass} u")
return
print("Element not found! Please
enter a valid element name.")

# User Input
query = input("Enter atomic number or
element name: ")
get_atomic_mass(query)

How It Works
[Link] the atomic masses of the first 30 elements
in a dictionary.
[Link] user inputs either the atomic number or
element name.
[Link] the atomic mass and display it.
[Link] the input is invalid, it prompts the user with an
error message.

Conclusion
This Python project successfully provides a
simple tool to find the atomic mass of the first
30 elements of the periodic table. The program
is user-friendly, efficient, and easy to use,
making it a helpful tool for students and
professionals in the fields of chemistry and
science.

Future Improvements
 Extend the program to handle all 118
elements of the periodic table.
 Add more features such as displaying the
element's symbol, atomic number, and
classification (metal, non-metal, etc.).
 Create a graphical user interface (GUI) to
improve the user experience.

References
 Data sourced from periodic table references
and trusted scientific websites for the atomic
masses of elements.
THANK YOU!!!

You might also like