8.6 Code Practice: Question 1
Write a function named buildArray that builds an array by appending a given number of random two-digit integers (10-99). It should accept two parameters — the first parameter is the array, and the second is an integer for how many random values to add, which should be input by the user.

Print the array after calling buildArray

86 Code Practice Question 1 Write a function named buildArray that builds an array by appending a given number of random twodigit integers 1099 It should accept class=

Respuesta :

In python 3.8:

import random

def buildArray(arr, nums):

   i = 0

   while i < nums:

       arr.append(random.randint(10,99))

       i+=1

arr = []

numbers = int(input("How many values to add to the array:\n"))

buildArray(arr, numbers)

print(arr)

I hope this helps!

The function named buildArray that builds an array by appending a given number of random two-digit integers (10-99) and accept 2 parameters is represented below

import random  

def buildArray(array, integer):

   i = 0

   while i < integer:

       array.append(random.randint(10, 99))

       i += 1

   return array

print(buildArray([], 12))

The code is written in python.

A function is declared called buildArray. This function accept 2 parameters which are arrays and integer.

i is use to declare a variable assigned to zero.

while i is less than the integer(one of the parameter), random number between 10 and 99 is appended to the parameter array.

The value of i keeps on increasing until it becomes less than the integer.

The filled array is returned.

Finally, we call the function with the required parameters.

The bolded portion of the code are keywords in python.  

read more: https://brainly.com/question/18612252?referrer=searchResults

Ver imagen vintechnology
ACCESS MORE