Skip to content

Commit 2776d02

Browse files
committed
Black formatting pass
1 parent 87e5465 commit 2776d02

File tree

8 files changed

+73
-17
lines changed

8 files changed

+73
-17
lines changed

ch08-conditional-logic/8-challenge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
total_A_wins = 0
1010
total_B_wins = 0
1111

12-
trials = 100000
12+
trials = 100_000
1313
for trial in range(0, trials):
1414
A_win = 0
1515
B_win = 0

ch08-conditional-logic/9b-challenge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from random import randint
88

99

10-
trials = 100000
10+
trials = 100_000
1111
flips = 0
1212

1313
for trial in range(1, trials):

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

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,33 @@
66

77
from random import choice
88

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"]
9+
noun = [
10+
"fossil",
11+
"horse",
12+
"aardvark",
13+
"judge",
14+
"chef",
15+
"mango",
16+
"extrovert",
17+
"gorilla",
18+
]
19+
verb = [
20+
"kicks",
21+
"jingles",
22+
"bounces",
23+
"slurps",
24+
"meows",
25+
"explodes",
26+
"curdles",
27+
]
28+
adjective = [
29+
"furry",
30+
"balding",
31+
"incredulous",
32+
"fragrant",
33+
"exuberant",
34+
"glistening",
35+
]
1236
preposition = [
1337
"against",
1438
"after",
@@ -21,7 +45,13 @@
2145
"over",
2246
"within",
2347
]
24-
adverb = ["curiously", "extravagantly", "tantalizingly", "furiously", "sensuously"]
48+
adverb = [
49+
"curiously",
50+
"extravagantly",
51+
"tantalizingly",
52+
"furiously",
53+
"sensuously",
54+
]
2555

2656

2757
def make_poem():

ch11-file-input-and-output/2-working-with-paths-in-python.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,19 @@
3333
for current_folder, subfolders, file_names in os.walk(path):
3434
for file_name in file_names:
3535
file_path = os.path.join(current_folder, file_name)
36-
file_tuple = os.path.splitext(file_path) # split into (path, extension)
36+
file_tuple = os.path.splitext(
37+
file_path
38+
) # split into (path, extension)
3739
if file_tuple[1].lower() == ".png": # check if extension is PNG
3840
pass # os.rename(file_path, file_tuple[0] + ".jpg")
3941

4042

4143
# Exercsie 4
4244
# Check that the two files have been converted to JPGs successfully
4345
print(os.path.exists(os.path.join(path, "png file - not a gif.jpg")))
44-
print(os.path.exists(os.path.join(path, "additional files/one last image.jpg")))
46+
print(
47+
os.path.exists(os.path.join(path, "additional files/one last image.jpg"))
48+
)
4549

4650

4751
# Exercise 5

ch11-file-input-and-output/6-challenge.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ def get_arguments():
5353
type=str,
5454
)
5555
parser.add_argument(
56-
"-r", "--row_limit", required=True, help="row limit to split csv at", type=int
56+
"-r",
57+
"--row_limit",
58+
required=True,
59+
help="row limit to split csv at",
60+
type=int,
5761
)
5862
args = parser.parse_args()
5963

ch13-interact-with-pdf-files/1-work-with-the-contents-of-a-pdf-file.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
for page_num in range(1, input_file.getNumPages()):
3737
output_PDF.addPage(input_file.getPage(page_num))
3838

39-
output_file_name = os.path.join(path, "Output/The Whistling Gypsy un-covered.pdf")
39+
output_file_name = os.path.join(
40+
path, "Output/The Whistling Gypsy un-covered.pdf"
41+
)
4042
with open(output_file_name, "wb") as output_file:
4143
output_PDF.write(output_file)

ch14-sql-database-connections/1-use-sqlite.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222

2323
# Exercise 3
2424
# Update the Species of Korben Dallas to "Human"
25-
c.execute("UPDATE Roster SET Species=? WHERE Name=?", ("Human", "Korben Dallas"))
25+
c.execute(
26+
"UPDATE Roster SET Species=? WHERE Name=?", ("Human", "Korben Dallas")
27+
)
2628

2729
# Exercise 4
2830
# Display the names and IQs of everyone classified as Human

ch17-graphical-user-interfaces/2-challenge.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@
1616
total_pages = input_file.getNumPages()
1717

1818
# let the user choose a beginning page
19-
page_start = gui.enterbox("Enter the number of the first page to use:", "Where to begin?")
19+
page_start = gui.enterbox(
20+
"Enter the number of the first page to use:", "Where to begin?"
21+
)
2022
if page_start is None: # exit on "Cancel"
2123
exit()
2224
# check for possible problems and try again:
2325
# 1) input page number isn't a (non-negative) digit
2426
# or 2) input page number is 0
2527
# or 3) page number is greater than total number of pages
26-
while not page_start.isdigit() or page_start == "0" or int(page_start) > total_pages:
28+
while (
29+
not page_start.isdigit()
30+
or page_start == "0"
31+
or int(page_start) > total_pages
32+
):
2733
gui.msgbox("Please provide a valid page number.", "Whoops!")
2834
page_start = gui.enterbox(
2935
"Enter the number of the first page to use:", "Where to begin?"
@@ -32,7 +38,9 @@
3238
exit()
3339

3440
# let the user choose an ending page
35-
page_end = gui.enterbox("Enter the number of the last page to use:", "Where to end?")
41+
page_end = gui.enterbox(
42+
"Enter the number of the last page to use:", "Where to end?"
43+
)
3644
if page_end is None: # exit on "Cancel"
3745
exit()
3846
# check for possible problems and try again:
@@ -47,15 +55,21 @@
4755
or int(page_end) < int(page_start)
4856
):
4957
gui.msgbox("Please provide a valid page number.", "Whoops!")
50-
page_end = gui.enterbox("Enter the number of the last page to use:", "Where to end?")
58+
page_end = gui.enterbox(
59+
"Enter the number of the last page to use:", "Where to end?"
60+
)
5161
if page_end is None: # exit on "Cancel"
5262
exit()
5363

5464
# let the user choose an output file name
5565
output_file_name = gui.filesavebox("", "Save the trimmed PDF as...", "*.pdf")
5666
while input_file_name == output_file_name: # cannot use same file as input
57-
gui.msgbox("Cannot overwrite original file!", "Please choose another file...")
58-
output_file_name = gui.filesavebox("", "Save the trimmed PDF as...", "*.pdf")
67+
gui.msgbox(
68+
"Cannot overwrite original file!", "Please choose another file..."
69+
)
70+
output_file_name = gui.filesavebox(
71+
"", "Save the trimmed PDF as...", "*.pdf"
72+
)
5973
if output_file_name is None:
6074
exit() # exit on "Cancel"
6175

0 commit comments

Comments
 (0)