looking for a simple python script with an explanation of how -(for loops) work. provide code and explanation using requirements below,. Write a program that prints all the factors of a given number and checks whether it is a prime number. The program Asks user for a positive number strictly between 1 and 5000 (both exclusive). Validates that the number is within the range, if not, prompts the user to enter the number again, until user enters a valid number. Prints all the factors, and the total count of factors. (Using either a for loop or a while loop, checks all the numbers less than the input number to see if it is a factor. A number k is a factor of n if n % k == 0 ). Next checks and reports whether the input number is a prime number. ( A prime number is only divisible by two factors : 1 and itself)

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter8: Advanced Data Handling Concepts
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question
thumb_down
Step 1

looking for a simple python script with an explanation of how -(for loops) work.

provide code and explanation using requirements below,.

Write a program that prints all the factors of a given number and checks whether it is a prime number. The program

  1. Asks user for a positive number strictly between 1 and 5000 (both exclusive).
  2. Validates that the number is within the range, if not, prompts the user to enter the number again, until user enters a valid number.
  3. Prints all the factors, and the total count of factors. (Using either a for loop or a while loop, checks all the numbers less than the input number to see if it is a factor. A number k is a factor of n if n % k == 0 ).
  4. Next checks and reports whether the input number is a prime number. ( A prime number is only divisible by two factors : 1 and itself)
e Python 3.6.3 Shell
Eile Edit Shell Debug Options Window Help
Welcome to the Prime Number Checker
Please enter an integer between 1 and 5000: -5
Invalid integer. Please try again.
Please enter an integer between 1 and 5000: 24
Factors: 1 2 3 4 68 12 24
It has 8 factors.
24 is NOT a prime number.
Bye!
>>>
Ln: 106 Col: 4
Transcribed Image Text:e Python 3.6.3 Shell Eile Edit Shell Debug Options Window Help Welcome to the Prime Number Checker Please enter an integer between 1 and 5000: -5 Invalid integer. Please try again. Please enter an integer between 1 and 5000: 24 Factors: 1 2 3 4 68 12 24 It has 8 factors. 24 is NOT a prime number. Bye! >>> Ln: 106 Col: 4
a Python 3.6.3 Shell
File Edit Shell Debug Options Window Help
Welcome to the Prime Number Checker
Please enter an integer between 1 and 5000: 17
Factors: 1 17
It has 2 factors.
17 is a prime number.
Bye!
>>> |
Ln: 116 Col:
X
Transcribed Image Text:a Python 3.6.3 Shell File Edit Shell Debug Options Window Help Welcome to the Prime Number Checker Please enter an integer between 1 and 5000: 17 Factors: 1 17 It has 2 factors. 17 is a prime number. Bye! >>> | Ln: 116 Col: X
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Operators
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT