2) what is the value of x?
X=int(13.25+4/2) *
17
O
14
O
15
O
23
Answers
This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Precedence and Associativity – 1”.
1. The value of the expressions 4/(3*(2-1)) and 4/3*(2-1) is the same.
a) True
b) False
The value of x will be 15
The códe will look like this
x=int(13.25+4/2)
print(x)
Explanation
Let's solve this in mathematical terms
13.25 + 4 / 2
13.25 + 2
15.25
We are getting the answer as 15.25 which is a float or decimal value but, the int() function converts the number mentioned to an integer number so, the output or value of x will be 15
Extra Information
The variable 'x' has a decimal value or you can say it's a float value stored in it.
float() function converts the number mentioned to a decimal number or a floating number
int() function converts the number mentioned to an integer number
Example
If x = 5.18 then int(x) will give 5
If x = 3 then int(x) will give 3.0
If x = 5.18 then float(x) will give 5.18
Python is created by Guido van Rossum and came into existence in 1991. It is a high-level and general programming language. It is a very lucid programming language as it has a good language construct and object-oriented approach. It is dynamically typed and garbage-collected.