Question
(x = random.randint(a,b) ) write a program that generates four integers between -50 and +50 and displays the calculations noted below. See the following code
(x = random.randint(a,b) ) write a program that generates four integers between -50 and +50 and displays the calculations noted below. See the following code (modify as needed)
import random a = -50 b = 50
x = random.randint(a,b) # returns an integer a <= x <= b
y = random.randint(a,b) # returns an integer a <= y <= b
z = random.randint(a,b) # returns an integer a <= z <= b
w = random.randint(a,b) # returns an integer a <= w <= b
Calculations/Display:
- Displays the four integers: Done)
print('1 random integers == ', x,' ',y,' ', z, ' ', w )
- The maximum integer (use max function)
- The minimum integer (use the min function
- The number of even integers (if x %2 == 0 then x is even)
- The number of odd integers
- The number of integers greater than -25 but less than 25 (if -25 < x and x < 25: )
- The number of positive integers
- The number of negative integers
- The average of the smallest and largest integers
- The average of all four integers
EXAMPLE OUTPUT
If the random number generator generated the four integers 22 -8 17 -5 then display
- The integers are 22 -8 17 -5
- The maximum integer is 22
- The minimum integer is -8
- The number of even integers is 2
- The number of odd integers is 2
- The number of integers greater than -25 but less than 25 is 4
- The number of positive integers 2
- The number of negative integers 2
- The average of the smallest and largest integers 7.0
- The average of the four integers is 6.5
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started