Python Program That Prints Out the Decimal Equivalents of 1/2, 1/3, 1/4, . . . ,1/10

Aim:

Using a for loop, write a program that prints out the decimal equivalents of 1/2, 1/3,
1/4, . . . ,1/10

Program:

i=1;
for j in range(2,10):
 print("i:",i,"j:",j)
 print(i,"/",j)
 print (i/j); 

Output:

i: 1 j: 2
1 / 2
0.5
i: 1 j: 3
1 / 3
0.3333333333333333
i: 1 j: 4
1 / 4
0.25
i: 1 j: 5
1 / 5
0.2
i: 1 j: 6
1 / 6
0.16666666666666666 
i: 1 j: 7
1 / 7
0.14285714285714285
i: 1 j: 8
1 / 8
0.125
i: 1 j: 9
1 / 9
0.1111111111111111 

Leave a Comment