程序代写代做代考 1

1

2

3

4

pair = [1, 2]
5

matrix = [ [1,2,0,4], [0,1,3,-1], [0,0,1,8] ]
6

worst_list = [ [1, 2],
[],
[ [3, False, None], [4, lambda: 5]]]
7

8

letters = [“A”, “B”, “C”, “D”, “E”, “F”] #012345
sublist1 = letters[1:]
sublist2 = letters[1:4]
compound_word = “cortaúñas”
word1 = compound_word[:5]
word2 = compound_word[5:]
9

letters = [“A”, “B”, “C”, “D”, “E”, “F”] #012345
sublist1 = letters[1:] # [‘B’, ‘C’, ‘D’, ‘E’, ‘F’]
sublist2 = letters[1:4]
compound_word = “cortaúñas”
word1 = compound_word[:5]
word2 = compound_word[5:]
9

letters = [“A”, “B”, “C”, “D”, “E”, “F”] #012345
sublist1 = letters[1:] # [‘B’, ‘C’, ‘D’, ‘E’, ‘F’]
sublist2 = letters[1:4] # [‘B’, ‘C’, ‘D’]
compound_word = “cortaúñas”
word1 = compound_word[:5]
word2 = compound_word[5:]
9

letters = [“A”, “B”, “C”, “D”, “E”, “F”] #012345
sublist1 = letters[1:] # [‘B’, ‘C’, ‘D’, ‘E’, ‘F’]
sublist2 = letters[1:4] # [‘B’, ‘C’, ‘D’]
compound_word = “cortaúñas”
word1 = compound_word[:5] # “corta”
word2 = compound_word[5:]
9

letters = [“A”, “B”, “C”, “D”, “E”, “F”] #012345
sublist1 = letters[1:] # [‘B’, ‘C’, ‘D’, ‘E’, ‘F’]
sublist2 = letters[1:4] # [‘B’, ‘C’, ‘D’]
compound_word = “cortaúñas”
word1 = compound_word[:5] # “corta”
word2 = compound_word[5:] # “úñas”
9

listA = [2, 3]
listB = listA
listC = listA[:]
listA[0] = 4
listB[1] = 5
list()
listA = [2, 3]
listB = listA
listC = list(listA)
listA[0] = 4
listB[1] = 5
10

11

def sum_nums(nums):
“””Returns the sum of the numbers in NUMS. >>> sum_nums([6, 24, 1984])
2014
>>> sum_nums([-32, 0, 32])
0
“””
12

def sum_nums(nums):
“””Returns the sum of the numbers in NUMS. >>> sum_nums([6, 24, 1984])
2014
>>> sum_nums([-32, 0, 32])
0
“””
if (nums == []):
return 0 else:
return nums[0] + sum_nums( nums[1:] )
13

def sum_up_to(n):
“””Returns the sum of positive numbers from 1 up to N (inclusive) >>> sum_up_to(5)
15
“””
14
.

range
def sum_up_to(n):
“””Returns the sum of positive numbers from 1 up to N (inclusive) >>> sum_up_to(5)
15
“””
sum = 0
for n in range(0, n+1):
sum += n return sum
end
range(start, end)
15
.

def sum_up_to(n):
“””Returns the sum of positive numbers from 1 up to N (inclusive) >>> sum_up_to(5)
15
“””
16
.

def sum_up_to(n):
“””Returns the sum of positive numbers from 1 up to N (inclusive) >>> sum_up_to(5)
15
“””
if n == 1:
return 1 else:
return n + sum_up_to(n-1)
17
.

18

def reverse(s):
“””Returns a string with the letters of S in the inverse order.
>>> reverse(‘ward’)
‘draw’
“””
reverse(“ward”) =
reverse(“ard”) =
reverse(“rd”) =
reverse(“d”) =
19

def reverse(s):
“””Returns a string with the letters of S in the inverse order.
>>> reverse(‘ward’)
‘draw’
“””
reverse(“ward”) = reverse(“ard”) + “w”
reverse(“ard”) = reverse(“rd”) + “a”
reverse(“rd”) = reverse(“d”) + “r”
reverse(“d”) =
19

def reverse(s):
“””Returns a string with the letters of S in the inverse order.
>>> reverse(‘ward’)
‘draw’
“””
reverse(“ward”) = reverse(“ard”) + “w”
reverse(“ard”) = reverse(“rd”) + “a”
reverse(“rd”) = reverse(“d”) + “r”
reverse(“d”) = “d”
19

def reverse(s):
“””Returns a string with the letters of S in the inverse order.
>>> reverse(‘ward’)
‘draw’
“””
if len(s) == 1:
return s else:
return reverse(s[1:]) + s[0]
20

reverse(ward) ret: draw
reverse(ard) ret: dra
reverse(rd) ret: dr
reverse(d) ret: d
< Prev > Next
21

def reverse(n):
“””Returns N with the digits reversed. >>> reverse_digits(123)
321
“””
22

def fUnKyCaSe(text):
“””Returns TEXT in fUnKyCaSe >>> fUnKyCaSe(“wats up”) ‘wAtS Up’
“””
23

def fUnKyCaSe(text):
“””Returns TEXT in fUnKyCaSe >>> fUnKyCaSe(“wats up”) ‘wAtS Up’
“””
def toggle_case(letter, should_up_case):
return letter.upper() if should_up_case else letter.lower()
def up_down(text, should_up_case): if len(text) == 1:
return toggle_case(text, should_up_case) else:
return toggle_case(text[0], should_up_case) + up_down(text[1:], not should_up_cas return up_down(text, False)
23
e
)

