[Tutor] Defining variable arguments in a function in python

2018-12-29 Thread Karthik Bhat
Hello, I have the following piece of code. In this, I wanted to make use of the optional parameter given to 'a', i.e- '5', and not '1' def fun_varargs(a=5, *numbers, **dict): print("Value of a is",a) for i in numbers: print("Value of i is",i) for i, j in dict.items()

Re: [Tutor] Defining variable arguments in a function in python

2018-12-29 Thread Alan Gauld via Tutor
On 29/12/2018 06:12, Karthik Bhat wrote: > def fun_varargs(a=5, *numbers, **dict): > print("Value of a is",a) > > for i in numbers: > print("Value of i is",i) > > for i, j in dict.items(): > print("The value of i and j are:",i,j) > > fun_varargs(1,2,3,4,5,6,7,8,9,10,

Re: [Tutor] Defining variable arguments in a function in python

2018-12-29 Thread Steven D'Aprano
On Sat, Dec 29, 2018 at 11:42:16AM +0530, Karthik Bhat wrote: > Hello, > > I have the following piece of code. In this, I wanted to make use > of the optional parameter given to 'a', i.e- '5', and not '1' > > def fun_varargs(a=5, *numbers, **dict): [...] > > fun_varargs(1,2,3,4,5,6,7,8,9

Re: [Tutor] decomposing a problem

2018-12-29 Thread Avi Gross
Steven, As I head out the door, I will sketch it. Given a data.frame populated with N rows and columns you want to break it into training and test data sets. In a data.frame, you can refer to a row by using an index like 5 or 2019. You can ask for the number of rows currently in existence. You c

Re: [Tutor] Defining variable arguments in a function in python

2018-12-29 Thread Peter Otten
Karthik Bhat wrote: > Hello, > > I have the following piece of code. In this, I wanted to make use > of the optional parameter given to 'a', i.e- '5', and not '1' > > def fun_varargs(a=5, *numbers, **dict): > print("Value of a is",a) > > for i in numbers: > print("Value

Re: [Tutor] decomposing a problem

2018-12-29 Thread Avi Gross
Steven, A more practical answer about splitting a data frame is to import modules such as for machine learning. Import sklearn.model_selection Then use train_test_split() to return 4 parts. Not sure what answers you need and why here. Plenty of ways and tools exist to specify choosing percen

Re: [Tutor] Defining variable arguments in a function in python

2018-12-29 Thread Avi Gross
I have my usual off the wall answer. OK, seriously. Not exactly an answer but perhaps an experiment. The question was how to have a non-named first argument to a function with some form of default. As was pointed out, this does not fit well with being able to have python gather all positional a