KnowledgeBoat Logo

Computer Science

What is the result of this code ?

def print_double(x):
    print(2 ** x)
print_double(3)
  1. 8
  2. 6
  3. 4
  4. 10

Python Functions

3 Likes

Answer

8

Reason — The code defines a function named print_double that takes one parameter x. Inside the function, it calculates 2 raised to the power of x using the exponentiation operator **, and then prints the result. So, when we call print_double(3), we're passing 3 as an argument to the function. The function calculates2 3, which is 8, and prints the result.

Answered By

2 Likes


Related Questions