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
Murljashka [212]
2 years ago
8

Write a program that prompts the user to input an integer and then outputs both the individual digits of the number and the sum

of the digits. For example, the program should: output the individual digits of 3456 as 3 4 5 6 and the sum as18,
Computers and Technology
1 answer:
mote1985 [20]2 years ago
4 0

The program is an illustration of loops; Loops are used for repetition

<h3>The actual program</h3>

The program written in Python, where comments are used to explain each line is as follows:

#This gets input for the number

n = int(input())

#This initializes the sum to 0

sumTotal = 0

#This iterates through the digits

for x in str(n):

   #This adds each digit

   sumTotal+=int(x)

   #This prints each digit

   print(x,end =' ')

#This prints a new line

print()

#This prints the total

print(sumTotal)

Read more about loops at:

brainly.com/question/24833629

#SPJ1

You might be interested in
PLZ HELP!!! I'm a beginner in coding!
Lina20 [59]

import random

rock,paper,scissors = 1,2,3

choice = int(input("Please choose 1 2 or 3: "))

computer = random.randint(1,3)

player_won = False

draw = False

if choice == computer:

   draw = True

elif choice == 1 and computer == 3:

   player_won = True

elif choice == 2 and computer == 1:

   player_won = True

elif choice == 3 and computer == 2:

   player_won = True

if player_won:

   print("You won!")

elif not player_won and not draw:

   print("The computer won!")

else:

   print("It's a draw!")

First, I recommend importing at the beginning of your program. Also, you can combine all your same datatype variables in one line. You also need to cast your user choice to an integer so you can compare it with the computer's choice. I wrote the if, elif, and else statements using a boolean variable. I simply wrote all the possibilities that would result in the player winning and this would result in the player_won variable being true. If this is the case, we print to the console, "You won!"

4 0
3 years ago
In the space below, explain how the Table Tools can be accessed
ZanzabumX [31]

Answer:

Click in the cell (or select multiple cells) that contains text you want to align. The Table Tools tab appears. Click the Layout tab under the Table Tools heading. … If you change the alignment of blank cells, any new text you type in those blank cells will appear according to the alignment you choose.

Explanation:

3 0
3 years ago
The landscape layout is more appropriate for leaflet. <br> TRUE OR FALSE
Reptile [31]
False im very sure its false
4 0
3 years ago
Define a method calcPyramidVolume with double data type parameters baseLength, baseWidth, and pyramidHeight, that returns as a d
tamaranim1 [39]

The method calcPyramidVolume is an illustration of the java methods; where the methods are executed when called or evoked

<h3>The main program</h3>

The program written in Java, where comments are used to explain each action is as follows:

//This defines the calcPyramidVolume method

public static double calcPyramidVolume(double baseLength,double baseWidth, double pyramidHeight) {

//This calculates the volume of the pyramid

       double PyramidVolume = calcBaseArea(baseLength,baseWidth) * pyramidHeight;

//This returns the volume of the pyramid

       return PyramidVolume;

   }

Read more about java methods at:

brainly.com/question/19271625

7 0
3 years ago
_____ consists of computer equipment used to perform input, processing, and output activities.
goldfiish [28.3K]
<span> (keyboards, mice, scanning, computer chips)</span>
6 0
3 years ago
Other questions:
  • While at work, Joe asked Dana to show him how to change the copier paper. Joe kept working as she explained the process, and the
    5·2 answers
  • How long did it take Linkedln to reach 1 million users?
    5·2 answers
  • . Does Zuckerberg believe in the thought that “the endpoint is when you sell the
    15·1 answer
  • FREE POINTS JUST ANSWER MY LATEST TWO QUESTIONS PLEASE
    10·2 answers
  • In a speech at a research conference, a computer expert stated that shopping centers would become obsolete in the future. He bel
    8·1 answer
  • . Convert BAC4 from hexadecimal to decimal. Show your work.
    9·1 answer
  • Knowledge and experience help you
    11·1 answer
  • Write a script that checks to see if at least one argument has been given on the command line and tests whether the argument is
    5·1 answer
  • Give 3 reasons why it is believed that smart phones precent us from communicating face to face.give three reasons why it is beli
    8·1 answer
  • Which device allows users to directly hear data from a computer
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!