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

Ms.Holmes decided to water her plants.She had 2 1/2 gallons of water.She gave each plant 1/4 gallon of water.Which expression could be used to determine how man
Look at the graph below: First line joins ordered pairs negative 4, 3 and 2, negative 3. Second line joins negative 4, negative 3 and 2, 3. Part A shaded abov
If l ll m, what is the value of x?​
In this assignment, you will write an argumentative essay defending a claim about the character of Dr. Jekyll
What is a CFO and their responsibilities to the company?
To the nearest hundredth of a centimeter, what is the length of a leg of the triangle?
In line 108-120, what is hurston saying about bags? What does she mean? What is she saying about people?
49. The potential energy of a spring is 0.3 J when it is compressed 0.04 m to the left of its equilibrium position. At thispoint it comes to its leftmost positi
Darren filled boxes with tins of orange juice and numbered the boxes in the order in which they were filled. He packed the 496th tin box 21 and then stopped for
What's the major differences between modern audiences and audiences during Shakespeare's time