Coding Portion of Exam 1 - Sample

 

This is a "closed book" examination and you must work entirely on your own. However, you may use the reference card(s) provided to you.

The source code you submit must be entirely your work and must be written entirely during the class period. The use of any pre-existing code (other than that provided as part of the exam) is prohibited.

You must login using the username student (which does not have a password), not using your eid.

You may only use a terminal/shell window, the course IDE and a WWW browser; the only page you may load in the WWW browser is the course submission site.

Your code need not comply with the course style guidelines and need not include comments. You should not submit any tests.

You must submit your code using the course submission system; your code for each question must be submitted separately in a single .py file (appropriately named). If the code you submit for a particular question does not run without error you will receive a grade of 0 on that question. Hence, you should stub-out your program before you do anything else (i.e., make sure that your program has all of the required functions, and that each function has the correct signature and returns an appropriately-typed value if necessary).

Your last submission is the one that will be graded. No limit will be placed on the number of submissions but, obviously, you must complete the exam during the class period and submissions waste time. The submission system will not provide hints.

(50 points) Complete the following game.py program which must contain a function named move_piece_by()and a function named player_turn().

(30 points) move_piece_by() is passed an int board position on a circular board (there are 32 such positions and they are 0-based) and an int representing the number on one die. It must return the board position that corresponds to advancing the current board position by the number of positions on the die. So, for example, if the current position is 18 and the number on the die is 22, it must return 8.

(20 points) player_turn() is passed two int values representing the number of moves made in the game and the number of players(0-n). player_turn() must return an int for representing the number for the player whose turn it is to go(player 0, player 1 for 2 player game). So, for example, it must return 3 if it is passed 8 and 4 and must return 0 if it is passed 5 and 2.

Your solution must not print to the console/display and must not read from the console/keyboard. You may write a main function or section of your progam for testing purposes, but you do not need to submit it.

Note: The elegance of your solution matters. That is, there are more and less elegant solutions to this problem. The more elegant your solution, the more points you will receive.  Your solution should not contain items not covered in Chp1-5 of the class text zyBook (if-then-else, loops, etc...).

"""
Game
"""
def move_piece_by(position, number):
    pass


def player_turn(moves, players):
    pass

Back to Top