Physics, asked by rahmanshakeel2001, 8 months ago

Write a simple python function to generate a series of floating-point numbers by declaring and updating the global values of the variable and use it to produce the desired range of floating-point numbers by taking input from the user.

Answers

Answered by monica789412
0

Python function to generate a series of floating-point numbers is given below.

Explanation:

Used the NumPy library to get the range of floating-point numbers. NumPy library has various numeric functions and mathematical functions to operate on multi-dimensional arrays and matrices.

NumPy has the arange() function to get the range of a floating-point numbers. The arange() function has the same syntax and functionality as a Python built-in range() function. Additionally, it also supports floating-point numbers in all of its arguments. i.e., we can pass float number in the start, stop and step arguments.

Syntax of numpy’s arange() function

arange (start, stop, step)

Let demonstrate the use with the following example.

import numpy

print("Printing float range with numpy.arange()")

print("Example one")

for i in numpy.arange(0, 5.5, 0.5):

   print(i, end=', ')

print("\nExample two")

for i in numpy.arange(5.5, 15.5, 2.5):

   print(i, end=', ')

print("\nExample Three")

for i in numpy.arange(-2.5, 2.5, 0.5):

   print(i, end=', ')

Output: Run Online

Printing float range with numpy.arange()

Example one

0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0,  

Example two

5.5, 8.0, 10.5, 13.0,  

Example Three

-2.5, -2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0,

To know more about this :

https://brainly.in/question/16082839

https://brainly.in/question/16336457

Similar questions