Question: Q2.2.2 The operators listed in Table 2.1 are all binary operators: they take two operands (numbers) and return a single value. The symbol - is

Q2.2.2 The operators listed in Table 2.1 are all binary operators: they take two operands (numbers) and return a single value. The symbol - is also used as a unary 2.2 Numbers, Variables, Comparisons and Logic 25 operator, which returns the negative value of the single operand on which it acts. For example, > a=4 >b=a b 4 Note that the expression b=a (which sets the variable b to the negative value of a ) is different from the expression b=a (which subtracts a from b and stores the result in b). The unary - operator has a higher precedence than *, / and % but a lower precedence than exponentiation (), so that, for example 24 is 16 (i.e. (24),not(2)4). Predict the result of the following expressions and check them using the Python shell. (a) 22 (b) 22 (c) 22 (d) 223 (e) 232 (f) 232 (g) (2)32 Table 2.1 Basic Python arithmetic operators \begin{tabular}{ll} \hline & Addition \\ & Subtraction \\ & Multiplication \\ / & Floating-point division \\ // & Integer division \\ % & Modulus (remainder) \\ & Exponentiation \\ \hline \end{tabular}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
