Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Augustana Computing Science 113

Assignment 8

Namespaces

Instructions:   Complete the following questions.  For the Python implementation questions, use the advanced programming techniques we have learned (e.g. making functions).

 

1.   Suppose that two functions in Python use the same variable name and both functions are used in the same program.  Does this cause a problem?  Why or why not?

 

2.   Python has a built-in function called max.  Suppose a programmer creates their own function         called max (exactly the same name).  What will happen when the programmer calls their function? Explain.

 

3.   Explain the difference between a parameter that is a structure and one that is not structured, in terms of being able to change any part of its value during a function call.

 

4.   In Python, write a program that uses our card shuffling module to deal a Bridge round, printing the result.  In Bridge, there are four players called North, South, East, and West.  All 52 cards are        dealt.  [You do not need to know how to play Bridge to complete this question.]

 

5.   Extend the program above to evaluate each hand to determine whether a hand has enough points to open the bidding.  Use the following evaluation scheme:

High Card Points:  4 for an Ace, 3 for a King, 2 for a Queen, and 1 for a Jack

Singleton KQJ Points:  1 for each singleton King, Jack or Queen, i.e. the King, Jack, or Queen is the only card that the player has in that suit

Length Points:  1 for a 5-card suit, 2 for a 6-card suit, 3 for a 7-card suit, etc.

Then the evaluation is:  High Card Points SingletonKQJ Points + Length Points.

 

To open the bidding, the evaluation must be 13 or higher.  For each hand, print out the evaluation and whether the hand has enough points to open the bidding.  [You do not need to know how to   play Bridge to complete this question.]