Skip to content

Commit bba924b

Browse files
authored
Final QA (#487)
1 parent 0f81139 commit bba924b

File tree

6 files changed

+18
-14
lines changed

6 files changed

+18
-14
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
quote = "life, uh, finds a way"
2-
unique_vowels = {char for char in quote if char in "aeiou"}
3-
print(unique_vowels)
1+
squares = {number: number * number for number in range(10)}
2+
print(squares)
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
squares = []
2-
for i in range(10):
3-
squares.append(i * i)
2+
for number in range(10):
3+
squares.append(number * number)
4+
45
print(squares)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
squares = [i * i for i in range(10)]
1+
squares = [number * number for number in range(10)]
22
print(squares)

python-list-comprehension/list_comprehension_with_condition_and_function.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
sentence = "The rocket, who was named Ted, came back \
2-
from Mars because he missed his friends."
1+
sentence = (
2+
"The rocket, who was named Ted, came back "
3+
"from Mars because he missed his friends."
4+
)
35

46

57
def is_consonant(letter):

python-list-comprehension/profiling.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
import timeit
33

44
TAX_RATE = 0.08
5-
prices = [random.randrange(100) for _ in range(100000)]
5+
PRICES = [random.randrange(100) for _ in range(100_000)]
66

77

88
def get_price(price):
99
return price * (1 + TAX_RATE)
1010

1111

1212
def get_prices_with_map():
13-
return list(map(get_price, prices))
13+
return list(map(get_price, PRICES))
1414

1515

1616
def get_prices_with_comprehension():
17-
return [get_price(price) for price in prices]
17+
return [get_price(price) for price in PRICES]
1818

1919

2020
def get_prices_with_loop():
2121
prices = []
22-
for price in prices:
22+
for price in PRICES:
2323
prices.append(get_price(price))
2424
return prices
2525

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
squares = {i: i * i for i in range(10)}
2-
print(squares)
1+
quote = "life, uh, finds a way"
2+
3+
unique_vowels = {char for char in quote if char in "aeiou"}
4+
print(unique_vowels)

0 commit comments

Comments
 (0)