Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed
image text in transcribed
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.jps How Many Prime Numbers within a Range of 1 to M ? (Embedded for Loops: Inner/ Outer) In a well-commented Python program hrmwk2Q4.py, extend the solution provided in Question 3 to determine it the number of prime numbers between 1 and M. Include a screen capture Hmwk2Q4.jpg for the test case below. Number of Primes Between 2 and M Enter an integer: 1000 168 Hmwk2Q4.jpg Hints: 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 inder 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 cuter loop is executed. 7. The counter is incremented INSIDE the OUTER loop when the INNER LOOP determines that N is prime Factors of an Integer (Using If Statements) In a well-commented Python program hmwk2Q2.py, ask the user to provide an integer N using the built-in input function. Form a list of the respective factors as shown below and have your program print the list. The convention is NOT to include the integer itself in the enumerated factors list. Include a screen capture Hmwk2Q2..jpg for the test case below. Factors of a Number Program Enter an integer: 14043 [1,3,31,93,151,453,4681] Hints: 1. Repetition is used to test the integers from 1 to N1. (USE A FOR LOOP) 2. If the nth integer is a factor, then the list is appended. (USE AN IF-STATEMENT) 3. The modulo operator % is a useful operator to consider in the logical test. 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

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

Temporal Databases Research And Practice Lncs 1399

Authors: Opher Etzion ,Sushil Jajodia ,Suryanarayana Sripada

1st Edition

3540645195, 978-3540645191

More Books

Students also viewed these Databases questions

Question

Define Scientific Management

Answered: 1 week ago

Question

Explain budgetary Control

Answered: 1 week ago

Question

Solve the integral:

Answered: 1 week ago

Question

What is meant by Non-programmed decision?

Answered: 1 week ago

Question

What is the preferred personality?

Answered: 1 week ago