Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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:

  1. Displays the four integers: Done)

print('1 random integers == ', x,' ',y,' ', z, ' ', w )

  1. The maximum integer (use max function)
  2. The minimum integer (use the min function
  3. The number of even integers (if x %2 == 0 then x is even)
  4. The number of odd integers
  5. The number of integers greater than -25 but less than 25 (if -25 < x and x < 25: )
  6. The number of positive integers
  7. The number of negative integers
  8. The average of the smallest and largest integers
  9. The average of all four integers

EXAMPLE OUTPUT

If the random number generator generated the four integers 22 -8 17 -5 then display

  1. The integers are 22 -8 17 -5
  2. The maximum integer is 22
  3. The minimum integer is -8
  4. The number of even integers is 2
  5. The number of odd integers is 2
  6. The number of integers greater than -25 but less than 25 is 4
  7. The number of positive integers 2
  8. The number of negative integers 2
  9. The average of the smallest and largest integers 7.0
  10. The average of the four integers is 6.5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions