• day 11


    #1 例如:min_max(2,5,7,8,4) 返回:{‘max’:8,’min’:2}(此题用到max(),min()内置函数)
    # def min_max(*args):
    # dic = {"max":max(args),'min':min(args)}
    # print(dic)
    # min_max(*[2, 5, 7, 8, 4])

    #2 写函数,传入一个参数n,返回n的阶乘.
    # def cal(num):
    # if num ==1 :
    # return 1
    # else:
    # return num*cal(num-1)
    # print(cal(6))
    # 3 写函数,返回一个扑克牌列表,里面有52项,每一项是一个元组
    # 例如:[(‘红心’,2),(‘草花’,2), …(‘黑桃’,‘A’)]
    # a = ["红桃","黑桃","草花"]
    # b = [1,2,3,4,5,6]
    # def list1(a,b):
    # llst = []
    # for i in a:
    # for j in b:
    # tuple1 = (i,j)
    # llst.append(tuple1)
    # return llst
    # print(list1(a,b))

    #4

    # def calc(a,b,c,d=1,e=2):
    # return (a+b)*(c-d)+e
    # print(calc(1,2,3,d=5,4))

    # def extendList(val,list=[]):
    # list.append(val)
    # return list
    #
    # list1 = extendList(10)
    # list2 = extendList(123,[])
    # list3 = extendList('a')
    #
    # print('list1=%s'%list1)
    # print('list2=%s'%list2)
    # print('list3=%s'%list3)

    # 写代码完成99乘法表.(升级题)
    # 1 * 1 = 1
    # 2 * 1 = 2 2 * 2 = 4
    # 3 * 1 = 3 3 * 2 = 6 3 * 3 = 9

    def cfb():
    for i in range(1,10):
    for j in range(1,i+1):
    print("{}*{}={}".format(i,j,i*j),end=" ")
    print("")
    cfb()

  • 相关阅读:
    STL与泛型编程-练习2-GeekBand
    HashSet
    JAVA集合
    分布式锁1 Java常用技术方案
    JAVA 锁
    JAVA多线程二
    JAVA多线程一
    Redis pipeline and list
    mongo 安装
    Intersection of Two Arrays
  • 原文地址:https://www.cnblogs.com/andyyangpython/p/10539143.html
Copyright © 2020-2023  润新知