Hw can i get both quotient and remainder in python, at the same time! Mayb side by side! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Hw can i get both quotient and remainder in python, at the same time! Mayb side by side!

a//b and a%b giving me c, d

3rd Jun 2018, 5:59 AM
Toyib IbnoToohir Ogunremi
Toyib IbnoToohir Ogunremi - avatar
3 Answers
+ 21
c, d = a//b, a%b is valid in Python
3rd Jun 2018, 7:22 AM
Nikolay Nachev
Nikolay Nachev - avatar
+ 10
You can use divmod() method which returns a tuple of a//b and a%b: a = 10 b = 7 c, d = divmod(a, b) print(c, d) >>> 1 3
3rd Jun 2018, 8:06 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
thanks everyone, God bless u all.
7th Jun 2018, 4:06 AM
Toyib IbnoToohir Ogunremi
Toyib IbnoToohir Ogunremi - avatar