Python Operators

  • Last Updated : 07 Mar, 2018

Question 1

What is the output of the following code : 

Python3

print 9//2
A

4.5

B

4.0

C

4

D

Error

Python Operators    
Discuss it


Question 1 Explanation: 

The ‘//’ operator in Python returns the integer part of the floating number.

Question 2
Which function overloads the >> operator?
A
more()
B
gt()
C
ge()
D
None of the above
Python Operators    
Discuss it


Question 2 Explanation: 
rshift() overloads the >> operator
Question 3
Which operator is overloaded by the or() function?
A
||
B
|
C
//
D
/
Python Operators    
Discuss it


Question 3 Explanation: 
or() function overloads the bitwise OR operator
Question 4

What is the output of the following program : 

Python3

i = 0
while i < 3:
       print i
       i++
       print i+1

A

0 2 1 3 2 4

B

0 1 2 3 4 5

C

Error

D

1 0 2 4 3 5

Python Operators    
Discuss it


Question 4 Explanation: 

There is no operator ++ in Python

There are 4 questions to complete.
My Personal Notes arrow_drop_up


Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.