Computer Science, asked by Lokeshk, 9 months ago

x=25
y="5"
z=x+y
print (x,y,z)
Identify the errors and rectify them.
(Python program)​

Answers

Answered by 16wh1a0460
0

Answer:

Type casting required for string to integer conversion

Explanation:

=25

y="5"

z=x+int(y)

print(x,y,z)

Answered by Equestriadash
7

x = 25

y = "5"

z = x + y

print(x, y, z)

The error in the above coding is a Runtime error.

In variable 'z', we're trying to add and integer and a string value which isn't possible.

Any value written in quotes is a string value. The value assigned to 'y' is a string henceforth.

Solution:

There are two options.

You can remove the quotes in variable 'y'.

x = 25

y = 5

z = x + y

print(x, y, z)

The output will be: 25 5 30

Or you can make 'x' a string value as well.

String values, when made to add, will get combined.

x = "25"

y = "5"

z = x + y

print(x, y, z)

The output will be: 25 5 255

Similar questions