Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
hello, apparently the program works well, but I needed to consider the value 0 also in the for result, for example if I put length 5 and points 10, it should return

0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0

What I have tried:

from math import *
a=int(0)
 
l=float(input('indicate the length of the beam = '))
 
np =int(input('indicate the number of points on the beam = '))
 
for i in range(0,np):
    a+=(l/np)
    print("%.1f" % a)
Posted
Updated 22-Jul-22 17:12pm

1 solution

Quote:
apparently the program works well, but I needed to consider the value 0 also in the for result

Try this:
Python
for i in range(0,np+1):
    print("%.1f" % a)
    a+=(l/np)
 
Share this answer
 
Comments
CPallini 23-Jul-22 7:52am    
5.
Patrice T 23-Jul-22 7:56am    
Thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900