Python is there a way to align my text along and truncate float at the same time

I’m trying to find out if in the format function if I can convert my float to 2 decimal points and have it align in the one line. In the example below I want to align the last element, i’m wondering if I can do something like print("{0:.2f} {1:<60} {{2:.2f}:<8} {3:.2f}".format(item[0], item[1], item[2], item[3])) I’m aware I can use the round function on the 2nd last element and then align it.

NumPy array row differences

I have a NumPy array vectors = np.random.randn(rows, cols). I want to find differences between its rows according to some other array diffs which is sparse and “2-hot”: containing a 1 in its column corresponding to the first row of vectors and a -1 corresponding to the second row. Perhaps an example shall make it clearer:

why does this accept any username as long as password is correct

username = input("Welcome, please enter your username.") password = input("Please enter your password.") if username != "tony" and password != "password123": print("Access Denied.") else: print("Welcome to the jungle") Answers: Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat … Read more

Why is the function inside the dictionary executing before they’re called

I’m trying to make simple code that reads names and put it on a list, what i am intending to do is a series of functions to add names to the list, remove name, find name position etc. so it will have a lot of ifs, to avoid that i tried to use a dictionary to store the functions that will be called, but when i execute the program the functions inside the dictionary are running before i can input the number to execute it