-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
84 changed files
with
1,011 additions
and
1,753 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"yaml.schemas": { | ||
"https://json.schemastore.org/github-issue-config.json": "/*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import os | ||
import sys | ||
import requests | ||
from dotenv import load_dotenv | ||
load_dotenv() | ||
import datetime | ||
|
||
api_key = os.getenv('OPENWEATHER_API_KEY') | ||
|
||
def get_weather(city): | ||
url = f'http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric' | ||
|
||
response = requests.get(url) | ||
if response.status_code == 200: | ||
data = response.json() | ||
weather = { | ||
'city': data['name'], | ||
'description': data['weather'][0]['description'], | ||
'temperature_min': data['main']['temp_min'], | ||
'temperature_max': data['main']['temp_max'], | ||
'humidity': data['main']['humidity'], | ||
'wind_speed': data['wind']['speed'], | ||
} | ||
return weather | ||
else: | ||
return None | ||
|
||
def get_city(): | ||
|
||
|
||
city = input('Enter city name: ') | ||
weather = get_weather(city) | ||
|
||
|
||
if weather: | ||
print(f"Current weather in {weather['city']}:") | ||
print(f"Description: {weather['description']}") | ||
print(f"Temperature [min]: {weather['temperature_min']} °C") | ||
print(f"Temperature [max]: {weather['temperature_max']} °C") | ||
print(f"Humidity: {weather['humidity']}%") | ||
print(f"Wind speed: {weather['wind_speed']} m/s") | ||
else: | ||
print(f"Could not retrieve weather information for {city}") | ||
|
||
def main(): | ||
os.system('cls' if os.name == 'nt' else 'clear') | ||
# today = datetime.date.today() | ||
date = datetime.datetime.now() | ||
today = "{:%m/%d/%Y %H:%M:%S}".format(date) | ||
|
||
app_name = 'Weather Forecast' | ||
border_length = max(len(app_name), len(today)) + 9 | ||
print("+" + "-" * (border_length - 2) + "+") | ||
print(f" {app_name}") | ||
print(f"{today}") | ||
print("+" + "-" * (border_length - 2) + "+") | ||
get_city() | ||
|
||
|
||
while True: | ||
response = input('\nCheck another city? (Y/N): ') | ||
if response == 'y' or response == 'Y': | ||
main() | ||
elif response == 'n' or response == 'N': | ||
print('\nThank you and have a great day.\n') | ||
sys.exit() | ||
else: | ||
print('\nError: Please select y or n.\n') | ||
continue | ||
|
||
if __name__ == '__main__': | ||
main() |
55 changes: 55 additions & 0 deletions
55
examples/python-starters/10-roman-numerals-converter/main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import os | ||
import sys | ||
|
||
|
||
def dec_to_roman(dec): | ||
roman_numerals = [ | ||
(1000, 'M'), | ||
(900, 'CM'), | ||
(500, 'D'), | ||
(400, 'CD'), | ||
(100, 'C'), | ||
(90, 'XC'), | ||
(50, 'L'), | ||
(40, 'XL'), | ||
(10, 'X'), | ||
(9, 'IX'), | ||
(5, 'V'), | ||
(4, 'IV'), | ||
(1, 'I') | ||
] | ||
|
||
roman = "" | ||
for value, numeral in roman_numerals: | ||
while dec >= value: | ||
roman += numeral | ||
dec -= value | ||
|
||
return roman | ||
|
||
def main(): | ||
os.system('cls' if os.name == 'nt' else 'clear') | ||
app_name = 'Decimal to Roman Numerals' | ||
border_length = len(app_name) + 4 | ||
print("+" + "-" * (border_length - 2) + "+") | ||
print(f" {app_name} ") | ||
print("+" + "-" * (border_length - 2) + "+") | ||
print() | ||
|
||
decimal_num = int(input("Enter number in decimal: ")) | ||
roman_number = dec_to_roman(decimal_num) | ||
print(f"Decimal number {decimal_num} is {roman_number} in numerals.") | ||
|
||
while True: | ||
response = input('\nDo you want to continue? (Y/N) ') | ||
if response.lower() == 'y': | ||
main() | ||
elif response.lower() == 'n': | ||
print('\nThank you and have a great day.\n') | ||
sys.exit() | ||
else: | ||
print('\nError: Please select Y or N.\n') | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
openai | ||
python-dotenv | ||
qrcode | ||
requests | ||
yt-dlp | ||
Flask | ||
python-dotenv | ||
-r requirements/development.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
python-dotenv | ||
qrcode | ||
requests | ||
yt-dlp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Advanced formatting | ||
|
||
## Alerts/Admonitions | ||
|
||
> [!NOTE] | ||
> Highlights information that users should take into account, even when skimming. | ||
> [!TIP] | ||
> Optional information to help a user be more successful. | ||
> [!IMPORTANT] | ||
> Crucial information necessary for users to succeed. | ||
> [!WARNING] | ||
> Critical content demanding immediate user attention due to potential risks. | ||
> [!CAUTION] | ||
> Negative potential consequences of an action. | ||
## Code Blocks | ||
|
||
```sh | ||
py -c 'import this' | ||
``` | ||
|
||
```sh | ||
git add --all | ||
git commit -m "initial commit" | ||
``` | ||
|
||
```sh | ||
git add --all && git commit -m "initial commit" | ||
``` | ||
|
||
## Collapsed Section | ||
|
||
### Default | ||
|
||
<details> | ||
<summary>Click to Expand</summary> | ||
|
||
The quick brown fox jumps over the lazy dog. | ||
|
||
_The quick brown fox jumps over the lazy dog._ | ||
|
||
1. Step one | ||
|
||
Do this | ||
|
||
2. Step two | ||
|
||
Not That | ||
|
||
3. Final | ||
|
||
```sh | ||
py -m pip install --upgrade pip | ||
``` | ||
|
||
Thank you! | ||
|
||
</details> | ||
|
||
### Open | ||
|
||
<details open> | ||
<summary>Click to collapse</summary> | ||
|
||
The quick brown fox jumps over the lazy dog. | ||
|
||
_The quick brown fox jumps over the lazy dog._ | ||
|
||
1. Step one | ||
|
||
Do this | ||
|
||
2. Step two | ||
|
||
Not That | ||
|
||
3. Final | ||
|
||
```sh | ||
py -m pip install --upgrade pip | ||
``` | ||
</details> | ||
|
||
## Want more? | ||
|
||
Check out this [website](https://mkeithx.github.io/). |
Oops, something went wrong.