Give the output of the following when num1 = 4, num2 = 3, num3 = 2 a) num1 += num2 + num3 b) print (num1) c) num1 = num1 ** (num2 + num3) d) print (num1) e) num1 **= num2 + c f) num1 = '5' + '5' g) print(num1) h) print(4.00/(2.0+2.0)) i) num1 = 2+9*((3*12)-8)/10 j) print(num1) k) num1 = float(10) l) print (num1) m) num1 = int('3.14')
Answers
Answer:
Explanation:
Arithmetic Operators perform various arithmetic calculations like addition, subtraction, multiplication, division, %modulus, exponent, etc. There are various methods for arithmetic calculation in Python like you can use the eval function, declare variable & calculate, or call functions.
Example: For arithmetic operators we will take simple example of addition where we will add two-digit 4+5=9
x= 4
y= 5
print(x + y)
Similarly, you can use other arithmetic operators like for multiplication(*), division (/), substraction (-), etc.
Comparison Operators
These operators compare the values on either side of the operand and determine the relation between them. It is also referred as relational operators. Various comparison operators are ( ==, != , <>, >,<=, etc)
Example: For comparison operators we will compare the value of x to the value of y and print the result in true or false. Here in example, our value of x = 4 which is smaller than y = 5, so when we print the value as x>y, it actually compares the value of x to y and since it is not correct, it returns false.
x = 4
y = 5
print(('x > y is',x>y))
Likewise, you can try other comparison operators (x < y, x==y, x!=y, etc.)