Skip to content

Commit 5a77519

Browse files
committed
Black reformatting pass
1 parent c5b3da1 commit 5a77519

File tree

22 files changed

+163
-134
lines changed

22 files changed

+163
-134
lines changed

ch04-strings-and-methods/0-strings-and-methods.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111

1212

1313
# Exercise 3
14-
print('''This string was written on multiple lines,
15-
and it displays across multiple lines''')
14+
print(
15+
"""This string was written on multiple lines,
16+
and it displays across multiple lines"""
17+
)
1618

1719

1820
# Exercise 4
19-
print("This one-line string was written out \
20-
using multiple lines")
21+
print(
22+
"This one-line string was written out \
23+
using multiple lines"
24+
)

ch04-strings-and-methods/1-mess-around-with-your-words.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@
2727
# A more advanced way to do the above example would be:
2828
my_string = "bazinga"
2929
start_index = 2
30-
print(my_string[start_index:len(my_string) - start_index + 1])
30+
print(my_string[start_index : len(my_string) - start_index + 1])

ch06-functions-and-loops/2-assignment.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Convert Celsius and Fahrenheit temperatures using functions
66

7+
78
def convert_cel_to_far(cel_temp):
89
far_temp = cel_temp * 9 / 5 + 32
910
return far_temp

ch06-functions-and-loops/3-run-in-circles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# Exercise 2
1212
# print the integer 2 through 10 using a "while" loop
1313
i = 2
14-
while (i < 11):
14+
while i < 11:
1515
print(i)
1616
i = i + 1
1717

ch06-functions-and-loops/4-assignment.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Calculate compound interest to track the growth of an investment
66

7+
78
def invest(amount, rate, time):
89
print("principal amount: ${}".format(amount))
910
print("annual rate of return:", rate)
@@ -13,5 +14,5 @@ def invest(amount, rate, time):
1314
print()
1415

1516

16-
invest(100, .05, 8)
17-
invest(2000, .025, 5)
17+
invest(100, 0.05, 8)
18+
invest(2000, 0.025, 5)

ch08-conditional-logic/8-assignment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
for trial in range(0, trials):
1414
A_win = 0
1515
B_win = 0
16-
if random() < .87: # 1st region
16+
if random() < 0.87: # 1st region
1717
A_win += 1
1818
else:
1919
B_win += 1
20-
if random() < .65: # 2nd region
20+
if random() < 0.65: # 2nd region
2121
A_win += 1
2222
else:
2323
B_win += 1
24-
if random() < .17: # 3rd region
24+
if random() < 0.17: # 3rd region
2525
A_win += 1
2626
else:
2727
B_win += 1

ch09-lists-and-dictionaries/2-assignment.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def enrollment_stats(list_of_universities):
1919

2020
def mean(my_list):
2121
if len(my_list) == 0:
22-
return 'The list is empty'
22+
return "The list is empty"
2323
list_sum = 0
2424
for i in range(len(my_list)):
2525
list_sum += float(my_list[i])
@@ -35,13 +35,13 @@ def median(my_list):
3535

3636

3737
universities = [
38-
['California Institute of Technology', 2175, 37704],
39-
['Harvard', 19627, 39849],
40-
['Massachusetts Institute of Technology', 10566, 40732],
41-
['Princeton', 7802, 37000],
42-
['Rice', 5879, 35551],
43-
['Stanford', 19535, 40569],
44-
['Yale', 11701, 40500],
38+
["California Institute of Technology", 2175, 37704],
39+
["Harvard", 19627, 39849],
40+
["Massachusetts Institute of Technology", 10566, 40732],
41+
["Princeton", 7802, 37000],
42+
["Rice", 5879, 35551],
43+
["Stanford", 19535, 40569],
44+
["Yale", 11701, 40500],
4545
]
4646

4747
totals = enrollment_stats(universities)

ch09-lists-and-dictionaries/3-assignment.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,22 @@
66

77
from random import choice
88

9-
noun = ["fossil", "horse", "aardvark", "judge",
10-
"chef", "mango", "extrovert", "gorilla"]
11-
verb = ["kicks", "jingles", "bounces", "slurps",
12-
"meows", "explodes", "curdles"]
13-
adjective = ["furry", "balding", "incredulous",
14-
"fragrant", "exuberant", "glistening"]
15-
preposition = ["against", "after", "into", "beneath",
16-
"upon", "for", "in", "like", "over", "within"]
17-
adverb = ["curiously", "extravagantly",
18-
"tantalizingly", "furiously", "sensuously"]
9+
noun = ["fossil", "horse", "aardvark", "judge", "chef", "mango", "extrovert", "gorilla"]
10+
verb = ["kicks", "jingles", "bounces", "slurps", "meows", "explodes", "curdles"]
11+
adjective = ["furry", "balding", "incredulous", "fragrant", "exuberant", "glistening"]
12+
preposition = [
13+
"against",
14+
"after",
15+
"into",
16+
"beneath",
17+
"upon",
18+
"for",
19+
"in",
20+
"like",
21+
"over",
22+
"within",
23+
]
24+
adverb = ["curiously", "extravagantly", "tantalizingly", "furiously", "sensuously"]
1925

2026

2127
def make_poem():

ch09-lists-and-dictionaries/5-store-relationships-in-dictionaries.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@
3535

3636
# Exercise 5
3737
# Remove "Darth Vader"
38-
del(birthdays["Darth Vader"])
38+
del (birthdays["Darth Vader"])
3939
print(birthdays)
4040

4141

4242
# Exercise 6 (Bonus)
4343
# Create dictionary by passing a list to dict()
44-
birthdays = dict([("Luke Skywalker", "5/25/19"),
45-
("Obi-Wan Kenobi", "3/11/57"),
46-
("Darth Vader", "4/1/41")])
44+
birthdays = dict(
45+
[
46+
("Luke Skywalker", "5/25/19"),
47+
("Obi-Wan Kenobi", "3/11/57"),
48+
("Darth Vader", "4/1/41"),
49+
]
50+
)

ch09-lists-and-dictionaries/6-capitals.py

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,54 @@
33

44

55
capitals_dict = {
6-
'Alabama': 'Montgomery',
7-
'Alaska': 'Juneau',
8-
'Arizona': 'Phoenix',
9-
'Arkansas': 'Little Rock',
10-
'California': 'Sacramento',
11-
'Colorado': 'Denver',
12-
'Connecticut': 'Hartford',
13-
'Delaware': 'Dover',
14-
'Florida': 'Tallahassee',
15-
'Georgia': 'Atlanta',
16-
'Hawaii': 'Honolulu',
17-
'Idaho': 'Boise',
18-
'Illinois': 'Springfield',
19-
'Indiana': 'Indianapolis',
20-
'Iowa': 'Des Moines',
21-
'Kansas': 'Topeka',
22-
'Kentucky': 'Frankfort',
23-
'Louisiana': 'Baton Rouge',
24-
'Maine': 'Augusta',
25-
'Maryland': 'Annapolis',
26-
'Massachusetts': 'Boston',
27-
'Michigan': 'Lansing',
28-
'Minnesota': 'Saint Paul',
29-
'Mississippi': 'Jackson',
30-
'Missouri': 'Jefferson City',
31-
'Montana': 'Helena',
32-
'Nebraska': 'Lincoln',
33-
'Nevada': 'Carson City',
34-
'New Hampshire': 'Concord',
35-
'New Jersey': 'Trenton',
36-
'New Mexico': 'Santa Fe',
37-
'New York': 'Albany',
38-
'North Carolina': 'Raleigh',
39-
'North Dakota': 'Bismarck',
40-
'Ohio': 'Columbus',
41-
'Oklahoma': 'Oklahoma City',
42-
'Oregon': 'Salem',
43-
'Pennsylvania': 'Harrisburg',
44-
'Rhode Island': 'Providence',
45-
'South Carolina': 'Columbia',
46-
'South Dakota': 'Pierre',
47-
'Tennessee': 'Nashville',
48-
'Texas': 'Austin',
49-
'Utah': 'Salt Lake City',
50-
'Vermont': 'Montpelier',
51-
'Virginia': 'Richmond',
52-
'Washington': 'Olympia',
53-
'West Virginia': 'Charleston',
54-
'Wisconsin': 'Madison',
55-
'Wyoming': 'Cheyenne',
6+
"Alabama": "Montgomery",
7+
"Alaska": "Juneau",
8+
"Arizona": "Phoenix",
9+
"Arkansas": "Little Rock",
10+
"California": "Sacramento",
11+
"Colorado": "Denver",
12+
"Connecticut": "Hartford",
13+
"Delaware": "Dover",
14+
"Florida": "Tallahassee",
15+
"Georgia": "Atlanta",
16+
"Hawaii": "Honolulu",
17+
"Idaho": "Boise",
18+
"Illinois": "Springfield",
19+
"Indiana": "Indianapolis",
20+
"Iowa": "Des Moines",
21+
"Kansas": "Topeka",
22+
"Kentucky": "Frankfort",
23+
"Louisiana": "Baton Rouge",
24+
"Maine": "Augusta",
25+
"Maryland": "Annapolis",
26+
"Massachusetts": "Boston",
27+
"Michigan": "Lansing",
28+
"Minnesota": "Saint Paul",
29+
"Mississippi": "Jackson",
30+
"Missouri": "Jefferson City",
31+
"Montana": "Helena",
32+
"Nebraska": "Lincoln",
33+
"Nevada": "Carson City",
34+
"New Hampshire": "Concord",
35+
"New Jersey": "Trenton",
36+
"New Mexico": "Santa Fe",
37+
"New York": "Albany",
38+
"North Carolina": "Raleigh",
39+
"North Dakota": "Bismarck",
40+
"Ohio": "Columbus",
41+
"Oklahoma": "Oklahoma City",
42+
"Oregon": "Salem",
43+
"Pennsylvania": "Harrisburg",
44+
"Rhode Island": "Providence",
45+
"South Carolina": "Columbia",
46+
"South Dakota": "Pierre",
47+
"Tennessee": "Nashville",
48+
"Texas": "Austin",
49+
"Utah": "Salt Lake City",
50+
"Vermont": "Montpelier",
51+
"Virginia": "Richmond",
52+
"Washington": "Olympia",
53+
"West Virginia": "Charleston",
54+
"Wisconsin": "Madison",
55+
"Wyoming": "Cheyenne",
5656
}

0 commit comments

Comments
 (0)