赞
踩
- a = int(input())
- ls = []
- for i in range(a):
- t = input().split(" ")
- if t[0] == 'insert':
- ls.insert(int(t[1]), int(t[2]))
- elif t[0] == 'print':
- print(ls)
- elif t[0] == 'remove':
- ls.remove(int(t[1]))
- elif t[0] == 'append':
- ls.append(int(t[1]))
- elif t[0] == 'sort':
- ls.sort()
- elif t[0] == 'pop':
- ls.pop()
- elif t[0] == 'reverse':
- ls.reverse()
- ls = ['the lord of the rings', 'anaconda', 'legally blonde', 'gone with the wind']
- s = input()
-
- if s == '1':
- print([x ** 3 for x in range(10)])
-
- elif s == '2':
- print([x ** 3 for x in [0, 2, 4, 6, 8]])
-
- elif s == '3':
- print([(x, x ** 3) for x in [1, 3, 5, 7, 9]])
-
- elif s == '4':
- for i in range(4):
- ls[i] = ls[i].capitalize()
- print(ls)
-
- else:
- print('结束程序')
-
- list1 = list(map(int,input().split()))
- list2 = list(map(int,input().split()))
-
- for i in list2:
- list1.append(i)
-
- list1.sort(reverse=True)
-
- print(list1)
- a = int(input())
- b = int(input())
-
- list1 = [('dungeon',7),('winterfell',4),('bran',9),('meelo',6)]
- list2 = [[ 'Angle', '0121701100106',99], [ 'Jack', '0121701100107',86], [ 'Tom', '0121701100109',65], [ 'Smith', '0121701100111', 100], ['Bob', '0121701100115',77], ['Lily', '0121701100117', 59]]
-
- if a>=len(list1):
- print(sorted(list1,key = lambda x:x[1]))
- else:
- print(sorted(list1,key = lambda x:x[1])[0:a])
-
- if b>=len(list2):
- print(sorted(list2,key = lambda x:x[0]))
- print(sorted(list2,key = lambda x:x[2]))
- else:
- print(sorted(list2,key = lambda x:x[0])[0:b])
- print(sorted(list2,key = lambda x:x[2])[0:b])
-
-
-
-
- ls = []
- while True:
- temp = input()
- if temp == '':
- break
- ls.append(temp.split())
- print(sorted(ls,key=lambda x:float(x[1][:-1]) * 1000 if x[1][-1] == 't' else float(x[1][:-2])))
-
- a = input()
-
- if (int(a[6]) == 0 and int(a[7]) >= 5) or int(a[6]) > 0:
- str = a[:6] + '19' + a[6:]
- else:
- str = a[:6] + '20' + a[6:]
-
- sum = (int(str[0]) * 7 + int(str[1]) * 9 + int(str[2]) * 10 + int(str[3]) * 5 + int(str[4]) * 8 + int(str[5]) * 4 + int(str[6]) * 2 + int(str[7]) * 1 + int(str[8]) * 6 + int(str[9]) * 3 + int(str[10]) * 7 + int(str[11]) * 9 + int(str[12]) * 10 + int(str[13]) * 5 + int(str[14]) * 8 + int(str[15]) * 4 + int(str[16]) * 2) % 11
-
- if sum == 0:
- str = str + '1'
- if sum == 1:
- str = str + '10'
- if sum == 2:
- str = str + 'X'
- if sum == 3:
- str = str + '9'
- if sum == 4:
- str = str + '8'
- if sum == 5:
- str = str + '7'
- if sum == 6:
- str = str + '6'
- if sum == 7:
- str = str + '5'
- if sum == 8:
- str = str + '4'
- if sum == 9:
- str = str + '3'
- if sum == 10:
- str = str + '2'
- print(str)
- Cube = int(input())
- for i in range(2,Cube+1):
- for a in range(2,i+1):
- for b in range(a,i+1):
- for c in range(b,i+1):
- if pow(i,3)==pow(a,3)+pow(b,3)+pow(c,3):
- print('Cube = {},Triple = ({},{},{})'.format(i,a,b,c))
-
- n, k = map(int, input().split(' '))
-
- ls = []
- if k < 2 or n < k or n<0 or k<0:
- print('Data Error!')
- else:
- for i in range(1, n + 1):
- ls.append(i)
- while len(ls) > k - 1:
- num = 1
- for i in ls:
- if num == k:
- ls.pop(k-1)
- ls = ls[k-1:] + ls[:k-1]
- break
- num = num + 1
- ls.sort()
- print(ls)
-
-
-
- import string
- def read_file(file):
- """接收文件名为参数,读取文件中的数据到字符串中,返回这个字符串"""
- with open(file, 'r', encoding='utf-8') as f:
- data = f.read()
- return data
-
-
- def word_list(txt):
- """接收字符串为参数,用空格替换字符串中所有标点符号,根据空格将字符串切分为列表
- 返回值为元素为单词的列表"""
- for punctuation in string.punctuation:
- txt = txt.replace(punctuation, ' ')
- return txt.split()
-
-
-
- def number_of_words(ls):
- """接收一个以单词为元素的列表为参数,返回列表中单词数量,返回值为整型"""
- return len(ls)
-
-
- if __name__ == '__main__':
- filename = input()
- text = read_file('step10/'+filename)
- words_list = word_list(text)
- words_counts = number_of_words(words_list)
- print('共有{}个单词'.format(words_counts))
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。