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]
3 years ago
8

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

Computers and Technology
2 answers:
Sophie [7]3 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]3 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 key do I use to start my presentation
Len [333]

Answer:

The answer to this question is given below in this explanation section.

Explanation:

Knowing how o start a presentation is crucial if you fail to capture the audience attention right of the bat your entire presentation will flop.Few listeners will stick with you to the end and retain what you have told.

That is mildly unpleasant when you are doing an in house presentation in front of your colleagues.But can become utterly embrassing when you are presenting in front of larger audience presentation to prospective customers.

Let you have most of your presentation slides and polished up you dont check and quick and effective power point presentation design tips.Many ideas are broken into bits sized statements for your slides and complemented with visuals.The best way is to appeal and invoke certain emotions with your audience curiosity,surprise fear or good old amusements.

8 0
3 years ago
Python 3.8.2 detais
olga2289 [7]

Answer:

me dont know

Explanation:

5 0
3 years ago
How does culture affect your life
777dan777 [17]
Culture identifies who you are, what you value, and how you act. 
5 0
3 years ago
What would be the best thing you could do to prepare yourself to work for a company that has embraced globalization?
kvasek [131]
Learn a foreign language
4 0
3 years ago
What is output? public class MathRecursive { public static void myMathFunction(int a, int r, int counter) { int val; val = a*r;
ycow [4]

Answer:

The output of the program is:

2 4 8 16 32 64 End

Explanation:

See attachment for proper presentation of the program

The program uses recursion to determine its operations and outputs.

The function is defined as: myMathFunction(int a, int r, int counter)

It initially gets the following as its input from the main method

a= 1; r = 2; counter = 0

Its operation goes thus:

val = a*r; 1 * 2 = 2

Print val; Prints 2

if (counter > 4) { System.out.print("End"); } : Not true

else { myMathFunction(val, r, counter + 1); }: True

The value of counter is incremented by 1 and the function gets the following values:

a= 2; r = 2; counter = 1

val = a*r; 2 * 2 = 4

Print val; Prints 4

else { myMathFunction(val, r, counter + 1); }: True

The value of counter is incremented by 1 and the function gets the following values:

a= 4; r = 2; counter = 2

val = a*r; 4 * 2 = 8

Print val; Prints 8

else { myMathFunction(val, r, counter + 1); }: True

The value of counter is incremented by 1 and the function gets the following values:

a= 8; r = 2; counter = 3

val = a*r; 8 * 2 = 16

Print val; Prints 16

else { myMathFunction(val, r, counter + 1); }: True

The value of counter is incremented by 1 and the function gets the following values:

a= 16; r = 2; counter = 4

val = a*r; 16 * 2 = 32

Print val; Prints 32

else { myMathFunction(val, r, counter + 1); }: True

The value of counter is incremented by 1 and the function gets the following values:

a= 32; r = 2; counter = 5

val = a*r; 32 * 2 = 64

Print val; Prints 64

if (counter > 4) { System.out.print("End"); } : True

<em>This prints "End"</em>

So; the output of the program is:

2 4 8 16 32 64 End

3 0
3 years ago
Other questions:
  • An international magazine publisher has commissioned you to do a series of images in black and white. The publisher distributes
    13·1 answer
  • Will upvote all answers
    7·1 answer
  • Which of the following is considered to be intellectual property?
    9·1 answer
  • Similarities between drawing toolbar and editing toolbar​
    12·2 answers
  • Someone gave me flashcards on a keychan. I have to memorize them and then give them back. Can I back them up to my PC by creatin
    5·1 answer
  • Write a C program to input a character, then check if the input
    5·1 answer
  • What are the different types of document required for mail merge?
    5·1 answer
  • true or false You are able to change the formatting of a table after it is inserted into a placeholder.
    6·1 answer
  • How is a WAN different from a LAN?
    10·1 answer
  • Need help plz 100 POINTS
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!