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

Design a program that asks the user to enter a string containing a series of single digit numbers with nothing separating them.

The program should display the sum of all the single digit numbers in the string. For example, if the user enters 2514, the method should return 12, which is the sum of 2, 5, 1, and 4. (Hint: The stringToInteger library function can be used to convert a single character to an integer.)
Computers and Technology
1 answer:
ruslelena [56]3 years ago
7 0

Answer:

  1. def calcSum(d):
  2.    sum = 0
  3.    for x in d:
  4.        sum += int(x)
  5.    return sum
  6. digits = input("Please enter your digits: ")
  7. print(calcSum(digits))

Explanation:

The solution code is written in Python.

Firstly, create a function that take one input digit string (Line 1).

In the function, create a sum variable with initial value 0.

Use a for loop to traverse through each character in the digit string and in the loop use int method to convert each character to integer and add it to sum variable (Line 3-5) and return the sum as output.

Next, use input function to prompt user enter a digit string (Line 7).

Lastly test the function by passing the input digit as argument and print the result (Line 8).

You might be interested in
Name the technique that uses a scheme to sum the individual digits in a number and stores the unit's digit of that sum with the
Artemon [7]

Answer:

Parity Bit

Explanation:

Given that Parity bit is a form of strategy or method that utilizes a scheme in adding a solitary bit to a binary string. This can be either 1 or 0, thereby making the total quantity of bit to become either odd parity bit or even parity bit during storage.

Hence, the technique that uses a scheme to sum the individual digits in a number and stores the unit's digit of that sum with the number is called PARITY BIT.

7 0
2 years ago
What command will unregister a component when run?
Advocard [28]
<span>Regsvr32.exe/u will unregister a component when run. Regsvr32.exe/u is a utility tool that is installed on Windows Xp or later versions of Windows. It has a 32-bit version and 64-bit version which can be found in the system root folder on a computer. It is capable of unregistering servers.</span>
7 0
3 years ago
Read 2 more answers
Stock ____ firms trade financial securities between a buyer and a seller.
diamong [38]
<span>Stock market firms, also known as brokerage firms, assist in the act of buying and selling financial securities. These trades are financed through financial institutions for security.</span>
3 0
3 years ago
what feature allows you to create a form letter or certificate and personalized it for different recipients by usin the info in
agasfer [191]

Answer:

mail merge is the answer to this one i believe

6 0
3 years ago
Write technical term of following statements: a.The set of programs to perform specific task. b.A feature of computer which tell
ExtremeBDS [4]

Answer:

a) Application software

d) Lady Augusta Ada Lovelace

b) (it may be versatility

6 0
2 years ago
Other questions:
  • Race conditions are possible in many computer systems. Consider a banking system with two methods: deposit(amount) and withdraw(
    14·1 answer
  • What is the function of the modem?
    12·2 answers
  • An important safety precaution you should take before starting any electrical servicing job is to make sure that your
    15·2 answers
  • List some of the ways that healthcare information technology is making healthcare more of a self-service industry?
    11·1 answer
  • Exchanging which type of data uses the least bandwidth?
    7·2 answers
  • What term describes what an actor breaks when he addresses the audience directly from stage, like in Hamlet’s “to be or not to b
    13·2 answers
  • Remember partially filled arrays where the number of elements stored in the array can be less than its capacity (the maximum num
    14·1 answer
  • Suppose that the following elements are added in the specified order to an empty binary search tree: Kirk, Spock, Scotty, McCoy,
    12·1 answer
  • Algorithm to calculate the area of a square.​
    6·1 answer
  • What are the specifications of mine shaft head gear​
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!