第一步,成为百万富翁 - 汇率习题【难度:2级】:

答案1:

import requests apiUrl = "http://api.fixer.io/"def getExchangeRates(baseRate="EUR", date="latest"):url = "{}{}?base={}".format(apiUrl, date, baseRate)headers = {'content-type': 'application/json'}return requests.get(url, headers=headers).json()​

答案2:

from requests import getapiUrl = "http://api.fixer.io/"def getExchangeRates(baseRate="EUR", date="latest"):reqUrl = apiUrl + '%s?base=%s' % (date, baseRate)response = get(reqUrl)return response.json()​

答案3:

import json
import requestsapiUrl = "http://api.fixer.io/"def getExchangeRates(baseRate="EUR", date="latest"):parameters = {"base" : baseRate}parsed = requests.get(apiUrl + date, parameters).json()return parsed​

答案4:

import requests
def getExchangeRates(baseRate='EUR', date='latest'):return requests.get('http://api.fixer.io/'+date+('?base='+baseRate if baseRate else '')).json()​

答案5:

import requests
apiUrl = "http://api.fixer.io/"def getExchangeRates(baseRate="EUR", date="latest"):req=requests.get('https://api.fixer.io/'+date+'?base='+baseRate)return req.json()​

答案6:

import requestsdef getExchangeRates(baseRate='EUR', date='latest'):# baseRate camcelcase naming convention forced by kata authorurl = 'http://api.fixer.io/' + dateparams = {'base': baseRate}r = requests.get(url, params=params)return r.json()
​

答案7:

apiUrl = "http://api.fixer.io/{}?base={}"import json
import requestsdef getExchangeRates(baseRate="EUR", date="latest"):s  = requests.get(apiUrl.format(date, baseRate)).json()return s  ​

答案8:

from requests import get
from json import loadsapiUrl = "http://api.fixer.io/"def getExchangeRates(baseRate="EUR", date="latest"):return loads(get("{}{}?base={}".format(apiUrl, date, baseRate)).text)​

答案9:

import requestsapiUrl = "http://api.fixer.io/"def getExchangeRates(baseRate="EUR", date="latest"):url = '{}{}?base={}'.format(apiUrl, date, baseRate)return requests.get(url).json()​

答案10:

import requestsdef getExchangeRates(baseRate="EUR", date="latest"):apiUrl = "http://api.fixer.io/"apiUrl += date + "?" ;apiUrl += "base=" + baseRate ; response = requests.get(apiUrl) ; if response.ok:return response.json() ; return None ; ​

景越Python基础训练营QQ群 ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190919153035264.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2F1bXRvcHNhbGU=,size_16,color_FFFFFF,t_70) 欢迎各位同学加群讨论,一起学习,共同成长!

Python练习题答案: 第一步,成为百万富翁 - 汇率卡塔【难度:2级】--景越Python编程实例训练营,1000道上机题等你来挑战相关推荐

  1. Python练习题答案: 馏分类【难度:2级】--景越Python编程实例训练营,1000道上机题等你来挑战

    馏分类[难度:2级]: 答案1: # Something goes Here ...class Fraction:def __init__(self, numerator, denominator): ...

  2. Python练习题答案: IRR计算 - 盈利能力的评价【难度:2级】--景越Python编程实例训练营,1000道上机题等你来挑战

    IRR计算 - 盈利能力的评价[难度:2级]: 答案1: def irr(c):precision, guess, v, lastPositiveGuess, lastNegativeGuess = ...

  3. Python练习题答案: 杰克的家【难度:2级】--景越Python编程实例训练营,1000道上机题等你来挑战

    杰克的家[难度:2级]: 答案1: VERSES = """\ This is the house that Jack built.This is the malt th ...

  4. Python练习题答案: 分类新会员【难度:1级】--景越Python编程实例训练营,1000道上机题等你来挑战

    分类新会员[难度:1级]: 答案1: def openOrSenior(data):return ["Senior" if age >= 55 and handicap &g ...

  5. Python练习题答案: CIS 122#12中的构造【难度:1级】--景越Python编程实例训练营,1000道上机题等你来挑战

    CIS 122#12中的构造[难度:1级]: 答案1: # For your convenience, the following functions from previous challenges ...

  6. Python练习题答案: 转换货币II【难度:2级】--景越Python编程实例训练营,1000道上机题等你来挑战

    转换货币II[难度:2级]: 答案1: def solution(to,lst):dolSym, eurSym, power = ('', '€', -1) if to=='EUR' else ('$ ...

  7. Python练习题答案: 海盗!是大炮准备好了!?【难度:0级】--景越Python编程实例训练营,1000道上机题等你来挑战

    海盗!是大炮准备好了!?[难度:0级]: 答案1: def cannons_ready(gunners):return 'Shiver me timbers!' if 'nay' in gunners ...

  8. Python练习题答案: 摩门经【难度:2级】--景越Python编程实例训练营,1000道上机题等你来挑战

    摩门经[难度:2级]: 答案1: from math import log, ceil def mormons(starting_number, reach, target):return ceil( ...

  9. Python练习题答案: 财富通灵塔的乘驾【难度:3级】--景越Python编程实例训练营,1000道上机题等你来挑战

    财富通灵塔的乘驾[难度:3级]: 答案1: def ride_of_fortune(artifact, explorers):STATES = {'A': 'B', 'B': 'A'}DIRS = { ...

  10. Python练习题答案: 赛车#1:简化拖动赛【难度:1级】--景越Python编程实例训练营,1000道上机题等你来挑战

    赛车#1:简化拖动赛[难度:1级]: 答案1: def drag_race(length, anna, bob):a = length / anna.speed + anna.reaction_tim ...

最新文章

  1. 程序员论坛炫耀公司福利:一线互联网公司的下午茶,什么水平?
  2. Linux内核初始化阶段内存管理的几种阶段
  3. python传参是传值还是传引用
  4. springframework报错_应对报错信息的必杀技!
  5. android java.net.ConnectException: Connection 127.0.0.1:8080 refused
  6. Galera集群server.cnf参数调整--前言
  7. 让Fiddler调试localhost和127.0.0.1
  8. 河南理工大学计算机软件考研857数据结构
  9. Java实现斯皮尔曼相关系数(Spearman)及T检验
  10. 燕秀计算机打印区域文字高度,燕秀快捷键(全)
  11. 前端开发和后端开发究竟有什么区别?详细介绍
  12. Vagrant启动报错
  13. ZooKeeper原理和实践
  14. 首席技术官(ChiefTechnologyOfficer)
  15. spring cloud eureka 样式wro.css wro.js 404
  16. tiny4412开发板实现uboot引导启动android 5.0.2系统
  17. No SQL treatise
  18. 大数据入门(五)-分布式计算框架MapReduce
  19. 谷歌Android无障碍套件,android无障碍套件下载
  20. 痞子衡嵌入式:浅谈i.MXRT1xxx系列MCU时钟相关功能引脚的作用

热门文章

  1. 2019互联网行业程序员工资大数据报告
  2. hdu6070 Dirt Ratio(二分+线段树)
  3. 台式计算机diy,DIY组装台式电脑经验分享学习篇
  4. 英文书籍下载常用网站
  5. VB6+Mo图层顺序的调整(MoveToTop、MoveTo、MoveToBottom )
  6. 高薪岗位大数据开发工程师要如何入门?【重磅】
  7. 【Android工具】神器来了,游戏安装加速器ourplay,重点:附赠强大免费gmail邮箱注册...
  8. visio增加连接点
  9. 奶爸日记3 - 给鑫鑫做的第一顿饭
  10. windows mac谷歌浏览器跨域