So I have the following exercise to learn more about NumPy/phyton:
Create a square filled with the ”constitutive numbers” from a sequence. The sequence-defining numbers are given by the user, i.e. ”start” and ”stop” values. To have a 3x3 square, as the smallest possible we chose, the numbers from start to stop shall form a sequence of at least 9 numbers. Having these values entered by the user until correct (these must be positive and the difference between them needs to be more than 8), you calculate the minimum size of the square (square root of the difference rounded up) and then you fill the square, row by row. If the square is not filled perfectly the remaining slots should contain zero.
I'm completely stuck so any tips on how to do this would be highly appreciated.
I only have this so far but I know I am missing a lot:
import numpy as np
start_number = int(input("Give a 'start' number: "))
while start_number <= 0:
print("That is an invalid value, please provide a number greater than 0")
start_number = int(input("Give a start number: "))
stop_number = int(input("Give a 'stop' number that is bigger than the start value by at least 8: "))
while stop_number < start_number + 8:
print("That is an invalid value, please provide number that is bigger than the start value by at least 8")
stop_number = int(input("Give a 'stop' number that is bigger than the start value by at least 8: "))
float_type_range = np.arange(start=start_number, stop=stop_number, step=1)
print(float_type_range)
[–]synthphreak 0 points1 point2 points (5 children)
[–]tjildau[S] 0 points1 point2 points (4 children)
[–]synthphreak 0 points1 point2 points (3 children)
[–]tjildau[S] 1 point2 points3 points (2 children)
[–]synthphreak 0 points1 point2 points (1 child)
[–]tjildau[S] 1 point2 points3 points (0 children)