-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGroup 8 Python Console Application
More file actions
42 lines (34 loc) · 1.8 KB
/
Group 8 Python Console Application
File metadata and controls
42 lines (34 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Global Holiday Planner
from pip._vendor import requests
from pprint import pprint as pp
country = input("What country would you like to visit?: ")
endpoint1 = 'https://restcountries.com/v3.1/name/' + country + '?fullText=true'
print(endpoint1)
response = requests.get(endpoint1) # making a call to the api
print(response.status_code) # check to ensure the api call is successful
data = response.json()
#pp(data)
# display country information 'area', 'borders', 'capital' 'continents' 'currencies' 'flag' 'language' 'population' 'timezones'
for info in data:
area = info['area']
borders = info['borders']
capital = info['capital']
continents = info['continents']
currencies = info['currencies']
flag = info['flag']
language = info['languages']
population = info['population']
timezones = info['timezones']
print(f'Information about {country} \narea:{area} \nborders: {borders} \ncapital: {capital} \ncontinents: {continents} \ncurrencies: {currencies} \nflag: {flag} \nlanguages: {language} \npopulation: {population} \ntimezones: {timezones}')
budget = float(input("What is your budget in USD?: "))
from pip._vendor import requests
from pprint import pprint as pp
api_key = 'd6463bde9e2ea9ae97de9ad2'
endpoint1 = 'https://v6.exchangerate-api.com/v6/d6463bde9e2ea9ae97de9ad2/latest/USD'
response = requests.get(endpoint1) # making a call to the api
print(response.status_code) # check to ensure the api call is successful
data = response.json()
#pp(data)
currency = input("Enter the currency you want to use: ")
converted_budget = budget * data['conversion_rates'][currency]
print(f"You wish to visit {country} for holiday. Your budget is ${budget} which is {currency}{converted_budget} when converted to your desired currency. Enjoy your holidays.")