Jump to content
xisto Community
Baniboy

My Very First Python Wannabe-'app' Train your mental math skills

Recommended Posts

Hi all. So, I've been kind of on and off learning python recently. Yesterday night I wrote a prototype Python script that gives you easy calculations to deal with. Anyway, I wanted to code it because I want to improve my mental math skills, so maybe somebody else wants (eheem... probably not) to try this out just for fun. Although you might not quite remember math or mental math in school as fun, I think being good in mental math is much more useful than knowing how to get the height of a cylinder based on it's volume and diameter, for example.

 

And with all the inactivity around here, I thought that this could create some kind of conversation here.

 

Anyway, about the script itself, of course I could've done this using JavaScript, but since I'm learning Python I thought I could do it with it instead.

The only kind of math problem currently featured is addition. Later I'll add subtraction and other basic ones. I just need to change the structure a bit because it was designed to only give addition calculations. I'll make it so that it selects randomly from the four/six different mathematical operations and then it would be unpredictable and more challenging. This script uses the Python random module to get the random numbers for the calculations, btw.

 

Instructions are given after you execute the Python script in the terminal. To execute it in a Linux terminal, enter

python '/yourfilepath/math.py'
You can also automatically get the file path if you type "python " and then drag the file into the terminal. For windows, I really don't know, I guess you have to get the full file path to the python.exe file and execute the script with it.

 

Download the .py file here <-- press CTRL + S after arriving to the page to save. Or go to "File -> Save as".

 

Any opinions and suggestions are appreciated, but remember that this is my first script with a 'purpose'. And I know the source is kind of a mess, because I made this only for myself and it wasn't intended to go public. And since it's a python script, there is no other choice than open source hehe ;)

 

TIP: if 3-digit numbers are hard for you, you can open the .py file in a code editor and change the following on lines 17-18:

num1 = random.randrange(0, 101)			num2 = random.randrange(0, 101)
to:

num1 = random.randrange(0, 50)			num2 = random.randrange(0, 50)

This way the results will always be 2-digits or less.

Edited by Baniboy (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.