r/PythonLearning
•
u/ProgramBrave718
•
Sep 26 '26
•
1
Showcase Made my first cool project!!!
I made a program that calculates exact sunrise and sunset based on latitude and longitude of a specific location.
Here I used this api
I can't get a geocoding api to translate location's name into coordinates.
I had to create a dictionary of a few locations.
9
u/ConclusionForeign856 Sep 26 '26
I'd use dataclasses to represent those locations. I think it's better at showing your intent and also less error prone (you can add fields to city sub-dicts, while you can't for dataclasses. But you still can change values in fields defined in your dataclasses.
I think the best would be NamedTuple from typing β defined field with type hints and immutable so you won't silently overwrite city coordinates.

I think it's typical for python programmers to overuse simple builtin data structures to build their programs. In C/C++/Rust you'd define a struct for those, NamedTuple kind of mirrors that approach
1
2
3
u/tcav24 Sep 26 '26
Nice work. If you want to keep iterating on the project you could also look into how you can show your cities as a list of selectable of options in the terminal. It would give the user more clarity on what cities they can choose from. (There are 3rd party libaries like 'Pick' and 'InquirerPy')
1
3
2
u/GreatGameMate Sep 26 '26
Looks nice, is there an interface that the user interacts with or is it all within the console ? Good work!
My little nitpick would be the emojis, but that is all personal opinion.
Code looks cleans.
2
1
u/Binary9363 Sep 30 '26
I have been wanted to start learning python where do ya recomend i could start ?
1
u/ProgramBrave718 Sep 30 '26
I guess brocode is good. Like he explains easily. You can watch his playlist on YouTube
1
1
u/togfast_456 Oct 14 '26
Bro it is fire for first . Ifirst time (13 years old) Even that can do
1
u/ProgramBrave718 Oct 15 '26
Well, I am a bit older than you. I am 15
1
u/Terminay 21d ago
ooh me tu!
1
u/ProgramBrave718 21d ago
Really
1
2
u/gofl-zimbard-37 Sep 26 '26
Nice. Now give it a proper main() to make it a real program. Never write code that runs outside of functions, such that you have to read the entire thing to know what it does.
1
u/Terminay 21d ago
looks like bros learning fast! keep at it and start getting this stuff online with some ui βοΈ
1
1
u/theJacofalltrades Oct 09 '26
That feeling when you finally build something that actually works is hard to beat. Tutorials are great, but getting all the pieces to work together on your own is a different kind of satisfaction. What part of the project gave you the most trouble?
-2
u/TreatZealousideal770 Sep 26 '26
Must be nice living in a magical world where APIs have 100% uptime, networks never lag, and KeyError doesn't exist. Back here on Earth, one HTTP 429 error will send your first 'cool project' straight to the shadow realm
1
u/ProgramBrave718 Sep 26 '26 edited Sep 26 '26
Sir, , actually i am still learning.I agree there are no timeouts and the api cannot work sometimes and please can u read my code carefully because there is Exception handling for city which is not found for. Please check code carefully before making a fake error
2
u/SchemeWestern3388 Sep 27 '26
I have no clue what that individual is so cynical about, ignore them.Β
Pretty decent first project. Keep at it!
1
u/SchemeWestern3388 Sep 27 '26
You sound like someone to avoid at a party.Β
I also get a strong feeling that you donβt have any achievements that anyone would be impressed by.Β
0


β’
u/Sea-Ad7805 Sep 26 '26
Run this program by clicking Memory Graph Web Debugger and see its state change step by step.