kaggle learn python
def has_lucky_number(nums):
return any([num % 7 == 0 for num in nums])
def menu_is_boring(meals):
"""Given a list of meals served over some period of time, return True if the
same meal has ever been served two days in a row, and False otherwise.
"""
for meal in meals:
next = meals.index(meal)+1
try:
if meal == meals[next] :
return True
except:
return False
# else:
# return False
meals=['Spam', 'Eggs', 'Bacon', 'Spam']
menu_is_boring(meals)
为什么不能返回数据啊!!!
竟然用len(meals)-1来解决了。。。。
str = "123abcrunoob321"
print (str.strip( '' ))
result:
3abcrunoob3
以上下例演示了只要头尾包含有指定字符序列中的字符就删除
map(lambda x:x.strip(',.'),doc.lower().split())
dic 没有append 方法
# 2 decimal points 3 decimal points, format as percent separate with commas
"{} weighs about {:.2} kilograms ({:.3%} of Earth's mass). It is home to {:,} Plutonians.".format(
planet, pluto_mass, pluto_mass / earth_mass, population,
)
result:
"Pluto weighs about 1.3e+22 kilograms (0.218% of Earth's mass). It is home to 52,910,390 Plutonians."
['K']
[10 if x in'KQJ' else x for x in hand_1]
kaggle learn python的更多相关文章
- 笨办法学 Python (Learn Python The Hard Way)
最近在看:笨办法学 Python (Learn Python The Hard Way) Contents: 译者前言 前言:笨办法更简单 习题 0: 准备工作 习题 1: 第一个程序 习题 2: 注 ...
- 《Learn python the hard way》Exercise 48: Advanced User Input
这几天有点时间,想学点Python基础,今天看到了<learn python the hard way>的 Ex48,这篇文章主要记录一些工具的安装,以及scan 函数的实现. 首先与Ex ...
- [IT学习]Learn Python the Hard Way (Using Python 3)笨办法学Python3版本
黑客余弦先生在知道创宇的知道创宇研发技能表v3.1中提到了入门Python的一本好书<Learn Python the Hard Way(英文版链接)>.其中的代码全部是2.7版本. 如果 ...
- 学 Python (Learn Python The Hard Way)
学 Python (Learn Python The Hard Way) Contents: 译者前言 前言:笨办法更简单 习题 0: 准备工作 习题 1: 第一个程序 习题 2: 注释和井号 习题 ...
- 学习小计: Kaggle Learn Embeddings
Embedding表示map f: X(高维) -> Y(低维),减小数据维度,方便计算+提高准确率. 参看Kaggle Learn:https://www.kaggle.com/learn/e ...
- 快速入门:十分钟学会PythonTutorial - Learn Python in 10 minutes
This tutorial is available as a short ebook. The e-book features extra content from follow-up posts ...
- Python basic (from learn python the hard the way)
1. How to run the python file? python ...py 2. UTF-8 is a character encoding, just like ASCII. 3. ro ...
- Learn Python the hard way, ex41 来自Percal 25 号星星的哥顿人
我承认,我偷懒了,少打了大量代码(剧情),英文太差,下次可以编个中文的试试 #!/urs/bin/python #coding:utf-8 from sys import exit from rand ...
- 笨办法学Python(learn python the hard way)--练习程序31-35
下面是练习31-练习35,基于python3 #ex31.py 1 print("You enter a dark room witn two doors. Do you go throug ...
随机推荐
- Django 启动源码
handler = self.get_handler(*args, **options) run(self.addr, int(self.port), handler,ipv6=self.use_ip ...
- CSS_细节总结
1. 负外边距 上下200*200盒子的重叠,切记用 absolute 绝对定位 为最佳解决方案. 定位 position : fixed absolute relative( top 为 ...
- react_app 项目开发 (2)_axios_pubsub-js
生产环境打包并运行 yarn run build 会src代码进行打包处理,在内存中生成打包文件 将打包文件保存至内存 yarn global add serve serve -s build 将 b ...
- pytorch安装(使用pip3装到conda环境下)
之前在windows上使用pip3的方式安装过pytorch,虽然偶尔也会HTTP Error,安装失败,但是基本还是可以安装成功的.上 这一次在ubuntu上装了anaconda,想着之后的库都用c ...
- PDF的水印怎么去掉
很多朋友私下都有问过PDF去除水印的方法,现在在网上下载一些PDF电子书,几乎页面内都会有水印的,而且有的水印还带有超链接,稍微不注意就会点开进入别的页面内,不仅影响了阅读效果还带给读者负面影响,那如 ...
- 总结-shell脚本
执行脚本从 svn 检出项目 vi ace.sh #!/bin/bash svn export svn://127.0.0.1/ace/demo /ace/demo 设置脚本可执行 chmod +x ...
- js 中数组的遍历
var x = ['a','b','c'] x.forEach(function(val,k){ console.log(val + '--' +k); }) a--0 b-- 1 c-- 2 var ...
- angularjs知识点
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- synchronized和Lock复习
刚学编程的时候,不懂得同步的概念,只认为程序按照自己写的顺序执行, 直到学到多线程,但当时理解同步问题,也只是面对临界资源需要加锁去控制, 解决一些,如生产消费的问题.但当时一直没考虑过,多线程的情况 ...
- 解决loadrunner录制时 Request Connection: Remote Server @ 0.0.0.0:80 (Service=?) NOT PROXIED! (REASON: Unable to connect to remote server: rc = -1 , le = 0)问题
环境为win7+ie8+loadrunner11,录制脚本回放查看Recoding log 出现如下错误:[Net An. Error ( 7f8:1340)] Request Connecti ...