What is the output of the following piece of code if the user enters two lines containing 2 and 4 respectively?
x = float(input()) y = float(input()) print(y ** (1 / x))
- 2.0
- 0.0
- 4.2
- 1.0
Explanation: Let’s analyze what happens:
- the user enters 2, which is converted to a float, and assigned to the x variable
- the user enters 4, which is converted to a float, and assigned to the y variable
- the result of the following evaluation is printed to the screen: 4 ** (1 / 2) = 4 ** 0.5 = 2.0
More Questions: Python Essentials 1 (PE1) Course Final Test
Please login or Register to submit your answer