﻿ Python: Print "30+20=50" - w3resource # Python: Print "30+20=50"

## Python Basic: Exercise-88 with Solution

Given variables x=30 and y=20, write a Python program to print "30+20=50".

Pictorial Presentation: Sample Solution-1:

Python Code:

``````x = 30
y = 20
print("\n%d+%d=%d" % (x, y, x+y))
print()
```
```

Sample Output:

```30+20=50
```

## Visualize Python code execution:

The following tool visualize what the computer is doing step-by-step as it executes the said program:

Sample Solution-2:

Python Code:

``````x = 30
y = 20
print("{0}+{1}={2}".format(x, y, x+y))
```
```

Sample Output:

```30+20=50
```

Sample Solution-3:

Python Code:

``````x = 30
y = 20
print("{}+{}={}".format(x, y, x + y))
```
```

Sample Output:

```30+20=50
```

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

What is the difficulty level of this exercise?

Test your Python skills with w3resource's quiz

﻿

## Python: Tips of the Day

Try-catch-else construct:

```try:
foo()
except Exception:
print("Exception occured")
else:
print("Exception didnt occur")
finally:
print("Always gets here")
```