Find primes This program creates and displays a 5x10 matrix(5 rows and 10 columns) of random integers between 1 and a maximum value(user input). Hint: Use the random library to generate each number and place it into your 2D list. The program then counts the number of prime numbers in each row of the array and displays this number, along with the found primes. The program finally displays the total number of prime numbers in the matrix.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Find primes

This program creates and displays a 5x10 matrix(5 rows and 10 columns) of random integers between 1 and a maximum value(user input).

Hint: Use the random library to generate each number and place it into your 2D list.

The program then counts the number of prime numbers in each row of the array and displays this number, along with the found primes.

The program finally displays the total number of prime numbers in the matrix.

Expected program behavior:
The values of our random matrix are:
[[12 39 25 29
2 11 41 47 41 27]
[ 6 18 22
6 34 40 48 47 41]
[28 12 28 40 20
2 10
3 39
9]
[28 22 26 24 44 34 48 19
2 26]
[34 47 35 10 35 14 18 23 14 38]]
Row 1 has 6 prime values: [29, 2, 11, 41, 47, 41]
Row 2 has 2 prime values: [47, 41]
Row 3 has 2 prime values: [2, 3]
Row 4 has 2 prime values: [19, 2]
Row 5 has 2 prime values: [47, 23]
There are a total of 14 prime numbers.
Transcribed Image Text:Expected program behavior: The values of our random matrix are: [[12 39 25 29 2 11 41 47 41 27] [ 6 18 22 6 34 40 48 47 41] [28 12 28 40 20 2 10 3 39 9] [28 22 26 24 44 34 48 19 2 26] [34 47 35 10 35 14 18 23 14 38]] Row 1 has 6 prime values: [29, 2, 11, 41, 47, 41] Row 2 has 2 prime values: [47, 41] Row 3 has 2 prime values: [2, 3] Row 4 has 2 prime values: [19, 2] Row 5 has 2 prime values: [47, 23] There are a total of 14 prime numbers.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education