Question: 2. (2 pts) Recall that parameter specifications in function definitions come in two flavors: name-only parameters and default-argument parameters, with the ability to preface at

 2. (2 pts) Recall that parameter specifications in function definitions come

2. (2 pts) Recall that parameter specifications in function definitions come in two flavors: name-only parameters and default-argument parameters, with the ability to preface at most one name-only parameter by a *(for this problem, we will not allow ** written before a name-only parameter, although such parameters are legal in Python). All parameters are separated by commas. To simplify this problem, let's use n to abbreviate a name-only parameter and d to abbreviate a default-argument parameter. Write a regular-expression pattern that matches legal orders of these parameter lists in a function definition. The general rule you should model is: a parameter list can (a) be empty, (b) contain one n, n, or d, (c) can contain a sequence of ns and ds with at most one *n in the sequence (front, middle, or rear). Legal: Should Match:n; d: *n; n,d.n,d; n,d, *n,d,d; ; "n,d.d,n.d; n,n, *n Illegal: Should Not Match: nd; *n, *n; n, *nd; n,d*n,d; *n,d,d, *n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!