Computer Science, asked by shreya1437, 6 months ago

Q11. Identify the errors in the following program code:
# Program to print sum of three numbers whose values are 10, 12 and 15
num l=10
num2=12
num3=15
sum = num l-unum2 +num3;
print 'sum​

Answers

Answered by Equestriadash
16

Given source code:

num 1 = 10

num2 = 12

num3 = 15

sum = num 1 - unum2 + num3;

print 'sum​

Correct code:

num1 = 10

num2 = 12

num3 = 15

sum = num1 + num2 + num3;

print(sum)

Corrections and reasons:

num1 = 10      

  • Variable names cannot contain special characters other than underscores (_).

num2 = 12   #no correction

num3 = 15   #no correction

sum = num1 + num2 + num3;

  • The objective was to obtain the sum of all the numbers added together. You would need to change the first sign from (-) to (+).
  • The second variable was also named as (num2) and not as (unum2). Wrong variables can lead to Name Errors.

print(sum)

  • Syntax error: print statements need to be enclosed within brackets.
Answered by svmjamalpur00
4

Answer:

it's correct answer

Explanation:

answer is correct

Attachments:
Similar questions