simple python script with an explanation of how -(for loops) work. provide code and explanation, please 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

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
icon
Concept explainers
Question
100%

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

provide code and explanation, please

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).
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
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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 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
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