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]
3 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]3 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
What kinds of dogs are there
drek231 [11]
There are al types of dogs what specific breed are you looking for

5 0
3 years ago
Read 2 more answers
Assign a variable solveEquation with a function expression that has three parameters (x, y, and z) and returns the result of eva
larisa [96]

Answer:

<em>The programming language is not stated;</em>

<em>However, the program written in Python is as follows</em>

def solveEquation(x,y,z):

     result = z - y + 2 * x

     print(result)

x = float(input("x = "))

y = float(input("y = "))

z = float(input("z = "))

print(solveEquation(x,y,z))

Explanation:

This line defines the function solveEquation

def solveEquation(x,y,z):

This line calculates the expression in the question

     result = z - y + 2 * x

This line returns the result of the above expression

     print(result)

The next three lines prompts user for x, y and z

x = float(input("x = "))

y = float(input("y = "))

z = float(input("z = "))

This line prints the result of the expression

print(solveEquation(x,y,z))

3 0
3 years ago
Which of the following should NOT be done to keep people from slipping on floors? A) Have the proper absorbents in an easy-to-fi
RoseWind [281]

The following options helps keep people from slipping on floors

A) Have the proper absorbents in an easy-to-find place to quickly put on spills : So that accidental little spills can be cleaned right away.

C) Wear slip-resistant footwear : It is a precautionary step to follow, no matter where we go.

D) Mark a slippery area with an easy-to-use tent sign that says " Caution, Slippery floor" : This allows people to be aware of the wet area and cross it cautiously.

Leaving oil and fluids to air dry thoroughly, takes a long time and there are chances that people step over it and slip.

So, the answer is

(B) Anytime oil or fluids are spilled on the floor, leave them to thoroughly air dry.

8 0
3 years ago
Read 2 more answers
What the repeal of online privacy protections means for you?
kvv77 [185]
Online Privacy is well, our privacy while on the internet. If they have repealed that, then we have no privacy while on the internet. I feel like now a days there is no privacy at all anywhere. Everywhere you go, there are cameras watching you. So for them to take away online privacy is pretty messed up.
7 0
3 years ago
Instructions:Type the correct answer in the box. Spell all words correctly.
weeeeeb [17]
The answer should be RAM = Random Access Memory

RAM memory is used to store current data while the computer is on. Bear in mind that after the computer is shutdown all data in RAM is lost.
6 0
3 years ago
Read 2 more answers
Other questions:
  • A base class named Garden contains a private field width and a property public int Width that contains get and set accessors. A
    11·1 answer
  • Joshua wants to be a lawyer. He found the following table on the Bureau of Labor Statistics’ website to find out about the emplo
    13·2 answers
  • There are three types of value for money. Which of the following is not a method of value?
    14·1 answer
  • A network security analyst received an alert about a potential malware threat on a user’s computer. What can the analyst review
    12·1 answer
  • Run the browser checker to see that the computer you are using now is set up for WileyPLUS. Which of the following browser funct
    15·1 answer
  • Interactive sites where users write about personal topic and comment to threaded discussion are called?
    10·2 answers
  • Fix thos code:Error using spm_check_installation&gt;check_basic (line 93) You do not appear to have the function search path set
    6·1 answer
  • What is project management? A. Brainstorming ways to plan a project B. Executing, completing, and revising a project C. Managing
    10·1 answer
  • If you forget your privacy password what will you do if the ask this question what is the name of one of your teacher?​
    12·1 answer
  • The contrast ratio of green-60 text on a yellow-10 background is ___ to 1.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!