Companion project: Pupil arithmetic.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.