I have to check whether year = [1900, 2020, 2021, 2001] is a leap year or not and get True/False as a result (Boolean) I have written a function as : But now I need to pass a list as year = [1900, 2020, 2021, 2001] and when I am doing so I am getting an error as “TypeError: unsupported
Tag: function
I’m trying to print the largest number from the inputs that the user gives, but it’s printing the wrong number
Basically, I’m trying to build a code to get the largest number from the user’s inputs. This is my 1st time using a for loop and I’m pretty new to python. This is my code: When I try running my code this is what happens: Any fixes? Answer So, first things first, the use of max can be avoided, as
How to call a function in a different module in Python and not repeating the function
I have defined a function in a different page in Python like so: However, because that function is called in many other files in the project, it is asking me over and over again at runtime to enter the user name. How can I input the user name once and then use that cached value to get the required database
Putting else statement in a loop [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about programming within the scope defined in the help center. Closed 1 year ago. Improve this question All I want to do is add an else statement at the end e.g else: print(‘Incorrect’) but I keep getting an
Write a loop code to calculate average 77 different times, using another column as criteria
First of all, that’s my first code and question, so sorry for the begginer level here and lack of vocabulary. I would like to calculate and store in a dataframe the average of the first 5 rows in a column “returns” with column “N” numbered as 1, and afterwards proceeding to calculate the average return of next 5 rows using
Python : Use of the previous value generated from a function in the same function
I am trying to have a rolling average of all the highs of [‘RSIndex’] greater than 52, series will have NaN value if the first ref value is less than 52, but I want to have the previous iterated value of [‘high_r’] that the function has generated if any other ref value is less than 52. If, anyone has any
import 2 dataframes from a function in a different python file
I have a python file which I have called Pre_Processing_File.py, this file has the function pre_Processing which loads in a text file and creates 3 data frames; userListing_DF,PrivAcc,allAccountsDF, this function then returns the 3 DFs. What I want to do is create another script and import the 3 DFs from the pre_Processing.py file, I have created a script called call_DFs
Defining functions dynamically does not work inside class objects?
In my current project, I am constructing functions dynamically by assembling a string, executing this string, then appending the resulting functions to a list. This works well inside a console, even when looped, but strangely does not work when I attempt to do the same thing inside a class object. Do you know why, and how I could get this
How to pass 1 argument each from 2 functions into 1 function?
I’ve tried to understand how and why I haven’t seen any answers to this specific question. I have two functions each has an argument path Just ignore everything these functions actually do, cause everything works just perfectly until I want to pass on name & site to the following create_new_sbb function So I want to pass on these arguments to
Numpy linspace function stop value
I giving start and stop values as parameters to the linspace function Stop value is normally does not include in the array. Because of this we always write [stop+1] in order to make include the stop value. But in linspace, if i write the output is: Why linspace function output includes the stop value when arange function does not? Answer