Skip to main content

A tool that can randomly generates simple add and subtract questions.

Project description

Help on module simple_maths_questions:

NAME

simple_maths_questions - # –coding: utf-8 –

FUNCTIONS
format_a_number(num)

格式化数字的显示方式,如果是负数,在数字的两边加上()

gen_one_question(min_number, max_number, num_of_numbers)

生成一道题目

param min_number:

int型,算式中允许出现的最小数字

param max_number:

int型,算式中允许出现的最大数字

param num_of_numbers:

int型,组成算式的数字数量

return:

结果list

gen_one_question_not_negative(min_number, max_number, num_of_numbers)

生成一道非负结果的测试题目

保证算式中的数字和计算结果都不为负数。

param min_number:

int型,算式中允许出现的最小数字

param max_number:

int型,算式中允许出现的最大数字

param num_of_numbers:

int型,组成算式的数字数量

return:

结果list

gen_operation_symbol()

随机生成运算符号

随机生成’+’或’-’,用于构建题目中的算式。

return:

str: 生成的运算符号

gen_question_with_answers(min_number, max_number, num_of_numbers, the_quantity, negative_flag)

生成包含答案的指定数量的题目

param min_number:

int型,算式中允许出现的最小数字

param max_number:

int型,算式中允许出现的最大数字

param num_of_numbers:

int型,组成算式的数字数量

param the_quantity:

int型,生成的测试题目数量

param negative_flag:

题目中是否允许出现负数的标志

return:

生成包含答案的题目dict,key:题目, value:答案

gen_questions(min_number, max_number, num_of_numbers, the_quantity, negative_flag)

生成指定数量的题目

param min_number:

int型,算式中允许出现的最小数字

param max_number:

int型,算式中允许出现的最大数字

param num_of_numbers:

int型,组成算式的数字数量

param the_quantity:

int型,生成的测试题目数量

param negative_flag:

题目中是否允许出现负数的标志

return:

生成的题目list

main(min_number, max_number, num_of_numbers, the_quantity, negative_flag, display_answer)

trim_parameters(first_num, second_num, num_of_nums, the_quantity, negative, bottom_limit, top_limit, number_limit)

对用来生成算式的参数进行剪裁

使得各参数合法,并且不会造成过大计算负载。

param first_num:

int型,算式中允许出现的最小或最大数字

param second_num:

int型,算式中允许出现的最小或最大数字

param num_of_nums:

int型,组成算式的数字数量

param the_quantity:

int型,生成的题目数量,最小值为1,最大值为常量MAX_QUANTITY所规定数值

param negative:

是否允许出现负数的标志

param bottom_limit:

int型,算式中允许出现的最小数字的下限,最小不能小于常量MIN_NUMBER_LIMIT所规定数值

param top_limit:

int型,算式中允许出现的最大数字的上限,最大不能大于常量MAX_NUMBER_LIMIT所规定数值

param number_limit:

int型,组成算式的数字数量上限,最大不能大于常量MAX_NUMBER_OF_NUMBERS所规定数值

return:

tuple,经过剪裁后合法的参数:最小数字,最大数字,组成算式的数字数量,题目数量

DATA

MAX_NUMBER_LIMIT = 100000 MAX_NUMBER_OF_NUMBERS = 5 MAX_QUANTITY = 200 MIN_NUMBER_LIMIT = -100000

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymathtest-0.1.1.dev4.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymathtest-0.1.1.dev4-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file pymathtest-0.1.1.dev4.tar.gz.

File metadata

  • Download URL: pymathtest-0.1.1.dev4.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for pymathtest-0.1.1.dev4.tar.gz
Algorithm Hash digest
SHA256 64b8b6b9a361b950f662f072a735b207c14e42997ec75552df2ed73e2f9ec708
MD5 0108ee0012020e2f19f203d051b999d8
BLAKE2b-256 25a57ef20361641e2be1ef7fb8708ca29c66700462486cc6877dfe91a780c1aa

See more details on using hashes here.

File details

Details for the file pymathtest-0.1.1.dev4-py3-none-any.whl.

File metadata

  • Download URL: pymathtest-0.1.1.dev4-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for pymathtest-0.1.1.dev4-py3-none-any.whl
Algorithm Hash digest
SHA256 8023e2f64c57b03cbadc40c14f31224175bfb322ea848639ad8d650fb0b780fd
MD5 5688d8f8d6c162e19668cf88ebc9b9f2
BLAKE2b-256 dce5b806c081c440a35d387e909dee2d4c569e3ec933bf6deeb22b85c2398e2d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page