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
If Windows does not automatically detect a newly added device, to get the device recognized and the drivers installed, you shoul
Artyom0805 [142]

Answer:

Update the device driver

Explanation:

Devices drivers are softwares used to link a component of the computer to the operating system functionality.

It normally comes with the installed operating system, but most plug and play devices , come with a little built-in OS that runs once it is plugged in.

If a device is not recognized, update the driver software and restart the system.

3 0
3 years ago
I am trying to code a lifting simulator game on ro-blox. These problems listed in the third picture tells you the problems. If y
ipn [44]

Answer:

cool

Explanation:

3 0
2 years ago
Read 2 more answers
Site won't let me log in and is glitching? Is rainly down?
yarga [219]

Answer: Somewhat.

Explanation: Try refreshing your pages, or reopening your browser.

3 0
3 years ago
Read 2 more answers
Explain the quality-improvement process.
Tasya [4]

Answer:

 The quality improvement is the process that involve the complete organization in pursuit of the quality. It basically helps to improve the team knowledge and in decision making by using the validate data.  

The quality improvement is the proactive undertaking of recognizing, breaking down and enhancing existing business forms inside an association for enhancement and to satisfy new portions or guidelines of value.

 The main factors of the quality improvement are:

  • Leadership quality
  • Monitoring various types of systems
  • High availability of resources
  • Adequate infrastructure

3 0
3 years ago
Read 2 more answers
Many mobile devices can perform internet searches and other tasks via
OleMash [197]
Cellular Network?
Browser?

there are a lot of things that allow mobile devices to do internet searches.
7 0
3 years ago
Other questions:
  • Query: [mcdonalds Austin] Viewport: Fresh User Location: within Houston, TX Result Returned: McDonalds location in a neighboring
    7·1 answer
  • What registry file contains installed programs' settings and associated usernames and passwords?​?
    13·1 answer
  • Select the proper ergonomic keyboarding techniques.
    15·2 answers
  • What part of the computer gives access to the internet
    10·1 answer
  • Some computer engineering students decided to revise the LC-3 for their senior project. In designing the LC-4, they decided to c
    13·1 answer
  • In which of the security mechanism does the file containing data of the users/user groups have inbuilt security?
    6·1 answer
  • An alteration threat violates information integrity. <br> a. True <br> b. False
    13·1 answer
  • Blood Alcohol Level (BAL) is the ratio between the alcohol consumed and the blood in the body. A. True B. False
    12·2 answers
  • Where ....................... the books that you borrowed? *
    5·1 answer
  • Why is it better for a CPU to have more than one cache?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!