Pls help me,tomorrow is my exam. "Create a login program with help of passing tuple to a function".
Answers
Answer:
Google searching will more help I than asking here.....
The variable on the right is a tuple containing three values. We unpack all three values into separate variables in the order they appear in the tuple. Note that in this case we are aware of how many values are in the tuple argument so know how many variables to include in the assignment.
As you are still new to this, I won’t go into detail about how we could have an unknown number of values in the argument, so cannot implement code in the same informed manner. We would need to exploit both the star syntax at the calling end, and splat syntax at the parameter end. Don’t get absorbed with this, just now, but bookmark it and come back when you have finished most of the Introduction to Python track.
>>> def expand_times_ten(*u): # splat return tuple([x * 10 for x in u]) >>> t = 1, 3, 5, 7, 9, 11>>> expand_times_ten(*t) # star (10, 30, 50, 70, 90, 110) >>>
To repeat, let this go until later. You might already know about the tuple() constructor, but it’s very likely you will not understand the code inside, known as a list comprehension. It will come up when you reach the more advanced concepts, so just wait until then and continue your studies in this unit.