1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
NNADVOKAT [17]
4 years ago
12

Python Write a program that asks the user for an integer and then prints out all its factors.

Computers and Technology
1 answer:
scoray [572]4 years ago
7 0

Answer:

def display_factors(num):

   for counter in range(1, num+1):

       if num % counter == 0:

           print(counter)

int_num= int(input("Enter a number : "))

print("The factors for {} are : ".format(int_num))

display_factors(int_num)

Explanation:

The function display_factors is used to display all factors of a number entered by a user.

  • In this  for counter in range(1, num+1) the for loop is iterated until counter is greater  to num is false.   Counter variable starts from 1 and ends when it gets greater than the input number.
  • if num % counter == 0: In this statement, each loop  iteration, checks whether a number (num) is exactly divisible by counter. It is the condition for counter to be a factor of num.
  • print(counter) This is used to display factors of an input number
  • int_num= int(input("Enter a number : ")) This statement asks user to enter a number (int_num) which will be an integer.
  • display_factors(int_num) This calls display_factors number to find the factors of an input number.

You might be interested in
How to reset windows 7 password without logging in
hammer [34]

Explanation:

<em>.</em><em>Reboot your laptop or PC. </em>

<em>Select the Repair your Computer option and press Enter. </em>

<em>The System Recovery Options window will popup, click System Restore, it will check the data in your Restore Partition and factory reset laptop without password.</em>

4 0
3 years ago
Read 2 more answers
What will be a fundamental aspect of future games??
alina1380 [7]
I believe that the answer to the question provided above is that with the age of improving technology, the aspects of future games will be based more unto electronic games or e-games.
Hope my answer would be a great help for you.    If you have more questions feel free to ask here at Brainly.
7 0
3 years ago
Read 2 more answers
How can you logout your account and do not want to have this anymore
hram777 [196]

Answer:

Just Click Log out!

Explanation:

Its Simple, really! I promise its real

5 0
4 years ago
Read 2 more answers
The most common cause of foodborne illness is
nignag [31]

Answer:

Food posioning

Explanation:

8 0
4 years ago
Read 2 more answers
*
asambeis [7]

Answer:

I think they're all valid but the validility depends on the website your using the usernames on.

Explanation:

6 0
3 years ago
Other questions:
  • Why are some constraints automatically applied by the software
    9·1 answer
  • There are only three active stations in a slotted aloha network: a, b, andc. each station generates a frame in a time slot with
    15·1 answer
  • A(n) _____ is a computer network that uses Internet Protocol technology to share information, operational systems, or computing
    12·1 answer
  • A comma is also called a statement terminator. A. True B. False
    8·1 answer
  • Which institution developed outside the limits of the written costitution of the united states ?
    14·1 answer
  • To display the entire entry for a calculated field, select the column in the Field row, right-click to display the shortcut menu
    15·1 answer
  • 1. How do you know that A Drop of Water is an expository<br> text? GENRE
    7·1 answer
  • Write a C program to calculate and display the coordinates of midpoint - M of a linesegment between two given points - say A and
    7·1 answer
  • Which of the following pieces of evidence was NOT used to support the Theory of Continental Drift?
    10·1 answer
  • Backing up your data on a regular basis is a part of the
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!