0
0
Intro to Computingfundamentals~10 mins

How images are stored (pixels, resolution) in Intro to Computing - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a pixel grid with 3 rows and 3 columns.

Intro to Computing
pixels = [[0 for _ in range([1])] for _ in range(3)]
Drag options to blanks, or click blank then click option'
A3
B5
C1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 or 1 instead of 3 for the number of columns.
Confusing rows and columns in the loops.
2fill in blank
medium

Complete the code to calculate the total number of pixels in an image with width 1920 and height 1080.

Intro to Computing
total_pixels = 1920 [1] 1080
Drag options to blanks, or click blank then click option'
A+
B*
C-
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Adding width and height instead of multiplying.
Dividing or subtracting width and height.
3fill in blank
medium

Fix the error in the code to access the pixel at row 2, column 3 in a 2D pixel list.

Intro to Computing
pixel_value = pixels[[1]][2]
Drag options to blanks, or click blank then click option'
A1
B3
C2
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 2 or 3 as index which is out of range.
Confusing row and column indices.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps pixel coordinates to their brightness if brightness is greater than 100.

Intro to Computing
bright_pixels = {(x, y): pixels[x][y] for x in range([1]) for y in range([2]) if pixels[x][y] > 100}
Drag options to blanks, or click blank then click option'
Awidth
Bheight
C256
D100
Attempts:
3 left
💡 Hint
Common Mistakes
Using fixed numbers instead of variables for dimensions.
Confusing width and height in the loops.
5fill in blank
hard

Fill all three blanks to create a dictionary that stores pixel brightness for pixels with brightness above 150.

Intro to Computing
bright_pixels = { [1]: pixels[[2]][[3]] for [2] in range(height) for [3] in range(width) if pixels[[2]][[3]] > 150 }
Drag options to blanks, or click blank then click option'
A(x, y)
Bx
Cy
D(x.upper(), y.upper())
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase keys incorrectly.
Mixing up x and y in loops.