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

If you started at 4 on the number line and moved to -9 , how far and in which direction would you need to move?
(6)A population begins at 42 individuals,climbs to 122 individuals and then levels off. This trend best illustrates which of the following? A) Biodiversity B)
how do i solve this i’m so lost and i’m literally failing this class any help is greatly appreciated thank you.
What hypothesis is Robert trying to investigate
i don’t understand ..
she has got..........unique computer.(a,an,the)
why did admiral leahy feel the use of the bomb was ethically and morally incorrect
A rock formed with 1,000 atoms of a radioactive parent element, but only contains 12.5% of its original radioactive parent atoms today. if the half-life is 1,00
The temperature of lake water over a period of time is shown in the graph below. The first temperature is recorded at 9 p.m. At what time is the water at its lo
Need help with this ASAP PLZ