Computer Science, asked by beingsavage, 16 days ago

Find errors in the following Python program
:x = int(input(‘enter a number’)))
x*2 = y
Print (“answer :”, y)

Answers

Answered by anindyaadhikari13
2

Solution:

Corrected Co‎de:

x = int(input('Enter a number: '))

y = 2 * x

print('Answer:', y)

Explanation:

There are errors present in every line of the code.

  • Line 1: In the first line, there is a colon present before x. It is removed after correction.
  • Line 2: Assignment operator is used when we want to assign some values to a variable. We cannot write x * 2 = y. Rather we have to write y = 2 * x
  • Line 3: The letter p must be written in small letters. Python is a case sensitive language. print() and Print() are treated differently. There is no built-in function like Print()

The given program prints twice of the number entered.

Similar questions