Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

My Very First Python Wannabe-'app'


No replies to this topic

#1 Baniboy

    Advocatus Diaboli

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 878 posts
  • Gender:Male
  • Location:/root
  • Interests:Everything...
  • myCENT:37.47

Posted 29 April 2010 - 08:19 PM

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, 29 April 2010 - 08:26 PM.





Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users