1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
postnew [5]
3 years ago
13

9.3 Code Practice

Computers and Technology
2 answers:
Softa [21]3 years ago
7 0

Answer:

import random

numbers = []

for r in range (4):

   numbers.append([])

for r in range(len(numbers)):

   for c in range(5):

       numbers[r].append(random.randint(-30,30))

for r in range(len(numbers)):

   for c in range (len(numbers[0])):

       print((numbers[r][c]), end = " ")

   print("")

Explanation:

ok

julsineya [31]3 years ago
5 0

Answer:

import random

def grid_maker(x, y):

   return [ [str(random.randint(-30, 30)) for _ in range(x)]for _ in range(y) ]

print ('\n'.join(' '.join(row) for row in grid_maker(4, 5)))

Explanation:

We use a template function and we generate numbers between -30 and 30:

>>> [str(random.randint(-30, 30))]

We also use the str() method so we can later concatenate the integers with \n. If you do not specify the integers, it will cause a crash. Also, keep in mind if we use a variable to store the integers, it will come out more of like a seed than a random grid. For instance, output without the random integers in a variable:

-12 16 -18 -3

7 5 7 10

18 -21 -16 29

21 3 -4 10

12 9 6 -9

Vs with a variable:

-25 6 -25 -20

-25 6 -25 -20

-25 6 -25 -20

-25 6 -25 -20

-25 6 -25 -20

Next we specify the  x and the y:

>>> for _ in range(x)]for _ in range(y) ]

Next we just print it and create a new line every time a row is made

hope this helped :D

You might be interested in
Which of the following are wise entrepreneurial decisions or concepts? Check all of the boxes that apply.
Artyom0805 [142]

Answer:

a b e d f

Explanation:

8 0
3 years ago
Read 2 more answers
Variable costs are __________.<br><br> A. decreasing<br> B. increasing<br> C. static
lubasha [3.4K]
The answer is A. Decreasing
5 0
3 years ago
Complete the following method named replaceEvens that receives the parameter numbers which is an array of integers. The method m
Taya2010 [7]

Answer:

Following are the method definition to this question:

public class Neg //defining class Neg

{  

public static void replaceEvens(int[] numbers) //defining a method replaceEvens that accepts array

{

int i; //defining integer variable

for(i = 0 ; i < numbers.length; i++) //defining foop to counts number

{

if(numbers[i]%2 == 0) //defining condition to check number is even  

{

numbers[i] = numbers[i] * -1; //multiply the number by -1

}

}

for(i = 0 ; i < numbers.length; i++) // defining loop print array

{

System.out.print(numbers[i] + " "); //print array

}

}    

public static void main(String[] as)//defining main method  

{

   int[] numbers = {12, 10, 18, 5, 2,22}; //defining array numbers and assign value

   System.out.println("Elements of array: "); //print message

   for(int i = 0 ; i < numbers.length ; i++)  //defining loop to print message

   {

   System.out.print(numbers[i] + " "); //print array

   }

  System.out.println("\n After replaceEvens"); //print message

   replaceEvens(numbers); //calling method replaceEvens

  }

}

Output:

please find the attachment.

Explanation:

  • In the given program a static method replaceEvens is declared, in which array numbers pass as the parameter, inside the for method loop is declared, which counts array number in this loop if block is defined, that check-in array there is an even number.
  • In the condition is true it will multiply the number by -1, and output side the loop it will define another loop to print its value.
  • Inside the main method, a number array is declared, that first prints its value then call the method to print its change value.    

3 0
3 years ago
Suppose one hundred stores participated in the
Sindrei [870]
I think the answer is A
7 0
4 years ago
Graphic designers sometimes must adjust the spacing between letters so that the result looks right to them. This is called
joja [24]
<span>B. optical spacing. Because they want to look right to them and only issue is their eyes, so answer is B.</span>
3 0
4 years ago
Other questions:
  • 1. Why isn't solar energy usually the only power source for a region?
    10·2 answers
  • Which piston stroke of the four-stroke cycle prepares the fuel mixture for combustion??
    8·1 answer
  • Write an application that solicits and inputs three integers from the user and then displays the sum, average, product, smallest
    12·1 answer
  • What application can be used to set windows 8 to boot into safe mode while still in windows?
    15·1 answer
  • What type of program installs and gathers personal information, including password and account information, from a computer with
    9·1 answer
  • A company wants to inform a select list of it's regular customers about a flash sale. Which type of platform will it use to send
    9·1 answer
  • Tom is trapped on the top floor of a department store. It’s just before Christmas
    13·2 answers
  • What percentage of teens say they have witnessed cyberbullying?
    6·2 answers
  • What is the advantage of learning through story compared to learning through personal experience?
    15·2 answers
  • A database program helps to ____________. A. Organize, send, and retrieve e-mails quickly b. Deliver elegant presentations to a
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!