<<

MCS 260 Project Two due Monday 22 February at noon Spring 2016

MCS 260 Project Two : a quiz on Chinese/Japanese numerals due Monday 22 February at noon

The purpose of the the second project is to use dictionaries and list operations to make a simple quiz on the numerals in the Chinese and . The unicode characters for the ten numbers are in the following table:

1 一 ’\u4e00’ 2 二 ’\u4e8c’ 3 三 ’\u4e09’ 4 四 ’\u56db’ 5 五 ’\u4e94’ 6 六 ’\u516d’ 7 七 ’\u4e03’ 8 八 ’\u516b’ 9 九 ’\u4e5d’ 10 十 ’\u5341’

The quiz starts by displaying a symbol and the user is prompted to supply the decimal value of the symbol. In case of a wrong answer, the user gets feedback as below:

$ python numerals.py Welcome to our quiz on Chinese/Japanese numerals. What is the value of 十 ? 7 Wrong answer, 十 equals 10. $

If the answer to the first question is correct, then the quiz continues. In the second question, the user must give the position (starting the index count from zero) of the symbol that matches the value of the decimal number. In case the answer is wrong, feedback is given as below:

$ python numerals.py Welcome to our quiz on Chinese/Japanese numerals. What is the value of 四 ? 4 Congratulations! Let us continue then, consider: [’一’, ’十’, ’六’, ’五’, ’七’, ’八’, ’二’, ’九’, ’三’, ’四’] At which position is the value of 9 ? 5 Wrong answer, 九 is at position 7. $

If the answer is correct, then the computer prints Congratulations! instead of the line that starts with Wrong answer. At the start of your program, import the following functions of the random module: from random import randint, shuffle

Calling randint as randint(1, 10) returns a random integer number between 1 and 10, both 1 and 10 included. If L is a list, then shuffle(L) permutes the order of the elements in L, like in shuffling a deck of cards.

UIC, Department of Mathematics, Statistics and Computer Science page 1 MCS 260 Project Two due Monday 22 February at noon Spring 2016

Some important points:

1. First and foremost, the Python interpreter must be able to execute your script. It is better to have a running but partial solution than a program that attempts to do all computations, but that fails to execute. Handing in an incomplete but working program is better than handing in a program that crashes or does not run at all. 2. The layout of the dialogue with the user and the formatting of the results should be exactly as in the example sessions. 3. Avoid grammatical and spelling errors in your dialogue with the user. 4. The first line of your Python program must be

# MCS 260 Project Two by

where you replace the by your name. 5. Add documentation to clarify your choice of variables and to indicate the steps of the program. 6. The computer project must be solved individually. Collaborations are not allowed. 7. Email your solution to the project to [email protected] before noon on Monday 22 February so the date of the email is proof of an on time submission. Bring also a printed version of your solution to class.

If you have questions or difficulties with the project, feel free to come to my office for help.

UIC, Department of Mathematics, Statistics and Computer Science page 2