KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

What will be the output from the code given below:

a, b = 3, 5
c = a * 2 + b / 2
print(c * 2)

Getting Started

1 Like

Answer

Output
17.0
Explanation

1. a, b = 3, 5 — This line assigns the value 3 to variable a and 5 to variable b using multiple assignment.

2. c = a * 2 + b / 2 — According to operator precedence:

c = a * 2 + b / 2
c = 3 * 2 + 5 / 2
c = 6 + 5 / 2
c = 6 + 2.5
c = 8.5

3. print(c * 2) — This line multiplies the value of c by 2: 8.5 * 2 = 17.0. The print() function displays the result.

Answered By

3 Likes


Related Questions