Computer Science, asked by gangbill8, 4 months ago

Discuss the use of ‘+’ operator with respect to strings and integers.

Answers

Answered by jack4610
0

Answer:

In strings the + operator concatenates the string

eg : 1. A = "Abc"

B = "Def"

print(A+B)

Output - AbcDef

2. A='1'

B='2'

print (A+B)

Output - 12

3. A=1

B= "Abc"

print(A+B)

Output - Error as str cannot be added to int

In integers + adds the integers or give the sum of integers.

eg: 1. A=10

B= 20

print(A+B)

Output - 30

2. A = 40

B = 60

print(A+B)

Output - 100

Similar questions