Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 1_beginner/chapter5/practice/alternating.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""
Alternating
"""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W291: trailing whitespace

Ask the user for an integer. The print the numbers from 1 to that number,
but alternating in sign. For example, if the input was 5, what would be printed
is 1, -1, 2, -2, 3, -3, 4, -4, 5. (Note, DO NOT include the last negative
number).
Do this with a for loop
"""

# Write code here.
Expand Down
24 changes: 10 additions & 14 deletions 2_intermediate/chapter10/practice/img_avg.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
"""
Image Average
Here is the challenge problem for 2D loops:
Images are often represented as 3D arrays,
""" Here is the challenge problem for 2d loops>
Images are often represented as 3d arrays,
where the rows and columns are the pixels in the image,
and each pixel has an RGB (red, green, blue) value
which determines the color of the pixel.
and each pixel has an r, g, and b value.
The interesting thing is that we can iterate over images.
The challenge is, given an image, create a program that
will return a different image where each pixel is the average
of the pixels surrounding it in the original image.
The neighbors of an image are all the pixels that surround it,
1 on each side, and 4 on the diagonals, for 8 in total. Each
pixel doesn't necessarily have 8 neighbors, though (think about why).
The neighbors of an image are all the pixels that surroun it,
1 on each side, and 4 on the diagonals, for 8 in total.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W291: trailing whitespace

Each pixel doesn't necessarily have 8 neighbors, though (think about why)
The code to grab an image from the internet and make it
into an array is given to you. The code also displays the new image
you create in the end.
NOTE: The image is 3 dimensional because each pixel has RGB values.
NOTE: The image is 3 dimensional because each pixel has rgb values.
To find the average value of all of a pixels neighbors, you must
change the average of the red value to the red value, blue to blue, etc.
For example, if the neighbors of a pixel with value [1, 2, 3]
were [20, 30, 40] and [10, 120, 30], the new pixel that would replace the
original one would be [15, 75, 35]
For example, if the neighbors of a pixel with value [1,2,3]
were [20,30,40] and [10,120,30], the new pixel that would replace the original one would be
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E501: line too long (91 > 79 characters)

[15,75,35]
"""

from PIL import Image
Expand Down
11 changes: 0 additions & 11 deletions 2_intermediate/chapter10/practice/odd_sum.py

This file was deleted.

9 changes: 0 additions & 9 deletions 2_intermediate/chapter10/practice/smooth_max.py

This file was deleted.

33 changes: 13 additions & 20 deletions 2_intermediate/chapter10/solutions/img_avg.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
"""
Image Average
Here is the challenge problem for 2D loops:
Images are often represented as 3D arrays,
""" Here is the challenge problem for 2d loops>
Images are often represented as 3d arrays,
where the rows and columns are the pixels in the image,
and each pixel has an RGB (red, green, blue) value
which determines the color of the pixel.
and each pixel has an r, g, and b value.
The interesting thing is that we can iterate over images.
The challenge is, given an image, create a program that
will return a different image where each pixel is the average
of the pixels surrounding it in the original image.
The neighbors of an image are all the pixels that surround it,
1 on each side, and 4 on the diagonals, for 8 in total. Each
pixel doesn't necessarily have 8 neighbors, though (think about why).
The neighbors of an image are all the pixels that surroun it,
1 on each side, and 4 on the diagonals, for 8 in total.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W291: trailing whitespace

Each pixel doesn't necessarily have 8 neighbors, though (think about why)
The code to grab an image from the internet and make it
into an array is given to you. The code also displays the new image
you create in the end.
NOTE: The image is 3 dimensional because each pixel has RGB values.
NOTE: The image is 3 dimensional because each pixel has rgb values.
To find the average value of all of a pixels neighbors, you must
change the average of the red value to the red value, blue to blue, etc.
For example, if the neighbors of a pixel with value [1, 2, 3]
were [20, 30, 40] and [10, 120, 30], the new pixel that would replace the
original one would be [15, 75, 35]
For example, if the neighbors of a pixel with value [1,2,3]
were [20,30,40] and [10,120,30], the new pixel that would replace the original one would be
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E501: line too long (91 > 79 characters)

[15,75,35]
"""

from PIL import Image
Expand All @@ -41,12 +37,9 @@

# write code to create newimg here
def solution1():
"""
Iterating over the image here. i is a variable from
0 to the width of the image.
j is a variable that ranges from 0 to the height of the image.
i is associated with values
"""
"""Iterating over the image here. i is a variable from 0 to the width of the image.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E501: line too long (83 > 79 characters)

j is a variable that ranges from 0 to the height of the image. i is associated with
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W191: indentation contains tabs

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E101: indentation contains mixed spaces and tabs

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E501: line too long (84 > 79 characters)

values"""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W191: indentation contains tabs

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E101: indentation contains mixed spaces and tabs

for i in range(len(img)):
for j in range(len(img[0])):
x_n = [0]
Expand Down
22 changes: 0 additions & 22 deletions 2_intermediate/chapter10/solutions/odd_sum.py

This file was deleted.

20 changes: 0 additions & 20 deletions 2_intermediate/chapter10/solutions/smooth_max.py

This file was deleted.