Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help writing a python program . Problem Description: Write a program that takes in Integer inputs from the user, then analyzes the Integer then determines
Help writing a python program
. Problem Description: Write a program that takes in Integer inputs from the user, then analyzes the Integer then determines the following: If the Integer is a prime number The factors of the Integer The sum of the Integer's factors The program will continue to loop, prompting the user for Integers and terminating only when the sum of an Integer's factors is greater than 500. (see examples) . Part 2: Organize lab2-2.py using comments Below your program header, enter additional comments in your Python program identifying each part. Make sure to leave blank spaces between each comment section. This is an important programming practice and is included in your assignment score. Part 3: Write the factors () function Write a Python function factors () that accepts an Integer parameter and returns a List. The factors() function calculates and stores all the factors of the number in the List before returning it. >>> factors (2) (1, 2) >>> factors (1) (1) >>> factors (10) (1, 2, 5, 10 ] Part 4: Complete the main() function The main() function should complete the following tasks: . Display the description of the program factors() function examples Initialize any necessary variables Using a while loop, repeat until the sum of the factors exceeds 500 Prompt the user for an Integer input Determine and display the factors of the Integer Determine if the Integer is prime and display the results Calculate and display the sum of the Integer's factors Example Input/Output Enter the number: 1 Factors: 1 1 is neither prime nor composite Running sum of factors is: 1 Enter the number: 2 Factors: 1 2 2 is a prime number. Running sum of factors is: 4 Enter the number: 5 Factors: 15 15 is a prime number. Running sum of factors is: 10 Enter the number: 67 Factors: 1 67 67 is a prime number. Running sum of factors is: 78 Enter the number: 99 Factors: 1 3 9 11 33 99 99 is not a prime number Running sum of factors is: 234 Enter the number: 250 Factors: 1 2 5 10 25 50 125 250 250 is not a prime number. Running sum of factors is: 702 Enter the number: 100 Factors: 1 2 4 5 10 20 25 50 100 100 is not a prime number. Running sum of factors is: 217 Enter the number: 39 Factors: 1 3 13 39 39 is not a prime number. Running sum of factors is: 273 Enter the number: 89 Factors: 1 89 89 is a prime number. Running sum of factors is: 363 Enter the number: 17 Factors: 1 17 17 is a prime number. Running sum of factors is: 381 Enter the number: 23 Factors: 1 23 23 is a prime number. Running sum of factors is: 405 Enter the number: 37 Factors: 1 37 37 is a prime number. Running sum of factors is: 443 Enter the number: 69 Factors: 1 3 23 69 69 is not a prime number. Running sum of factors is: 539Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started