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]
4 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]4 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
HELP PLZZZZZZ
Brums [2.3K]

Answer:

Do you want me the money for the policy that has been canceled

3 0
3 years ago
One form of Intrusion Detection System (IDS) starts operation by generating an alert for every action. Over time, the administra
soldier1979 [14.2K]

Answer:

advantages

- detect anomalies

- information for new security rules

disadvantages

- false alarms

Explanation:

Advantages

- With an IDS we can check and track every attack or detect anomalies even when you don't know about these behaviors.

- When an IDS detects anomalies, the system generates information about these behaviors and you can create new rules for these attacks.

Disadvantages

- When we use an IDS, we could receive false alarms because we cannot predict every behavior.

4 0
4 years ago
Write a script called fact.sh that is located in your workspace directory to calculate the factorial of a number n; where n is a
ira [324]

Answer:

hope this helps

Explanation:

7 0
3 years ago
Can you share a google Docx. with a person who has an Icloud Email?
stiks02 [169]

Answer:

Yes, all you do is click 'share' on the top right and then copy the link, then you would send the link to said to person that has a icloud email.

5 0
4 years ago
On a system with paging, a process cannot access memory that it does not own. Why? How could the operating system allow access t
kompoz [17]

Answer:

  • Because the page is not in its page table
  • The operating system could allow access to other memory by allowing entries for non-process memory to be added to the process page table

Explanation:

On a system with paging, a process cannot access memory that it does not own because the page is not in its page table also the operating system controls the contents of the table,therefore it limits a process of accessing to only the physical pages allocated to the process.

The operating system could allow access to other memory by allowing entries for non-process memory to be added to the process page table.that way two processes that needs to exchange  data can efficiently do that . i.e creating a very efficient inter-process communication

7 0
3 years ago
Other questions:
  • The following code in a different program is not working properly. The message should display the value of the intCounter variab
    14·1 answer
  • Advantages of a personal area network
    5·1 answer
  • The conscious process of planning and controlling how you spend your time is called?
    15·1 answer
  • The concept of a process in an operating system embodies two primary characteristics, one of which is:
    15·1 answer
  • Which of the four digital-to-analog conversion techniques is the most susceptible to noise? EXPLAIN WHY.
    6·1 answer
  • Write a function named joinStrings() that keeps asking the user for words and joins them together. Each word should start with a
    12·1 answer
  • E-What is the important of Recycle bin?<br>Ans:​
    12·1 answer
  • During which phase of the writing process is it best to have other
    11·1 answer
  • In the Burp Suite Program that ships with Kali Linux, what mode would you use to manually send a request (often repeating a capt
    14·1 answer
  • What are the main differences between openldap and microsoft's active directory (ad)? check all that apply
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!