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
A group of users can perform certain operations on a shared workbook. Which option helps them to update and track changes in the
irina1246 [14]

The “Allow changes by more than one user at the same time” option.


In a group of users, it is very important to create a shared workbook so that several people are able to update information and track changes in the workbook at the same time. To do so, one should click on the review tab of the excel sheet and select share workbook. On the editing tab of the share workbook dialog box, select the Allow changes by more than one user at the same time check box. Go ahead and click the advanced tab and select option you would want to use and then click OK

 






4 0
3 years ago
When you are ready to print your document, what tab and command should you choose from the menu?
Margaret [11]

Answer:

File, Print UWU

Explanation:

3 0
3 years ago
Read 2 more answers
Is greedy algorithm non deterministic by nature?
Flura [38]

Answer: Yes

Explanation: Greedy algorithm is the algorithm that gives the solution to the problem on the basis of the piece by piece or step by step architecture.  the next step of the solution is based on the aim of solving problem optimally.But the steps chosen can be correct or incorrect.

Non-deterministic nature is the feature that determines that the  steps that is being chosen is not the most optimal one and no high surety is present.Thus, this nature is present in the greedy algorithm and it has non-deterministic nature.

7 0
3 years ago
CIST 1122 Project 2 Instructions
NikAS [45]

Answer:

it is suppost ro be at

least 20 tb

Explanation:

5 0
2 years ago
A chart object has all the feature of ____ when activated
diamong [38]

Answer:

A

Explanation:

8 0
3 years ago
Other questions:
  • Which disk drive type contains a magnetic HDD with onboard flash memory serving as a non-volatile cache?
    6·1 answer
  • Describe mobile computing
    7·1 answer
  • Which magazine can help the public to determine the best technology to buy?
    14·1 answer
  • On what basis can you categorize the generations of computers?
    5·1 answer
  • Which skill type refers to the knowledge and ability to perform a task?
    13·2 answers
  • ______ are used to store all the data in a database.
    7·1 answer
  • In which situation would saving a Word document as a PDF be most useful?
    9·2 answers
  • Choose the correct answer
    6·1 answer
  • State the functions of the parts of the computer​
    11·2 answers
  • The action of entering data into your computer. This can be text typed in a word processing document, keywords entered in a sear
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!