== 0 == 1
== []
== ”
len(S) == 1
n % 10
L[0]
S[0]
n // 10
L[1:] L[:-1]
S[1:] S[:-1]
24

25

sum(iterable,
start)
all(iterable)
any(iterable)
max(iterable,
key=None)
min(iterable,
key=None)
start
True
iterable
iterable
iterable
iterable
iterable
iterable
False
True
iterable
26

sum([73, 89, 74, 95], 0) # 331
all([True, True, True, True])
any([False, False, False, True]) all([x < 5 for x in range(5)]) perfect_square = lambda x: x == round(x ** 0.5) ** 2 any([perfect_square(x) for x in range(50, 60)]) 27 sum([73, 89, 74, 95], 0) # 331 all([True, True, True, True]) # True any([False, False, False, True]) all([x < 5 for x in range(5)]) perfect_square = lambda x: x == round(x ** 0.5) ** 2 any([perfect_square(x) for x in range(50, 60)]) 27 sum([73, 89, 74, 95], 0) # 331 all([True, True, True, True]) # True any([False, False, False, True]) # True all([x < 5 for x in range(5)]) perfect_square = lambda x: x == round(x ** 0.5) ** 2 any([perfect_square(x) for x in range(50, 60)]) 27 sum([73, 89, 74, 95], 0) # 331 all([True, True, True, True]) # True any([False, False, False, True]) # True all([x < 5 for x in range(5)]) # True perfect_square = lambda x: x == round(x ** 0.5) ** 2 any([perfect_square(x) for x in range(50, 60)]) 27 sum([73, 89, 74, 95], 0) # 331 all([True, True, True, True]) # True any([False, False, False, True]) # True all([x < 5 for x in range(5)]) # True perfect_square = lambda x: x == round(x ** 0.5) ** 2 any([perfect_square(x) for x in range(50, 60)]) # False 27 max([73, 89, 74, 95]) # 95 max(["C+", "B+", "C", "A"]) max(range(10)) 28 max([73, 89, 74, 95]) # 95 max(["C+", "B+", "C", "A"]) # C+ max(range(10)) 28 max([73, 89, 74, 95]) max(["C+", "B+", "C", "A"]) max(range(10)) # 95 # C+ # 9 28 max([73, 89, 74, 95]) max(["C+", "B+", "C", "A"]) max(range(10)) # 95 # C+ # 9 coords = [ [37, -144], [-22, -115], [56, -163] ] max(coords, key=lambda coord: coord[0]) min(coords, key=lambda coord: coord[0]) gymnasts = [ ["Brittany", 9.15, 9.4, 9.3, 9.2], ["Lea", 9, 8.8, 9.1, 9.5], ["Maya", 9.2, 8.7, 9.2, 8.8] ] min(gymnasts, key=lambda scores: min(scores[1:])) max(gymnasts, key=lambda scores: sum(scores[1:], 0)) 28 max([73, 89, 74, 95]) max(["C+", "B+", "C", "A"]) max(range(10)) # 95 # C+ # 9 coords = [ [37, -144], [-22, -115], [56, -163] ] max(coords, key=lambda coord: coord[0]) # [56, -163] min(coords, key=lambda coord: coord[0]) gymnasts = [ ["Brittany", 9.15, 9.4, 9.3, 9.2], ["Lea", 9, 8.8, 9.1, 9.5], ["Maya", 9.2, 8.7, 9.2, 8.8] ] min(gymnasts, key=lambda scores: min(scores[1:])) max(gymnasts, key=lambda scores: sum(scores[1:], 0)) 28 max([73, 89, 74, 95]) max(["C+", "B+", "C", "A"]) max(range(10)) # 95 # C+ # 9 coords = [ [37, -144], [-22, -115], [56, -163] ] max(coords, key=lambda coord: coord[0]) # [56, -163] min(coords, key=lambda coord: coord[0]) # [-22, -115] gymnasts = [ ["Brittany", 9.15, 9.4, 9.3, 9.2], ["Lea", 9, 8.8, 9.1, 9.5], ["Maya", 9.2, 8.7, 9.2, 8.8] ] min(gymnasts, key=lambda scores: min(scores[1:])) max(gymnasts, key=lambda scores: sum(scores[1:], 0)) 28 max([73, 89, 74, 95]) max(["C+", "B+", "C", "A"]) max(range(10)) # 95 # C+ # 9 coords = [ [37, -144], [-22, -115], [56, -163] ] max(coords, key=lambda coord: coord[0]) # [56, -163] min(coords, key=lambda coord: coord[0]) # [-22, -115] gymnasts = [ ["Brittany", 9.15, 9.4, 9.3, 9.2], ["Lea", 9, 8.8, 9.1, 9.5], ["Maya", 9.2, 8.7, 9.2, 8.8] ] min(gymnasts, key=lambda scores: min(scores[1:])) max(gymnasts, key=lambda scores: sum(scores[1:], 0)) # ["Maya", ...] 28 max([73, 89, 74, 95]) max(["C+", "B+", "C", "A"]) max(range(10)) # 95 # C+ # 9 coords = [ [37, -144], [-22, -115], [56, -163] ] max(coords, key=lambda coord: coord[0]) # [56, -163] min(coords, key=lambda coord: coord[0]) # [-22, -115] gymnasts = [ ["Brittany", 9.15, 9.4, 9.3, 9.2], ["Lea", 9, 8.8, 9.1, 9.5], ["Maya", 9.2, 8.7, 9.2, 8.8] ] min(gymnasts, key=lambda scores: min(scores[1:])) # ["Maya", ...] max(gymnasts, key=lambda scores: sum(scores[1:], 0)) # ["Brittany", . 28 .. 29 30