126k views
1 vote
Try to answer the following question without running the code in Python:

If we run the following program:
a = 2 + 6
b = 7 % 3
c = a - b
c = c * 5
print(c)

what gets printed?

User Jfeust
by
5.5k points

1 Answer

1 vote

Answer:

35

Explanation:

Given

the above lines of code

Required

What's the output

We'll analyze the code line by line

a = 2 + 6

At this point a = 8

b = 7 % 3

At this point b = 1. This is so because, the remainder of 7%3 is 1

c = a - b

At this point c = 7;

This is calculated by c = 8 - 1 = 7

c = c * 5

At this point; c = 35

This is calculated by: c = 7 * 5 = 35

print(c)

The value of c, which is 35 is printed

User Sebastian Hajdus
by
6.2k points