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
trapecia [35]
3 years ago
6

Write a program with class name Digits that prompts the user to input a positive integer and then outputs the number reversed an

d the sum of the digits. For example, if the user enters the number 3456, then your program should output 6543 and the sum as 18. Use a while loop. Hint: use the mod operator and 10 as divider to find the right most digit and to update the value of controlling expression
Computers and Technology
1 answer:
mr Goodwill [35]3 years ago
7 0

Answer:

Written in Python:

inputnum = int(input("User Input: "))

outputnum = 0

total = 0

while(inputnum>0):

     remainder = inputnum % 10

     outputnum = (outputnum * 10) + remainder

     inputnum = inputnum//10

     total = total + remainder

print("Reverse: "+str(outputnum))

print("Total: "+str(total))

Explanation:

This prompts user for input

inputnum = int(input("User Input: "))

This initializes the reverse number to 0

outputnum = 0

This initializes total to 0; i.e. sum of each digit

total = 0

The following iteration gets the reverse of user input

<em>while(inputnum>0): </em>

<em>      remainder = inputnum % 10 </em>

<em>      outputnum = (outputnum * 10) + remainder </em>

<em>      inputnum = inputnum//10 </em>

<em>      This adds each digit of user input</em>

<em>      total = total + remainder </em>

This prints the reversed number

print("Reverse: "+str(outputnum))

This prints the sum of each digit

print("Total: "+str(total))

You might be interested in
hello fellows i need a help.Ineed to know about computer evolutions and computer generations.please hurry.Its my rankover questi
mestny [16]

Answer: Computer generations: There was First Generation 50s,60s. 2nd  60s,70s, 3rd, 70s, Present, and 4th Future.

Computer evolutions: The first modern computer was created in the 1930s and was called the Z1, which was followed by large machinery that took up entire rooms. In the '60s, computers evolved from professional use to personal use, as the first personal computer was introduced to the public.

Explanation: This took me about 10 minutes. Enjoy.

8 0
2 years ago
What is typeface
Mademuasel [1]
I’m so bored and hungry answer is c 3566
4 0
3 years ago
Read 2 more answers
What is the text that is entered into a cell used to identify the purpose of the worksheet, columns, and rows?
castortr0y [4]
Values - Numbers, formulas, and functions, that can be used in calculations; to enter a calculation, start with = and then the formula calculations. The text, date, number, or logical input that completes a condition that a field must meet for searching or filtering. For example, the field Author with the condition <b>equals</b> must include a value, such as <b>Amy</b>, to be complete.



Functions - Excel's built in formulas. A pre-written formula that takes a value or values, performs an operation, and returns a value or values. Use functions to simplify and shorten formulas on a worksheet, especially those that performs lengthy or complex calculations.




Labels - Entries that contains text and numerical information. NOT USED IN CALCULATIONS;  such as "2012 Sales." HELPS YOU IDENTIFY WORKSHEET ROWS AND COLUMNS, MAKING IT EASIER TO UNDERSTAND.




Date and Time: -  Haven't found anything on this one



Hope this helps
7 0
4 years ago
Read 2 more answers
, 13 dB correspond to a power ratio of ....?
ohaa [14]

Answer:

19.95

Explanation:

Power ratio (in db) = 10 * log [P(out)/P(in)]

Here, P(in) and P(out) correspond to input and output power in Watts respectively.

This implies, 13 db = 10 * log [P(out)/P(in)]

Rearranging,  log [P(out)/P(in)] = (13/10)

Or, P(out)/P(in) = 10 ^ 1.3 = 19.95

But, P(out)/P(in) corresponds to the power ratio of output and input power.

So the required power ratio corresponds to 19.95

5 0
4 years ago
c724 wgu True or false. A storage device consists of all the components that work together to process data into useful informati
Law Incorporation [45]

Answer:

False

Explanation:

A output device consists of all the components that work together to process data into useful information

8 0
3 years ago
Other questions:
  • What is the type of account and normal balance of allowance for uncollectible accounts?
    13·2 answers
  • A server-side extension ________________. provides its services to the web server in a way that is totally transparent to the cl
    13·1 answer
  • Question 12 :A user complains that his computer is taking a long time to boot. During the boot process, you observe that the har
    7·1 answer
  • The structure of a language has five different components: __________ refers to the smallest unit of meaning in a language, wher
    12·1 answer
  • Plot absorbance versus concentration in μmol/L of the Tartrazine solution at the wavelength of the maximum absorbance of Allura
    10·1 answer
  • Which of the following is NOT a useful strategy when making an informed purchase ?
    7·1 answer
  • C. Explain the given term in short:<br>a. Computer Ethics​
    14·2 answers
  • Which type of information should never be given out on social media?
    5·2 answers
  • What are the methods used in research methodology?
    12·1 answer
  • How would the grain crusher work
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!