Hi i have a python program project
its to make an arithmetic program with difficulty levels

-essentially a calculator - that throws out addition, subtraction, multiplication, division and combined math problems at random (depending on which function the user chooses)
-also has three difficulty levels, which can be chosen by user - more digits are added when difficulty is increased
- ideally meant to have a button made in graphics - that allows the user to quit at any time and return to the main menu which allows them to choose which function to practice

and i have NO idea how to do it! only vague things, which don't help at all. please help i'm in dire straits!

Leave the graphics till last. First, create a program which is able to read / write to the command-line e.g. ask a question, recieve an answer. If you get that working, adding the random aspect and difficulties shouldn't be too hard.

hi

the problem is that i'm almost completely incompetent with it. I know the very basics of the basics (not even loops really) - but since then i've been completely lost in the class.
i'll be able to follow your lead and understand the workings of the program, which is essential because i have to walk a group through the workings of the program in class.
again, i really need as much help as possible and would be very obliged!

cointosser

Ok, well you not going to be convincing me to do your assignment for you, but I am happy to help. Once you start producing code, I can help you with more specific issues.

Anyway, basic of basics: write a hello world program, and append some user input on the end. e.g. "hello world, [user input]". Reading in the user input is a large portion of the problem you need to solve, if you need syntax, google will be your fastest companion. Try that first...

sillyboy - i've got this far, and it feels quite good. some more direction please?

def main():
answer0=0
if answer0==0:
answersright=0
else:
starting_variable=0
# Problem1
print "34*32"
answer1 = input()

if answer1 == 1088:
answersright=answersright+1
q1=1
else:
answersright=answersright
q1=0
if answersright == 1:
problem0=0
else:
blank_else=0
if q1>0:
print "You were right!"
else:
print "Try again"
main()

That looks great, I ran it quickly and it works well.

You shouldn't look to me for directions, they are in your problem definition. If I were solving this problem, I would probably next look at reading a user input to determine the difficulty. So you could have 3 pre-defined problems, and decide which to show the user depending on the difficulty they select. Good luck

my friend, use code blocks when posting codes so as to preserve the most valuable indentation

okay

they can enter e for easy , m for medium h for hard
then they can enter + - * or /
then they are given math problems

i don't know how to make the problems random number generations
i don't know how to make them re try it when its wrong
putting a loop inside the if/else just makes it repeat once. is there such a thing as an infinity loop.

Leave the graphics till last. First, create a program which is able to read / write to the command-line e.g. ask a question, recieve an answer. If you get that working, adding the random aspect and difficulties shouldn't be too hard.

I will need to agree with these post

when they get a question right - it prints you were right
but the program ends. i need the program to take an input that allows them to go back to the beginning or end

Ok, so your program is going to end when it has no code left to execute (which you probably already know). For you to get the behaviour explained above, you will probably need to execute parts of the code more than once. Anyway, with the code you posted before, when the user is correct (or whatever your condition is), you can simply call "main()" and it will go back to the start.

how can i group a bunch of code into one thing - so that i can recall the entire piece with just that recall?
for some reason i think its to do with strings, but i'm not sure

nope, before main you will see "def". This means that everything within the block (in jython the block will be defined with indenting) belongs to "main". So you need to define your functions accordingly to be able to recall specific activities. You can make your life easier by choosing well defined function names and making sure they only do what is expected of them.

Hope that clarifies it a little for you...

silly boy
thought it made more sense to email the code rather than paste it here. please take a look if you have time.
I'm not sure if you got what I meant by need it not to end

I've replied and fixed it up for you. There were 2 issues I fixed:
1. def means defining a function, not calling, so "def main:" should only appear once in your code
2. you didn't have any function calls "main()"

So to create a function use def blah:
to call a created function use blah()

awesome. thanks very much
how do i get the math problems to be randomly generated?
something to do with rand or rand range?
the idea is for level Easy to be single digit problems, medium to be double and hard triple.
is there a way to program it to throw out random problems?(within those difficulty ranges) - 10 per difficulty level

I think you will find a math library for python (I am not 100% on this, but it would make sense). If you look through it, it will also probably have some random function. If it is like most random functions, it will probably generate something between 0-1 so you will need to do things like x10 to get values from 0-10 etc... so you will be able to manipulate the random number generator to output something useful to you. If you get stuck, I will look into it more.

you're not supposed to take part of the discussion out of the thread...now if someone were to search and find this thread, they can't see what you learned.

For random number generation, I like the python random module:

import random
op1 = random.randint(1,10)
op2 = random.randint(1,10)
sum = op1 + op2
print op1,'+',op2,'=',sum
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.