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
Changes in computer technology have an effect on _____. computer scientists only people who work with computers only everybody p
luda_lava [24]
Changes in computer technology have an effect on <span>everybody.</span>
6 0
4 years ago
Read 2 more answers
Which of these is a formatting option that you can use to enhance your text document?
Paha777 [63]
My best guess is the last option (D) tools. Hope it helps
8 0
3 years ago
Read 2 more answers
Write. A program to fine the difference of two number 25 and 17 . Also displays the output
Anon25 [30]

Answer:

Answer = 25-17

print("25-17", Answer)

Explanation:

You put the sum into a variable which in this case would be Answer and then you can output it with the question.

6 0
3 years ago
I have a DBA for keyboarding coming up and I am nervous. Any tips or pointers?
Gennadij [26K]
Don't be nervous... haha
3 0
3 years ago
Read 2 more answers
Write a function called getRowTotal. This function should accept a two-dimensional int array as its first parameter (the array h
garik1379 [7]

Answer:

The solution is implemented using C++

int getRowTotal(int a[][5], int row) {

  int sum = 0;

  for(int i =0;i<5;i++)

  {

      sum += a[row][i];

  }

  return sum;

}

Explanation:

This defines the getRow function and the parameters are arr (the 2 d array) and row and integer variable

int getRowTotal(int arr[][5], int row) {

This defines and initializes sum to 0

  int sum = 0;

This iterates through the row and adds the row items

<em>   for(int i =0;i<5;i++)    { </em>

<em>       sum += arr[row][i]; </em>

<em>   } </em>

This returns the calculated sum

  return sum;

}

8 0
3 years ago
Other questions:
  • Type the correct answer in the box. Spell all words correctly.
    14·1 answer
  • The technology Herman Hollerith created in the 1880s began the modern-day data processing function in computers.
    5·1 answer
  • This IDS defeating techniques works by splitting a datagram or packet into multiple fragments and the IDS will not spot the true
    8·1 answer
  • What is instant messaging
    5·1 answer
  • Examples of apps include pop-up windows, validation of webform inpts and images that change when a cursor passes over them
    12·1 answer
  • Write a program that simulates rolling one die using the following steps: 1. Prompt the user for the number of sides on the die.
    13·1 answer
  • How do you reset a g.mail password?
    12·2 answers
  • Practising some questions for board exams for class 12 python,pls help with detailed answer
    14·1 answer
  • Add criteria to this query to return only the records where the value in the SubscriptionType field is Self or Family and the va
    12·1 answer
  • By the mid-1990s, how did revenue generated from video games compare to revenue generated from movies?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!