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

You want to discard your old computer and want to securely erase the data from your hard drive. What can you use to do this and what is the process called?
You have been given the task of transporting 3,000 apples 1,000 miles from Appleland to Bananaville. Your truck can carry 1,000 apples at a time. Every time you
Which of the following was true of the Know-Nothing party? A. It wanted to undermine immigrant voting strength. B. It rejected nativism. C. It gained the wides
60 minutes is 20% of how many minutes
$64 jacket; 20% discount find sale price to the nearest cent show work
NEED HELP ASAP PLEEEASE :( I need to write an equation for this: Train A leaves a station at 8:00 and travels at 100 km per hour towards the next city.  One and
Write the next 3 terms in each pattern 1, 5, 25, 125, …
360 kilometers is is 24% of how many kilometers
3 15/16 divided by 2 5/8Ask your question here
what is the protagonist in the book if I stay