zoukankan      html  css  js  c++  java
  • 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( '12' )) 
    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]
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- focus on what you want to be
  • 相关阅读:
    Python之路_Day6
    正则表达式
    tensorflow 使用 5 mnist 数据集, softmax 函数
    数据分析 大数据之路 六 matplotlib 绘图工具
    tensorflow 使用 4 非线性回归
    tensorflow 使用 3 模型学习
    数据分析 大数据之路 五 pandas 报表
    tensorflow 使用 2 Felch ,Feed
    tensorflow 使用 1 常量,变量
    数据分析 大数据之路 四 numpy 2
  • 原文地址:https://www.cnblogs.com/bamboozone/p/10590697.html
Copyright © 2011-2022 走看看