Skip to content

Commit fcc5a20

Browse files
committed
Fix code style issues with Black
1 parent 8dddaf1 commit fcc5a20

File tree

8 files changed

+53
-57
lines changed

8 files changed

+53
-57
lines changed

1_beginner/chapter3/solutions/temperature.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Temperature
1+
# Temperature
22
# Write a program that converts Celsius to Fahrenheit.
33
# It should ask the user for the temperature in
44
# degrees Celsius and then print the temperature in degrees Fahrenheit.

1_beginner/chapter5/practice/add_all_the_way.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@
77
# write code here
88

99

10-
11-
12-
#Try using the other loop and do the same p[roblem again
10+
# Try using the other loop and do the same p[roblem again

1_beginner/chapter5/practice/alternating.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
1010
"""
1111

12-
#Write code here.
12+
# Write code here.
1313

1414
number = int(input("Enter Number Here: "))
1515

1616

17-
#Now try it with a while loop
17+
# Now try it with a while loop

1_beginner/chapter5/practice/fibonnaci.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
''' CHALLENGE PROBLEM!! NOT FOR THE FAINT OF HEART!
1+
""" CHALLENGE PROBLEM!! NOT FOR THE FAINT OF HEART!
22
33
The Fibonacci numbers, discovered by Leonardo di Fibonacci,
44
is a sequence of numbers that often shows up in mathematics and,
@@ -12,9 +12,9 @@
1212
1313
The challenge is to use a for loop (not recursion, if you know what that is),
1414
to find the 100th Fibonnaci number.
15-
'''
15+
"""
1616

17-
#write code here
17+
# write code here
1818

1919

20-
#Can you do it with a while loop?
20+
# Can you do it with a while loop?

1_beginner/chapter5/practice/prime.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
"""
1111

12-
#write code here
12+
# write code here
1313

1414
numer = int(input("Enter number here: "))
1515

@@ -25,4 +25,4 @@
2525
2626
"""
2727

28-
#write code here
28+
# write code here

1_beginner/chapter5/practice/series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
Also, try adding up 1 -1/3 + 1/5 - 1/7 + 1/9 - 1/11 ... 10 million times. then
1414
multiply this result by 4. What number is this close to?
1515
16-
"""
16+
"""

2_intermediate/chapter10/practice/img_avg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@
3737
plt.imshow(img)
3838
plt.show()
3939

40-
#write code to create newimg here
40+
# write code to create newimg here
4141

4242
plt.imshow(newimg)
4343
plt.show()
4444

4545
plt.imshow(transpose)
46-
plt.show()
46+
plt.show()

2_intermediate/chapter10/solutions/img_avg.py

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -35,50 +35,48 @@
3535
transpose = numpy.transpose(img)
3636

3737

38-
#write code to create newimg here
38+
# write code to create newimg here
3939
def solution1():
40-
"""Iterating over the image here. i is a variable from 0 to the width of the image.
40+
"""Iterating over the image here. i is a variable from 0 to the width of the image.
4141
j is a variable that ranges from 0 to the height of the image. i is associated with
4242
values"""
43-
for i in range(len(img)):
44-
for j in range(len(img[0])):
45-
x_n = [0]
46-
y_n = [0]
47-
48-
if(i == 0):
49-
x_n.append(1)
50-
elif(i == len(img)-1):
51-
x_n.append(-1)
52-
else:
53-
x_n.append(1)
54-
x_n.append(-1)
55-
56-
if(j == 0):
57-
y_n.append(1)
58-
elif(j == len(img[0])-1):
59-
y_n.append(-1)
60-
else:
61-
y_n.append(1)
62-
y_n.append(-1)
63-
64-
r_avg = -1*img[i][j][0]
65-
g_avg = -1*img[i][j][1]
66-
b_avg = -1*img[i][j][2]
67-
c = -1
68-
69-
for x in x_n:
70-
for y in y_n:
71-
r_avg += img[i+x][j+y][0]
72-
g_avg += img[i+x][j+y][1]
73-
b_avg += img[i+x][j+y][2]
74-
c+=1
75-
r_avg = r_avg/c
76-
g_avg = g_avg/c
77-
b_avg = b_avg/c
78-
79-
newimg[i][j] = [r_avg, g_avg, b_avg]
80-
81-
43+
for i in range(len(img)):
44+
for j in range(len(img[0])):
45+
x_n = [0]
46+
y_n = [0]
47+
48+
if i == 0:
49+
x_n.append(1)
50+
elif i == len(img) - 1:
51+
x_n.append(-1)
52+
else:
53+
x_n.append(1)
54+
x_n.append(-1)
55+
56+
if j == 0:
57+
y_n.append(1)
58+
elif j == len(img[0]) - 1:
59+
y_n.append(-1)
60+
else:
61+
y_n.append(1)
62+
y_n.append(-1)
63+
64+
r_avg = -1 * img[i][j][0]
65+
g_avg = -1 * img[i][j][1]
66+
b_avg = -1 * img[i][j][2]
67+
c = -1
68+
69+
for x in x_n:
70+
for y in y_n:
71+
r_avg += img[i + x][j + y][0]
72+
g_avg += img[i + x][j + y][1]
73+
b_avg += img[i + x][j + y][2]
74+
c += 1
75+
r_avg = r_avg / c
76+
g_avg = g_avg / c
77+
b_avg = b_avg / c
78+
79+
newimg[i][j] = [r_avg, g_avg, b_avg]
8280

8381

8482
solution1()
@@ -87,4 +85,4 @@ def solution1():
8785
plt.show()
8886

8987
plt.imshow(transpose)
90-
plt.show()
88+
plt.show()

0 commit comments

Comments
 (0)