Computer Science, asked by shahiasha895, 1 month ago

python question a=10 b=4 a%=b b%=a print (a+b) output and explanation plz​

Attachments:

Answers

Answered by rajsingh08471
1

Answer:

Output will be 2.

Explanation:

here ,a=10, b=4

a%=b is nothing but a shorthand operation for

a=a%b

the "%" operator basically gives the remainder .

Now,

a%b =10%4 =2 as we get remainder 2 after dividing 10 by 4.

the result is then stored in a because its given

a=a%b (or a%=b)

so now a=2.

Similarly,

b%=a => b=b%a,

So b=4%2 as 'a' is now 2 after the above operation

4%2 gives value 0,as 4/2 remainder is 0.

so now b=0.

print(a+b) gives output as 2+0 ,i.e ,2

since a=2 and b=0.

Similar questions