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
KonstantinChe [14]
3 years ago
10

Write a function that accepts a positive random number as a parameter and returns the sum of the random number's digits. Write a

program that generates random numbers until the sum of the random number's digits divides the random number without remainder. assembly language
Computers and Technology
1 answer:
Luba_88 [7]3 years ago
4 0

Answer:

Explanation:

The following Python program has a function called addDigits which takes a number as a parameter and returns the sum of the digits. Then the program creates a loop that keeps creating random numbers between 222 and 1000 and divides it by the value returned from the function addDigits. If the remainder is 0 is prints out a statement and breaks the loop, ending the program. The picture below shows the output of the program.

import random

def addDigits(num):

   sum = 0

   for x in str(num):

       sum += int(x)

   return sum

sum = addDigits(random.randint(222, 1000))

while True:

   myRandomNum = random.randint(2, 99)

   if (sum % myRandomNum) == 0:

       print("No remainder between: " + str(sum) + " and " + str(myRandomNum))

       break

You might be interested in
Create a class called Clock to represent a Clock. It should have three private instance variables: An int for the hours, an int
Anvisha [2.4K]

Answer:

public class Clock

{

private int hr; //store hours

private int min;  //store minutes

private int sec; //store seconds

public Clock ()

{

 setTime (0, 0, 0);

}

public Clock (int hours, int minutes, int seconds)

{

 setTime (hours, minutes, seconds);

}

public void setTime (int hours, int minutes, int seconds)

{

 if (0 <= hours && hours < 24)

      hr = hours;

 else

      hr = 0;

 

 if (0 <= minutes && minutes < 60)

      min = minutes;

 else

      min = 0;

 

 if (0 <= seconds && seconds < 60)

      sec = seconds;

 else

      sec = 0;

}

 

 //Method to return the hours

public int getHours ( )

{

 return hr;

}

 //Method to return the minutes

public int getMinutes ( )

{

 return min;

}

 //Method to return the seconds

public int getSeconds ( )

{

 return sec;

}

public void printTime ( )

{

 if (hr < 10)

      System.out.print ("0");

 System.out.print (hr + ":");

 if (min < 10)

      System.out.print ("0");

 System.out.print (min + ":");

 if (sec < 10)

      System.out.print ("0");

 System.out.print (sec);

}

 

 //The time is incremented by one second

 //If the before-increment time is 23:59:59, the time

 //is reset to 00:00:00

public void incrementSeconds ( )

{

 sec++;

 

 if (sec > 59)

 {

  sec = 0;

  incrementMinutes ( );  //increment minutes

 }

}

 ///The time is incremented by one minute

 //If the before-increment time is 23:59:53, the time

 //is reset to 00:00:53

public void incrementMinutes ( )

{

 min++;

 

if (min > 59)

 {

  min = 0;

  incrementHours ( );  //increment hours

 }

}

public void incrementHours ( )

{

 hr++;

 

 if (hr > 23)

     hr = 0;

}

public boolean equals (Clock otherClock)

{

 return (hr == otherClock.hr

  && min == otherClock.min

   && sec == otherClock.sec);

}

}

3 0
3 years ago
Which of the following is not a true statement? a. Data flow diagrams and flowcharts are difficult to prepare and revise using s
Nimfa-mama [501]

Answer:

a. Data flow diagrams and flowcharts are difficult to prepare and revise using software packages.

Explanation:

A data flow diagram is a graphical description of the source and destination of data that shows how data flow within an organization.

Documentation tools are used extensively in the systems development process.

Data flow diagrams and flowcharts are the two most frequently used systems development documentation tools. Also, documentation tools save an organization both time and money.

7 0
3 years ago
Imagine your friend wants to apply
mojhsa [17]
What do ur friend wants to apply for ?
7 0
4 years ago
What type of values are typically stores in unweighted graphs
Strike441 [17]

Answer: A) 0 and 1

Explanation:

0 and 1 are the values that typically store in unweighted graph. Unweighted graph define as when an edge does not associate with the weight and does not contain any type of cost.

It is also known as edge weighted graph as, it is associated with the edge values and weight.

0 and 1 are typically store in the unweighted graphs because it is a very easy to store and simple to represent the graph in an array in the form of list.  

4 0
4 years ago
What is branching in Python​
timama [110]

Answer:

Branching is where a program decides whether to do something or not.

6 0
3 years ago
Other questions:
  • 11.19 LAB: Max magnitude Write a function max_magnitude() with two integer input parameters that returns the largest magnitude v
    7·1 answer
  • . What are the disadvantages of using small, fixed-length cells in ATM?
    13·2 answers
  • All ofthe following are correct EXCEPT one option when it comes towriting disappointing news letters. Identify theexception.
    6·1 answer
  • A data mart differs from a data warehouse in that: Group of answer choices it deals with a particular component or functional ar
    13·1 answer
  • Which is an advantage of setting bookmarks?
    15·1 answer
  • This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by
    8·1 answer
  • All of these (except the ______) go unnoticed by the computer
    7·1 answer
  • What G-Suite Apps integrate with Forms
    14·2 answers
  • Explain the relevancy of computers in today's global society​
    11·1 answer
  • Although plants and ainamals are both living things___
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!