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
Xelga [282]
2 years ago
8

Write a program that accepts three decimal numbers as input and outputs their sum​

Computers and Technology
2 answers:
Sophie [7]2 years ago
6 0

Answer:

sum = 0.0

for i in range(0,3):

   sum += float(input("Enter a decimal number to sum: "))

print ("Sum: ", sum)

*** Sample Input ***

Enter a decimal number to sum: 1.1

Enter a decimal number to sum: 2.2

Enter a decimal number to sum: 3.3

*** Sample Output ***

Sum:  6.6

Explanation:

For this problem, a method was devised in python to create the sum of three individual decimal numbers.

The first line of code, <em>sum = 0.0</em>, initializes a variable to the float type in which we will store the value of our sum.  Note, it is initialized to 0.0 to start from a value of 0 and be considered a float.

The second line of code, <em>for i in range(0,3):</em>  is the creation of a for loop control structure.  This will allow us to repeat a process 3 amount of times using the iterator i, from value 0 to 3 in this case.  Note, 0 is inclusive and 3 is exclusive in the python range.  This means the for loop will iterate with, i=0, i=1, and i=2.

The third line of code, <em>sum += float(input("Enter a decimal number to sum: "))</em>  is simply asking the user for a number, taking that input and converting it from a string into a float, and then summing the value with the previous value of sum and saving that into sum.

The fourth line of code, <em>print ("Sum: ", sum)</em> is simply displaying the final value that was calculated by adding the three user inputs together which were stored into the variable <em>sum</em>.

Cheers.

mina [271]2 years ago
4 0

Answer:

a = float(input("Enter an integer: "))

b = float(input("Enter an integer: "))

c = float(input("Enter an integer: "))

print (a + b + c)

Explanation:

Takes three numbers that user inputs and outputs their sum (of whatever numbers are given.)

You might be interested in
What computer has best software
Kruka [31]
Dell computers have pretty good software.
4 0
3 years ago
what is happening when humans control the breeeding of living things to favor certain desired features
sweet-ann [11.9K]
Selective Breeding is happening.
6 0
3 years ago
Steps to copy and paste text/information from website to Ms-word using keyboard​
Greeley [361]

Answer: Highlight the text you want to copy. Use the shortcut key combination Ctrl + C on a PC or Command + C on a Mac to copy the text. Move the text cursor to where you want to paste the text. Press Ctrl + V on a PC or Command + V on a Mac to paste the text

Explanation:

just copy and past by highlighting the text you want and clicking ctrl and c at the same time then ctrl and v to put it on word

8 0
1 year ago
List some of the cautions related to costume change
Volgvan

Answer:

Costume Change?

Explanation:

You might not have enough time to complete the costume and it may look a little sloppy. Also, if you are in a play, everyone must be notified of the change.

4 0
2 years ago
Abrupt changes in road surface or the shape of the road may indicate
Zanzabum

Answer:

D. a potential hazard

Explanation:

Abrupt changes in road surface or the shape of the road may indicate a potential hazard.

5 0
3 years ago
Read 2 more answers
Other questions:
  • Dfd symbols are referenced by using all ____ letters for the symbol name.
    9·1 answer
  • .A menu within a menu is called what? (nested menu ,submenu ,recursive menu ,formal list )
    12·1 answer
  • A third-grade teacher at Potter Elementary School wants a program that allows a student to enter the amount of money a customer
    14·1 answer
  • What operating system is an open source program
    15·1 answer
  • (3 points) Write a program to process two large chunks of data (e.g., a large 3D array and an array of self-defined structures w
    11·2 answers
  • Select the correct answer.
    10·2 answers
  • What is the age group for the silent genration
    10·1 answer
  • What would be the best tool to display the following information from a basketball game?
    6·1 answer
  • A(n) __________ structure is a structure that causes a statement or a set of statements to execute repeatedly.
    13·1 answer
  • 4. Ernesto works in a small office with five other people. What are two possible connection
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!