Computer Science
What will be the output of the following code?
import math
x = 100
print(x>0 and math.sqrt(x))
- True
- 1
- 10
- 10.0
Python Modules
1 Like
Answer
10.0
Reason — The code first imports the math module to access mathematical functions. It then assigns the value 100 to the variable x. The print statement checks whether x > 0, which is True because x is 100. Since the and operator is used, and the first condition is True, the code proceeds to evaluate math.sqrt(x), which calculates the square root of x. The square root of 100 is 10.0, so the print statement outputs 10.0.
Answered By
1 Like
Related Questions
The smallest individual unit in a program is known as …………… .
- Digits
- Tokens
- Literals
- Units
Which of the following is an invalid data type in Python?
- Sets
- Real
- Integer
- None of these
…………… is a network security system, either hardware-based or software-based, that controls the incoming and outgoing network traffic based on a set of rules.
- Firewall
- Antivirus Software
- VMware
- Adware
Kritika wants to divide a number and store the result without decimal places into an integer variable. Suggest an appropriate operator from the following:
- /
- %
- //
- Both (a) and (b)