Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This Question no 4 is related to 3 so I am posting 3 as well. Question 4 (20 Points) How Many Prime Numbers within a

image text in transcribedThis Question no 4 is related to 3 so I am posting 3 as well.
image text in transcribed
Question 4 (20 Points) How Many Prime Numbers within a range of 1 to M? (Embedded For Loops: Inner/Outer) In a well-commented Python program hmwk2Q4.py, extend the solution provided in Question 3 to determine if the number of prime numbers between 1 and M. Include a screen capture Hmwk204.jpg for the test case below. Hints: Number of Primes Between 2 and M Enter an integer: 1000 168 Hmwk204.jpg 1. Question 3 provides a test if a single integer N is prime or not. 2. Remove the input function to query the user for the integer N. 3. Embed (i.e. intent) the code for the single integer test in an outer for loop that uses N as the index variable 4. The outer for loop has the limits for N in range(1, M+1):, where M is the value supplied by the user 5. M is defined before the outer loop is executed 6. A counter of the number primes is initialized to zero before the outer loop is executed. 7. The counter is incremented INSIDE the OUTER loop when the INNER LOOP determines that N is prime Grading: 2 points for comments, 2 points for obtaining M, the upper limit of the prime number test from a user, 8 points for the correct OUTER LOOP, 2 points for initiating the counter, 2 points for incrementing the count, 2 points for implementing the correct INNER LOOP (extending Hmwk203.py) and 2 points for Hmwk204.jpg. Question 3 (10 Points) Prime Number In a well-commented Python program hmwk2Q3.py, extend the solution provided in Question 2 to determine if the integer N is a prime number. Include a screen capture Hmwk2Q3.jpg for the test case below Is The Integer Prime ? Enter an integer: 7919 7919 is Prime Hmwk2Q3.jpg Grading: 2 points for comments, 2 points for a correct logical test to determine if number is prime from the list of the factors (no need to display the list), 4 points for extending code from Hmwk2Q2.py, and 2 points for Hmwk203.jpg

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

Step: 3

blur-text-image

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

Modern Database Management

Authors: Heikki Topi, Jeffrey A Hoffer, Ramesh Venkataraman

13th Edition

0134773659, 978-0134773650

More Books

Students also viewed these Databases questions

Question

what is a peer Group? Importance?

Answered: 1 week ago

Question

Question Can life insurance be used in a Keogh (HR 10) plan?

Answered: 1 week ago