jojovill6416 jojovill6416
  • 16-11-2020
  • Computers and Technology
contestada

Write code that generates a random odd integer (not divisible by 2) between 50 and 99 inclusive.

Respuesta :

Cytokine
Cytokine Cytokine
  • 16-11-2020

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.

Answer Link

Otras preguntas

Katie Clean invited Messy Missy to her house to work on their biology project, but Katie Clean had no idea what a visit from Messy Missy entailed. First of all,
We're the sons of liberty justified in their treatment of the loyalists
After the American Civil War, Andrew Jackson brokered an agreement to allow _______ back into the Union. A. The south B. the south C. The South D. the South
The area of the base of a prism is 21 cm2. The perimeter of the base is 20 cm. The height of the prism is 8 cm. What is the surface area of the prism? _____ cm2
What prevented computers from having an impact on everyday life in the 1950s? (Points : 3) Business demand was so high that they were not available for personal
when was James Somerset born?
Are there still emperors today? If so, where?
We're the sons of liberty justified in their treatment of the loyalists
1. Joleen bought 12 apples. Each apple weighed 1.8 ounces. How many pounds of apples did Joleen buy? 2. 1/4, 1/25, 1/400, 1/2500 What one is equivalent to 0.04%
What is the smallest country on the Horn of Africa?