Python Assignments
  • Python Assignments
  • Operators Assignment
  • User Input Assignments
  • String Assignments
  • Conditional Statements - Assignments
  • Loops - Assignments
  • List Assignments
  • Function Practice Questions
  • File Handling Assignments
  • Miscellaneous Python Assignments
Powered by GitBook
On this page

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

Solution

Answer : option 2

The output of the following python code snippet print(type(4/2)) print(type(4//2))

  1. float and float

  2. float and int

  3. int and float

  4. int and int

Solution

Answer: option 2

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

Solution

Answer: option a

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

Solution

Answer: option a

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

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

Solution

Answer: option d

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

Solution

Answer: option d

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

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

Solution

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

The output of the following

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

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

Solution

Answer: option d

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

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

Solution

Answer: option a

20 or 30 =?

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

Solution

Answer: option c

What will be the output of the following code

print(True or True and False)

a. True b. False

Solution

Answer : a because and has higher precedence over or

What will be the precedence of

a. Not b. And c. Or

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

Solution

Answer: a

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

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

Solution

Answer : a

Int(4.5) = ?

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

Solution

Answer: a

str(4.5) = ?

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

Solution

Answer: b

type(22%3) = ?

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

Solution

Answer: a

Output of :

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

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

Solution

Answer: b

Output of :

X = ‘24’ print(X+str(int(‘2’)))

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

Solution

Answer: b

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

Solution

Answer: c

Which will give an error?

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

Solution

Answer: d

PreviousPython AssignmentsNextUser Input Assignments

Last updated 2 years ago