12.6k views
5 votes
What is the value of i printed? j = i = 1 i += j + j * 5 print("What is i?", i)

User AaronHS
by
4.8k points

1 Answer

4 votes

Answer:

7

Step-by-step explanation:

Given the codes as follows:

  1. j = i = 1
  2. i += j + j * 5
  3. print("What is i?", i)

In line 1, the value of 1 is assigned to variable i and then the variable i is assigned to variable j. This means j will hold the value of 1 as well.

In line 2, j will be multiplied with 5 prior to the addition with j itself. So, j + j * 5 -> 1 + (1 * 5) -> 1 + 5 -> 6

Next, value of 6 will be added with i. i = i + 6 -> i = 1 + 6 -> 7#

Eventually, value of 7 will be printed out (Line 3).

User Domingo
by
5.0k points