#### Category : function

sample_set ={‘a’, 1234, ‘xyz’, 12.454} print(sample_set.add(‘1232’)) Gives output as : None What I am trying to understand is , why doesn’t the nested ‘.add’ function work and prints a set with an additional element 1232 ? Source: Python..

I want to sort a hand of cards by alphabetical order first (Club, Diamond, Heart, Spade) and then by rank (Ace to King). I have the following (very lengthy and inefficient) code but the output seems wrong. I feel like it is an issue with the bubble sort that I use. What am I missing ..

I’ve got an error in python trying to do my homework for python course. The task was to create an array of expenses using operations such as add and list(printing all the elements) The error persists in any version of Python (3.7,3.8,3.9) and in different IDEs ( Visual Studio, PyCharm, some online interpretator) To describe ..

I have a function that should return a gradient. def numerical_derivative_2d(func, epsilon): def grad_func(x): grad_func = (func(x + np.array([epsilon, 0])) – func(x)) / epsilon, (func(x + np.array([0, epsilon])) – func(x)) / epsilon return grad_func But when calculating the gradient at a specific point, I get None. t1 = lambda x: ( -1 / ((x – ..

I am currently in the process of creating a "hangman" game. Below is a function I have developed that returns the unused letters. However I am not sure how to save the value I receive from the function and use it again when it loops in in the while loop… This is what it is ..

I use this function: from sklearn.datasets import load_iris from sklearn.linear_model import LogisticRegression X, y = load_iris(return_X_y=True) for i in range(X.shape): clf = LogisticRegression(random_state=0, verbose=0, max_iter=1000).fit(X[:,i].reshape(-1,1), y) print(clf.score(X[:,i].reshape(-1,1),y)) and i get 4 values as output: 0.7466666666666667 0.5533333333333333 0.9533333333333334 0.96 But when i try to add these 4 values to list: from sklearn.datasets import load_iris from sklearn.linear_model ..

I have a dataframes. X is dataframe with features. Y is predicted values. I want to write a function to get all accuracies ifI train with model with each column from X. I try this code but it doesn’t work: import sklearn.metrics as mtr from sklearn import linear_model model = linear_model.LogisticRegression(max_iter=3000,solver=’lbfgs’) model.fit(X, Y) def accuracies_find(X, ..