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 48 feet are represented by 12 inches on a scale drawing, then a scale of 1/4 inch represents how many feet? a. 3 foot c. 2 foot b. 4 foot d. 1 foot
Please help i am very confused on how to solve sqrt 12/ sqrt 24 Plese help
I NEED HELP PLEASE 1. __________ is formal disapproval of a Senate or House member’s actions. Gerrymandering Expulsion Franking privilege Censure 7. A commutati
What is the common difference in the following arithmetic sequence? 12, 6, 0, -6, ... 6 -6 -2
Which of the following best describes a Topographic Map? A. A map showing restaurants, malls and major attractions for a city B. A map that shows elevation
Why do normal t cells, which recognize foreign peptide antigens bound to self mhc molecules, react strongly against the allogeneic mhc molecules of a graft?
What percentages of atoms are heavier than hydrogen and helieum?
The Yangtze River flows into which body of water?
Should the United States' executive and legislative branches act to promote and increase global free trade? Why or why not?
how do you write 281% as a decimal