程序代写代做代考 python 1

1

2

3

members = []
members = [“Pamela”, “Tinu”, “Brenda”, “Kaya”]
ages_of_kids = [1, 2, 7]
prices = [79.99, 49.99, 89.99]
digits = [2//2, 2+2+2+2, 2, 2*2*2]
remixed = [“Pamela”, 7, 79.99, 2*2*2]
4

len()
attendees = [“Tammy”, “Shonda”, “Tina”]
print(len(attendees))
num_of_attendees = len(attendees)
print(num_of_attendees)
5

len()
attendees = [“Tammy”, “Shonda”, “Tina”]
print(len(attendees)) # 3
num_of_attendees = len(attendees)
print(num_of_attendees)
5

letters = [‘A’, ‘B’, ‘C’] #Index: 0 1 2
letters[0]
letters[1]
letters[2]
letters[3]
curr_ind = 1
letters[curr_ind]
6

letters = [‘A’, ‘B’, ‘C’] #Index: 0 1 2
letters[0] # ‘A’
letters[1] # ‘B’
letters[2] # ‘C’
letters[3]
curr_ind = 1
letters[curr_ind] # ‘B’
6

letters = [‘A’, ‘B’, ‘C’] #Index: 0 1 2
letters[0] # ‘A’
letters[1] # ‘B’
letters[2] # ‘C’
letters[3] # Error!
curr_ind = 1
letters[curr_ind] # ‘B’
6

letters = [‘A’, ‘B’, ‘C’] #Index: 0 1 2
letters[0] # ‘A’
letters[1] # ‘B’
letters[2] # ‘C’
letters[3] # Error!
curr_ind = 1
letters[curr_ind] # ‘B’
6

letters = [‘A’, ‘B’, ‘C’] #Index: 0 1 2
letters[0] # ‘A’
letters[1] # ‘B’
letters[2] # ‘C’
letters[3] # Error!
curr_ind = 1
letters[curr_ind] # ‘B’
letters[-1] # ‘C’
letters[-2] # ‘B’
letters[-4] # Error!
6

from operator import getitem getitem(letters, 0)
7

+
boba_prices = [5.50, 6.50, 7.50]
smoothie_prices = [7.00, 7.50]
all_prices = boba_prices + smoothie_prices
add
from operator import add
boba_prices = [5.50, 6.50, 7.50]
smoothie_prices = [7.00, 7.50]
all_prices = add(boba_prices, smoothie_prices)
8

*
boba_prices = [5.50, 6.50, 7.50]
more_boba = boba_prices * 3
mul
from operator import mul boba_prices = [5.50, 6.50, 7.50]
more_boba = mul(boba_prices, 3)
digits = [1, 9, 8, 4]
together = [6, 2, 4] + digits * 2
together = add([2, 7], mul(digits, 2))
9

*
boba_prices = [5.50, 6.50, 7.50]
more_boba = boba_prices * 3
mul
from operator import mul boba_prices = [5.50, 6.50, 7.50]
more_boba = mul(boba_prices, 3)
digits = [1, 9, 8, 4]
together = [6, 2, 4] + digits * 2 # [6, 2, 4, 1, 9, 8, 4, 1, 9, 8, 4]
together = add([2, 7], mul(digits, 2))
9

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] ]
gymnasts
gymnasts[0]
10

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] ]
gymnasts
gymnasts[0]
10

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] ]
gymnasts
gymnasts[0]
10

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]
gymnasts[0]
gymnasts[0][0]
gymnasts[1][0]
gymnasts[1][4]
gymnasts[1][5]
gymnasts[3][0]
11

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]
gymnasts[0]
gymnasts[0][0]
gymnasts[1][0]
gymnasts[1][4]
gymnasts[1][5]
gymnasts[3][0]
# [“Brittany”, 9.15, 9.4, 9.3, 9.2]
11

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]
gymnasts[0]
gymnasts[0][0] # “Brittany”
gymnasts[1][0]
gymnasts[1][4]
gymnasts[1][5]
gymnasts[3][0]
# [“Brittany”, 9.15, 9.4, 9.3, 9.2]
11

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]
gymnasts[0]
gymnasts[0][0] # “Brittany”
gymnasts[1][0] # “Lea”
gymnasts[1][4]
gymnasts[1][5]
gymnasts[3][0]
# [“Brittany”, 9.15, 9.4, 9.3, 9.2]
11

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]
gymnasts[0]
gymnasts[0][0] # “Brittany”
gymnasts[1][0] # “Lea”
gymnasts[1][4] # 9.5
gymnasts[1][5]
gymnasts[3][0]
# [“Brittany”, 9.15, 9.4, 9.3, 9.2]
11

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]
gymnasts[0]
gymnasts[0][0] # “Brittany”
gymnasts[1][0] # “Lea”
gymnasts[1][4] # 9.5
gymnasts[1][5] # IndexError!
gymnasts[3][0]
# [“Brittany”, 9.15, 9.4, 9.3, 9.2]
11

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]
gymnasts[0]
gymnasts[0][0] # “Brittany”
gymnasts[1][0] # “Lea”
gymnasts[1][4] # 9.5
gymnasts[1][5] # IndexError!
gymnasts[3][0] # IndexError!
# [“Brittany”, 9.15, 9.4, 9.3, 9.2]
11

