# Operators Assignment

The Output of **a = 2+3-4/2\*\*2** and also tell its type?

1. 4 and int
2. 4.0 and float
3. 1.0 and float
4. 5 and int

<details>

<summary>Solution</summary>

Answer : option 2

</details>

The output of the following python code snippet\
&#x20;   **print(type(4/2))**\
&#x20;    **print(type(4//2))**<br>

1. float and float
2. float and int
3. int and float
4. int and int

<details>

<summary>Solution</summary>

Answer: option 2

</details>

What will be the output of the following python code snippet\
**a= 12**\
**print(type(a))**\
**a=’12345’**\
**print(type(a))**

a.    Int and str

b.    Int and int

c.     str and int

d.    str and str

<details>

<summary>Solution</summary>

Answer: option **a**

</details>

Operators with the **same precedence** are evaluated in which manner?

a.    Left to right\
b.    Right to left\
c.     Can’t say\
d.    None of the Above Mentioned

<details>

<summary>Solution</summary>

Answer: option **a**

</details>

Output of ***a = 2\*3/4\*\*1==2.00***

a.    1.5\
b.    2\
c.     True\
d.    False

<details>

<summary>Solution</summary>

Answer: option **d**

</details>

The Output of following code\
**print(bool(0), bool(3.14159), bool(-3), bool(1.0+1j))**

a.    False False False False\
b.    True True False True\
c.     False True False True\
d.    False True True True

<details>

<summary>Solution</summary>

Answer: option **d**

</details>

The Output of the following **2\*\*3\*\*2**

a.    512\
b.    64\
c.     12\
d.    None

<details>

<summary>Solution</summary>

Answer: option **a because \*\* operator has right to left associativity**

</details>

The output of the following

**A = 100**\
**B= 30**\
**print(A and B)**

a.    True\
b.    False\
c.     100\
d.    30

<details>

<summary>Solution</summary>

Answer: option **d**

</details>

Output of the following\
**print(100>2 and 100 > 30)**

a.    True\
b.    False\
c.     100\
d.    30

<details>

<summary>Solution</summary>

Answer: option **a**

</details>

&#x20;

**20 or 30 =?**

a.    False\
b.    True\
c.     20\
d.    30

<details>

<summary>Solution</summary>

Answer: option **c**

</details>

What will be the output of the following code&#x20;

**print(True or True and False)**

a.    True\
b.    False

<details>

<summary>Solution</summary>

Answer : ***a*** because **and** has higher precedence over **or**

</details>

&#x20;

What will be the precedence of

&#x20;                    **a.    Not**\
&#x20;                        **b.    And**\
&#x20;                        **c.     Or**

a.    Abc\
b.    Bac\
c.     Bca\
d.    Cab

<details>

<summary>Solution</summary>

Answer: a

</details>

&#x20;

The Output of the following **2/2\*3\*\*2<=10**

a.    True\
b.    False\
c.     9\
d.    10

<details>

<summary>Solution</summary>

Answer : a

</details>

&#x20;

**Int(4.5) = ?**

a.    4\
b.    5\
c.     4.5\
d.    4.0

<details>

<summary>Solution</summary>

Answer: a

</details>

&#x20;

**str(4.5) = ?**

a.    4\
b.    4.5\
c.     4.0\
d.    5

<details>

<summary>Solution</summary>

Answer: **b**

</details>

**type(22%3) = ?**

a.    Int\
b.    Str\
c.     Float\
d.    Can’t say

<details>

<summary>Solution</summary>

Answer: **a**

</details>

&#x20;

**Output of :**&#x20;

***X = 25***\
***print(X+int(‘2’))***

&#x20;

a.    Error\
b.    27\
c.     252\
d.    None

<details>

<summary>Solution</summary>

Answer: **b**

</details>

&#x20;

Output of :

***X = ‘24’***\
***print(X+str(int(‘2’)))***&#x20;

a.    26\
b.    242\
c.     Error\
d.    None

<details>

<summary>Solution</summary>

Answer: **b**

</details>

&#x20;

Which of the following gives **error** in python?

**a.    A = b= c =1**\
**b.    A, b, c = 1, 2, 3**\
**c.     A, b, c = 1**\
**d.    Abc = 1**

a.    A\
b.    B\
c.     C\
d.    D

<details>

<summary>Solution</summary>

Answer: **c**

</details>

&#x20;

Which will give an error?

a.    A++\
b.    ++a\
c.     A += 1\
d.    Both A and B

<details>

<summary>Solution</summary>

Answer: **d**

</details>

&#x20;
