Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
Bonsai Boy of New York Bonsai Trees and Accessories

BlueHost Web Hosting

Liquid Web iThemes WordPress Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

DreamHost Web Hosting


getResponse autofunnels

Liquid Web Cloud VPS Hosting

11,402 questions

15,552 answers

573 users

How to break a fraction to fractional and whole number in Python

1 Answer

0 votes
import math     

for i in range(10):         
   print('{}/2 = {}'.format(i, math.modf(i / 2.0)))



'''
run:

0/2 = (0.0, 0.0)
1/2 = (0.5, 0.0)
2/2 = (0.0, 1.0)
3/2 = (0.5, 1.0)
4/2 = (0.0, 2.0)
5/2 = (0.5, 2.0)
6/2 = (0.0, 3.0)
7/2 = (0.5, 3.0)
8/2 = (0.0, 4.0)
9/2 = (0.5, 4.0)

'''

 




answered Jun 30 by avibootz
edited Jun 30 by avibootz
...