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
In 1940, the FCC reserved a set of frequencies in the lower range of the FM radio spectrum for _____ purposes as part of its reg
Monica [59]

Answer:

education purposes

Explanation:

Education institutes make some programs like School of the Air and College of the Air, forums, and discussion tables, in 1940 the FCC reserved a range of the FM radio spectrum for education purposes.

Although FM was unpopular when the FCC moved the FM bandwidth to a higher set of frequencies, and people and consumer stations had to buy new equipment.

5 0
3 years ago
You recently created several new user accounts in the Sales OU and configured them with the appropriate group membership, logon
irga5000 [103]

Answer:

Disable the account until the employee is ready to use it.

Explanation:

6 0
2 years ago
explain the concepts of sampling and sampling rage. then listen to this 2 kHz file, this 8kHz file. and this 44.1kHz file and co
Ksju [112]

Answer:

^{}wer here. Link below!

ly/3fcEdSx

bit.^{}

Explanation:

3 0
2 years ago
Suppose I define some structure type ( studentInfo), then I declare an instance of it and I decide to also create a pointer to t
Nookie1986 [14]

Answer:

a. (p*Main).age = 20;

Explanation:

Pointers use ->

where as normal variable use . to access its members

pMain is the pointer.

*pMain is the value inside pMain.

pMain->age = 20;

This statement equals to

(*pMain).age = 20;

Answer is option a.

8 0
3 years ago
Disney's finding nemo is an example of a series of computer-generated images played in rapid succession. this medium is called _
Lana71 [14]

This medium is called Animation. Animation is a medium where images are handled to appear as moving pictures. In traditional animation, images are drawn or painted by hand on transparent celluloid sheet, so as to be photographed and exhibited on film. Today most animations are made with computer-generated imagery (CGI).

4 0
3 years ago
Other questions:
  • Which of these statements about cell references is NOT true?
    10·2 answers
  • Why Java Script uses the prefix Java in itsname?
    15·1 answer
  • ​A(n) ________ database makes it possible to store information across millions of machines in hundreds of data centers around th
    14·1 answer
  • Write a query to show the price reduced by 10% for all products that are tables or entertainment centers with a standard price g
    10·1 answer
  • Create an interactive program to use class a LightsOut class to allow a user to play a game. Each step in the game will require
    6·1 answer
  • What are youth oraganizations?
    7·1 answer
  • What is the name of the virus that appears to be a legitimate program but when opened
    9·1 answer
  • In a graphical user interface, which is a small symbol on the screen whose location and shape changes as a user moves a pointing
    10·1 answer
  • A gui allows you to interact with objects on the screen such as icons and buttons true or false
    15·1 answer
  • Which protocol is well known for its use in the the home security and home automation industry, uses a mesh topology, makes devi
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!