Companion: Yang Yuning Hao Nan
Requirements Analysis:
1. Applicable crowd: elementary school students.
2. Can carry out "+,-,*,/" of the arithmetic. The difficulty can be changed at any time.
3. After submitting the test paper, you can display the score and display the number of wrong questions.
4. You can display the correct question and the number of the wrong question.
Code:
1. Import the random number generation module.
2. Define add, subtract, multiply, respectively, except four operation classes:
3. Define the main function.
Operation Result:
Development experience:
This program is completed independently, doubtful through the Internet query carefully resolved. There are many BIF functions in Python that are already encapsulated and can be called directly. A random.randint that generates random numbers in code. These built-in functions also require a lot of accumulation. After many experiments and online investigation, it was learned that Python can not exercise the corresponding function after arithmetic, so use the statement caltype=random.randint (0,3) randomly generated 0,1,2,3 four numbers, each number corresponding to an algorithm, to achieve arithmetic function. Through the writing of two times, the Python language has a certain understanding.
Companion project: Pupil arithmetic.