#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()
转载于:https://www.cnblogs.com/andyyangpython/p/10539143.html