Write code that generates a random odd integer (not divisible by 2) between 50 and 99 inclusive.
Answers
Answer 1
import random
nums = [x for x in range(50,100) if x%2!=0]
print(random.choice(nums))
We use a list comprehension to create a list of the odd numbers between 50 and 99. Then we randomly choose one of those numbers using the random module.