419,480 views
31 votes
31 votes
2.2 code practice

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

User Gert Hermans
by
2.9k points

2 Answers

10 votes
10 votes

Answer:

I have used Python Language for this question. Code

a = int(input("Enter first number: "))

b = int(input("Enter second number: "))

c = int(input("Enter third number: "))

print("The sum of these numbers is", a + b + c)

Step-by-step explanation:

a, b and c are variables in the code. int is a command used to convert string into an integer(if possible). input is also a command. It is used to take input from the user. Whenever we make an input to take a number as a input it will be stored in a string not in an integer. The numbers/strings are stored in their variables. At last, I have used print function, which is used to print an integer or any string. To print the sum of numbers taken as input, I add them using their variables name, used in it. We can also give an integer and a string at same as a output by adding them. I know 2 ways to add an integer and a string. But, I have used the easy one for you in the code, and will explain that only. To add a string and an integer first you need to write print() function. Now, write write two quotes in the bracket of print function. Now, write the string you want in the quotes. After writing the string type one comma just after quotes, and type the number you want after comma. You can also write the integer before string by writing the number then comma and then string in quotes. You can also write more string or integer by typing comma then string/integer...

Definition of words I used in the explanation.

Variables: It is used to store any number, string, code etc. For example, a = 23. So, the variable a store the number 23, or b = "This is a string". So, the variable b stores the string etc.

String: It is stored as a sentence, or alphabet not as a number. For example, a = "This is a string", or b = "23". 23 is a number but, it is written between quotes that's why its not a number is a string.

If you have any doubt related my explanation, ask me in comment.

User Diegocr
by
3.0k points
20 votes
20 votes

this is for python correct?

User Kuba Rakoczy
by
2.8k points