All Questions
98 questions
-1
votes
1
answer
114
views
Repeating an iterating function N times [closed]
I have an iterative function, f(x) = ax + b, which I want to repeat N times. My steps are as follows
1.) Define the iterative function
2.) Assign a value to each repetition
3.) Stop at the Nth ...
0
votes
2
answers
65
views
Reading file and list/tuple iteration
I need to take the data from a file, remove the lines that begin with a comment hash, then read that file into a list. Then convert that list into a list tuples of start times, end times, and step ...
0
votes
1
answer
52
views
For Loops Over Lists
I am trying to read a file, remove the lines that begin with a "#" and then store the remaining lines in a list where I will try and split them into tuples.
The file "in.dat" is ...
0
votes
2
answers
35
views
Defining Function Arguments and List Iteration
I am EXTREMELY new to Python but have experience in javascript. Below is a portion of my program that is not running as the argument "data" in "remove_comment_lines" is not defined....
0
votes
0
answers
16
views
How to check and convert Python function string arguments to list type inside the function? [duplicate]
I have a function with several arguments and I want some of them to check are they list type. Those that are not should be converted to list type.
I decided to do it by making the list of arguments to ...
-1
votes
1
answer
101
views
please how do i use a method to store a collection of class objects using a dictionary for to store the items with appropriate keys and values
class: Define a Python class(MovieList) with methods to do the following:
Define a constructor to create an object of the MovieList class.
A method to store a collection of movie objects that are ...
-1
votes
1
answer
960
views
Python "do...until" iteration until a condition is met with function updating
I have a general question about the "do...until" iteration until a condition is met.
Let's say that I have a variable x, y and z, where:
x0 = function(y0)
I ran the code, and from the ...
-2
votes
1
answer
107
views
iteration using it.chain
I'm stuck on returning the result from the function which is checking samples for A/B test and gave the result. The calculation is correct, but somehow I'm getting the result twice. The code and ...
-2
votes
3
answers
389
views
Is there a code where it prompts the user to enter specific numbers?
I'm practicing Python and I am having a few issues with my code.
I am trying to define the main function and prompt the user to enter three specific numbers. The program is supposed to find the ...
0
votes
0
answers
13
views
How can I take a list that isn't a set length, and use each item as an argument for a function? [duplicate]
I'm trying to find a way to take a list of integers and put each one as an argument of a function without knowing the length of the list. I have been trying to do things like join and such but that ...
0
votes
1
answer
37
views
Running through 15 hdf5 in a directory to compute a function, but getting reiterations of the same table over again
I've currently written a code to run through all the hdf5 files in a directory, print out the tables from the files, plot a figure for each table, and then spit out the area under the curve for each. ...
0
votes
1
answer
126
views
How do I create a Python function that creates values based on previous row's values?
I have a Pandas dataframe with 3 columns: Date, Return, and Result that has stock gains % in the Return column. The dates are set to daily and the index is reset.
The dataframe has hundreds of rows. I'...
-1
votes
1
answer
164
views
Conditional Iteration over a Pandas Dataframe using Function
every month I get a dataframe , so every month I will have to do some adjusts to the dataframe, I would like to create a function for just apply it on every dataframe without create the code again.
I ...
1
vote
3
answers
401
views
Why isn't my function for getting the smallest value from a list working
I made a function for getting the smallest value from a list but it is not working properly and returning the wrong value. It prints out 5. What is wrong with it?
def finding_least_num(a_list):
...
0
votes
1
answer
526
views
Recalling a function iteratively
I have a question about recalling my function within a loop.
Below is my code:
List_new = myfunction()
for items in List_new:
if(my condition is TRUE):
Execute some commands
if(my ...