12

in
digits = [2, 8, 3, 1, 8, 5, 3, 0, 7, 1] 1 in digits
3 in digits
4 in digits
not (4 in digits)
13

in
digits = [2, 8, 3, 1, 8, 5, 3, 0, 7, 1] 1 in digits # True
3 in digits # True
4 in digits # False
not (4 in digits) # True
13

14

for in :

while
def count(s, value): total = 0
for element in s:
if element == value:
total = total + 1 return total
15

for in :



16

gymnasts = [
]
for-in
for gymnast in gymnasts: for data in gymnast:
print(data, end=”|”)
[“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]
17

pairs = [[1, 2], [2, 2], [3, 2], [4, 4]]
same_count = 0
for x, y in pairs: if x == y:
same_count = same_count + 1
18

19

… -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5…
range(-2, 3)
for num in range(6):
print(num) # 0, 1, 2, 3, 4, 5
for num in range(1, 6):
print(num) # 1, 2, 3, 4, 5
20

21

[

for in ]
odds = [1, 3, 5, 7, 9]
evens = [(num + 1) for num in odds]
22

[

for in ] odds = [1, 3, 5, 7, 9]
evens = [(num + 1) for num in odds]
[

for in if ]
temps = [60, 65, 71, 67, 77, 89]
hot = [temp for temp in temps if temp > 70]
22

[

for in if ]


letters = [‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘m’, ‘n’, ‘o’, ‘p’] word = [letters[i] for i in [3, 4, 6, 8]]
23

def divisors(n):
“””Returns all the divisors of N.
>>> divisors(12)
[1, 2, 3, 4, 6]
“””
24

def divisors(n):
“””Returns all the divisors of N.
>>> divisors(12)
[1, 2, 3, 4, 6]
“””
return [x for x in range(1, n) if n % x == 0]
25

def front(s, f):
“””Return S but with elements chosen by F at the front.
>>> front(range(10), lambda x: x % 2 == 1) # odds in front
[1, 3, 5, 7, 9, 0, 2, 4, 6, 8]
“””
26

def front(s, f):
“””Return S but with elements chosen by F at the front.
>>> front(range(10), lambda x: x % 2 == 1) # odds in front [1, 3, 5, 7, 9, 0, 2, 4, 6, 8]
“””
return [e for e in s if f(e)] + [e for e in s if not f(e)]
27

28

‘2,400’ ‘2.400’ ‘1.2e-5’
“””Se lembra quando a gente
Chegou um dia a acreditar
Que tudo era pra sempre
Sem saber
Que o pra sempre sempre acaba”””
‘curry = lambda f: lambda x: lambda y: f(x, y)’
29

‘您好, I am a string, hear me roar !’ “I’ve got an apostrophe”
“””The Zen of Python
claims, Readability counts.
Read more: import this.”””
# ‘The Zen of Python\nclaims, Readability counts.\nRead more: import
\n
30
th

alfabeto = ‘abcdefghijklmñopqrstuvwxyz’
len(alfabeto) # 27
alfabeto[13] + “andu” # ñandu
alfabeto + ‘ ¡Ya conoces el ABC!’
31

initial = ‘P’
initial[0] == initial
in
‘W’ in ‘Where\’s Waldo’ ‘Waldo’ in ‘Where\’s Waldo’
# True
32

initial = ‘P’
initial[0] == initial # True
in
‘W’ in ‘Where\’s Waldo’ # True ‘Waldo’ in ‘Where\’s Waldo’
32

initial = ‘P’
initial[0] == initial # True
in
‘W’ in ‘Where\’s Waldo’ # True ‘Waldo’ in ‘Where\’s Waldo’ # True
32