Beispiel #1
0
 def currencies(self, request, alpha_2):
     """
     Send timezones for a specific country
     """
     try:
         c = CountryInfo(alpha_2)
         return Response(c.currencies(), content_type="application/json")
     except KeyError:
         return Response(_("Unknown country or no info for this country"),
                         status=HTTP_404_NOT_FOUND)
def user_geo(country_name="me"):
    if country_name == "me":
        code = geocoder.ip(country_name).country
        country = CountryInfo(code)
    else:
        country = CountryInfo(country_name)
        code = country.iso(2)
    capital = country.capital()
    name = country.name().capitalize()
    currency = country.currencies()
    return [code, name, capital, currency]
Beispiel #3
0
 def currencies(self, *args, **kwargs) -> []:
     """
     Return a list of currencies used in this country
     """
     from djangophysics.currencies.models import Currency
     from djangophysics.currencies.models import CurrencyNotFoundError
     ci = CountryInfo(self.alpha_2)
     currencies = []
     for currency in ci.currencies():
         try:
             currencies.append(Currency(code=currency))
         except CurrencyNotFoundError:
             pass
     return currencies
Beispiel #4
0
def capital():
    i = 1
    while i > 0:
        a = input("Enter country name: ")
        if (a == "bye"):
            break
        else:
            s = a
            country = CountryInfo(s)
            print(country.capital())
            #it prints the capital of country
            print(country.currencies())
            #it prints currency of country
        i = i + 1
def country_info(country_name):
    d = []
    country = CountryInfo(country_name)
    d.append(["name", country.name().capitalize()])
    d.append(["capital", country.capital().capitalize()])
    d.append(["region", country.region().capitalize()])
    d.append(["currency", country.currencies()])
    d.append(["area", country.area()])
    d.append(["population", country.population()])
    d.append(["languages", country.languages()])
    d.append(["borders", country.borders()])
    d.append(["calling code", country.calling_codes()])
    d.append(["lat/long", country.capital_latlng()])
    d.append(["code", country.iso(2)])
    return d
Beispiel #6
0
 def currencies(self) -> []:
     """
     Return a list of currencies used in this country
     """
     ci = CountryInfo(self.alpha_2)
     return ci.currencies()
Beispiel #7
0
    if category == "subregion":
        subregion_pool = subregions
        subregion_pool = [
            y for y in subregion_pool if y != country.subregion()
        ]
        subregion_pool = rand.sample(subregion_pool,
                                     options[category_index] - 1)
        subregion_pool.append(country.subregion())
        rand.shuffle(subregion_pool)
        index = subregion_pool.index(country.subregion())

    elif category == "currency":
        currencies_pool = currencies
        currencies_pool = [
            y for y in currencies_pool if y != country.currencies()[0]
        ]
        currencies_pool = rand.sample(currencies_pool,
                                      options[category_index] - 1)
        currencies_pool.append(country.currencies()[0])
        rand.shuffle(currencies_pool)
        index = currencies_pool.index(country.currencies()[0])

    else:
        index = country_pool.index(countries_question[i])

    answer = choices[index]

    for x in range(options[category_index]):
        country_choice = CountryInfo(country_pool[x])
def get_currencies_by_country(country):
    country = CountryInfo(country)
    return country.currencies()
Author: Ayushi Rawat
'''

#import the necessary module!
from countryinfo import CountryInfo

name = 'India'
country = CountryInfo(name)

data1 = country.alt_spellings()
print(data1)

data2 = country.capital()
print(data2)

data3 = country.currencies()
print(data3)

data4 = country.languages()
print(data4)

data5 = country.timezones()
print(data5)

data6 = country.area()
print(data6)

data7 = country.borders()
print(data7)

data8 = country.calling_codes()
Beispiel #10
0
 def currencies(self):
     ci = CountryInfo(self.alpha_2)
     return ci.currencies()
Beispiel #11
0
print('Welcome, You can get information about any country here!')
user = input('\nEnter the name of a country:\n')
name = user

country = CountryInfo(name)

country_name = country.alt_spellings()
print('\nName:')
for name in country_name:
    print(name, end=', ')

country_capital = country.capital()
print(f'\n\nCapital:\n{country_capital}')

country_currency = country.currencies()
print('\nCurrency:')
for currency in country_currency:
    print(currency, end=', ')

country_lang = country.languages()
print('\n\nLanguages:')
for languages in country_lang:
    print(languages, end=', ')

country_timezone = country.timezones()
print('\n\nTime-Zone:')
for timezones in country_timezone:
    print(timezones, end=', ')

country_area = country.area()