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
The hardware to keep the output data when finished is a
Bess [88]
I believe the answer is modem
4 0
3 years ago
Which of the following is a valid format symbol in Microsoft Excel? Dollar Sign, Comma, Percent Sign or all of them? I can't fig
Helen [10]
The Answer is all of them, it's okay when i had to take this class last year and it took me for ever to find the tab and paste options. 
6 0
3 years ago
What command do you type in the search box to access the command line intrface in windows?
Whitepunk [10]
Cmd.exe



------------------------------------------
3 0
3 years ago
What is the range of the well-known ports used by tcp and udp?
melamori03 [73]
/etc/services on my CentOS machine goes up to 49000. Reserved ports are less than 1024.

Well known and reserved ports are two different things. Well known ports only need a registration with IANA. Reserved ports, on *nixes, requires root for a deamon to bind to the port.
8 0
3 years ago
At the beginning of Section 5.2, it is stated that multiprogramming and multiprocessing present the same problems, with respect
QveST [7]

Answer:

By definition, <u>multiprocessing</u> refers to the processing of multiple processes at the same time by multiple CPUs.

By definition, <u>multiprogramming</u> keeps programs in main memory at the same time and execute them concurrently utilizing a single CPU doing a context switch.

The first difference is that multiprocessing uses multiple CPUs and multiprogramming to utilize context switch to do concurrency in one CPU. Another difference is that multiprocessing is more expensive but more efficient than multiprogramming due that it allows parallel processing.

6 0
3 years ago
Other questions:
  • To display or distribute information from a database, programmers or database administrators create ___ .
    12·1 answer
  • When ordering a new​ zagflatz, customers must choose the style of three major​ components, each of which has about ten variation
    6·1 answer
  • The acronym is used to define the process that allows multiple devices to share a single routable ip address.
    6·1 answer
  • Explain how the principles underlying agile methods lead to accelerated development and deployment of software.
    6·1 answer
  • The objective of an Enterprise Resource Planning (ERP) system is to create a customized software program that integrates the inf
    14·1 answer
  • In order to average together values that match two different conditions in different ranges, an Excel user should use the functi
    6·1 answer
  • Which ORDER BY clause causes 10 rows to be retrieved from the result set, starting with the 20th row?
    5·1 answer
  • Steps in the systems development life cycle​
    15·2 answers
  • Function _one(array)
    6·1 answer
  • What is the best way to use copyrighted material?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!