Here is the completed code to solve the problem:
import random
random.seed(61)
x = random.randint(14, 25)
if 10 <= x <= 20:
x = x + 5
else:
x = x - 3
print(x)
Explanation:
random
module and seed the random number generator for consistent results.x
between 14 and 25 (inclusive). Note that the original code specified randint(14, 25), which is fine.if
statement with a combined condition 10 <= x <= 20
to check if x
falls within the range [10, 20].x
is between 10 and 20), we increase x
by 5: x = x + 5
.else
), we decrease x
by 3: x = x - 3
.x
.