Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Python range code

Practice constructing ascending and descending ranges, testing membership, and slicing range sequences.

Beginner ~6 min read

Challenge 1

Create an arithmetic progression from 2 through 10 by twos.

python Your answer
values = range()
print(list(values))

Press Ctrl⌘Enter to check your answer

Challenge 2

Create a descending range from 9 to 1 by ones.

python Your answer
values = range()
print(list(values))

Press Ctrl⌘Enter to check your answer

Challenge 3

Check whether 14 belongs to the even-number range.

python Your answer
evens = range(0, 20, 2)
found = 14  evens
print(found)

Press Ctrl⌘Enter to check your answer

Challenge 4

Take the middle three values from the range.

python Your answer
values = range(0, 12, 2)
middle = values[]
print(list(middle))

Press Ctrl⌘Enter to check your answer