How to Get Quotient and Remainder in Python


In this example, we will learn how to obtain the quotient and remainder in Python. 

Source Code

#! /usr/bin/env python3
# -*- coding: utf-8 -*-

a,b = map(int,input('Please enter divisor a and dividend b:').split())

print('a//b:', a//b)
print('a%b:', a%b)
print('divmod(a,b):', divmod(a, b))

Output:

Please enter divisor a and dividend b: 5 4
a//b: 1
a%b: 1
divmod(a,b): (1, 1)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments