zoukankan      html  css  js  c++  java
  • Python 刷题知识点

    if :
        elif :
    else :
    print('{0} 
    {1} 
    {2}' .format((a + b), (a - b), (a * b)))
    print(*[num**2 for num in range(n)], sep = '
    ')
    def f():
        return condition # 直接返回判断的条件真或假
    print(*range(1, int(input())+1), sep= '')
    x, y, z, n = (int(input()) for _ in range(4))
    print ([a, b, c] for a in range(0, x+1) for b in range(0, y+1) for c in range(0, z+1) if a + b + c != n])
    i = int(input())
    lis = list(map(int,raw_input().strip().split()))[:i]
    z = max(lis)
    while max(lis) == z:
        lis.remove(max(lis))
    
    print max(lis)
    n = int(input())
    marksheet = [[input(), float(input())] for _ in range(n)]
    second_highest = sorted(list(set([marks for name, marks in marksheet])))[1]
    print('
    '.join([a for a,b in sorted(marksheet) if b == second_highest]))
    if __name__ == '__main__':
        n = int(input())
        student_marks = {}
        for _ in range(n):
            name, *line = input().split()
            scores = list(map(float, line))
            student_marks[name] = scores
        query_name = input()
        query_scores = student_marks[query_name]
        print("{0:.2f}".format(sum(query_scores) / (len(query_scores))))
    L = []
    for _ in range(0, int(input())):
        user_input = input().split(' ')
        command = user_input.pop(0)
        if len(user_input) > 0:
            if 'insert' == command:
                eval("L.{0}({1}, {2})".format(command, user_input[0], user_input[1]))
            else:
                eval("L.{0}({1})".format(command, user_input[0]))
        elif command == 'print':
            print(L)
        else:
            eval("L.{0}()".format(command))
    # eval() 将insert, pop, print等str转换成命令字符,进行执行
    print raw_input() == 0 or hash(tuple(map(int, raw_input().split(' '))))
    def swap_case(s):
        return s.swapcase() # 字母大小写转换函数
    
    if __name__ == '__main__':
        s = input()
        result = swap_case(s)
        print(result)
    def split_and_join(line):
        return "-".join(line.split(" ")) # 先分隔在用符号代替
    
    if __name__ == '__main__':
        line = input()
        result = split_and_join(line)
        print(result)
    import sys
    import xml.etree.ElementTree as etree
    
    def get_attr_number(node):
        return sum([len(elem.items()) for elem in tree.iter()])
    
    if __name__ == '__main__':
        sys.stdin.readline()
        xml = sys.stdin.read()
        tree = etree.ElementTree(etree.fromstring(xml))
        root = tree.getroot()
        print(get_attr_number(root))
    import xml.etree.ElementTree as etree
    
    maxdepth = 0
    def depth(elem, level):
        global maxdepth
        level += 1
        if level >= maxdepth:
            maxdepth = level
        for child in elem:
            depth(child, level)
    
    if __name__ == '__main__':
        n = int(input())
        xml = ""
        for i in range(n):
            xml =  xml + input() + "
    "
        tree = etree.ElementTree(etree.fromstring(xml))
        depth(tree.getroot(), -1)
        print(maxdepth)
    import re
    
    n, m = map(int, input().split())
    a, b = [], ""
    for _ in range(n):
        a.append(input())
    
    for z in zip(*a):
        b += "".join(z)
    
    print(re.sub(r"(?<=w)([^w]+)(?=w)", " ", b))
    import numpy as np
    print(np.array(input().split(),int).reshape(3,3))
    n, m = map(int, input().split())
    array = numpy.array([input().strip().split() for _ in range(n)], int)
    print (array.transpose())
    print (array.flatten())
    import numpy as np
    a, b, c = map(int,input().split())
    arrA = np.array([input().split() for _ in range(a)],int)
    arrB = np.array([input().split() for _ in range(b)],int)
    print(np.concatenate((arrA, arrB), axis = 0))
    Try to be a giver
  • 相关阅读:
    jquery异步加载json格式的数据
    三角形及选中取消按钮的css代码
    css实现自适应宽度布局
    table表格中实现tbody部分可滚动,且thead部分固定
    table数据表格添加checkbox进行数据进行两个表格左右移动。
    对checkbox 的checked的一些总结
    Java多线程同步器
    Springboot动态获取bean对象工具类
    并发阻塞队列和非阻塞队列详解
    多线程-volatile关键字和ThreadLocal详解
  • 原文地址:https://www.cnblogs.com/HannahGreen/p/12065777.html
Copyright © 2011-2022 走看看