Computer Science, asked by Bhawnadhingra2267, 9 months ago

X=X+2 output is by python

Answers

Answered by Anonymous
41

Answer:

X+=2

Explanation:

These are called as In-place operators in python programming language.In-place operators allow you to write code like 'x = x + 2' more concisely, as 'x += 2'. The same thing is possible with other operators such as -, *, / and % as well.

For example here is a small program:

Input:

>>> x = 4

>>> x *= 3

>>> print(x)

Output:

This can be written as X=X*3

so, the output = 4*3=12

12

In-place operators can also be used for strings, for example:

>>> x = "spam"

>>> print(x)

spam

>>> x += "eggs"

>>> print(x)

spameggs

Attachments:
Similar questions