[Tutor] curses
ok after reading a few tutorials i think i know enough to write my program here it is not commented yet though sorry: import curses from time import sleep scr=vurses.initscr() population=0 seconds=0 try: scr.nodelay(1) scr.leaveok(0) max_y, max_x = scr.getmaxyx() while scr.getch()== -1: sleep(1) seconds=seconds+1 population=population+2.5 scr.addstr(0,0,"seconds:",seconds") # i would like to get this bottom left but didn't know how scr.sddch(1,0,population) # here is ware i think I'm having problems also would like this to be centered scr.clear() scr.refresh() finaly: curses.endwin() but i get the error: traceback (most recent call last): file "population.py", line 15, in scr.addch(1,0,population) TypeError: argument 1 or 3 must be a ch or an int thank you ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] curses
hello all sorry to bother I'm working on my first curses program ive been wanting to learn curses for a while now and now that a have a lop top with fedora core running in run level 3 ware im trying to program all the tools i'll use but curses will be my only gui ALAN has been helping me with this program import curses from time import sleep scr=curses.initscr() population=0 seconds=0 try: scr.nodelay(1) scr.leaveok(0) max_y, max_x = scr.getmaxyx() while 1: sleep(1) second=seconds=+1 population=population+2.5 scr.addstr(0,0,"seconds",seconds) scr.addch,max_y/2, max_x/2, str(population)[0] scr.refresh() finally: curses.endwin() depending on ware i run this i get different results on may mac OSX 10.4 i only get a wired second thing in the top left corner that looks like this secooes and when i run this on fedora core 6 i get the seconds word in top left but no number and i get a single digit in the midle that changes i think the single digit is part of population but not all i cant find out what is wrong any help would be great :) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] reading random line from a file
im writing a quick quote reader that spits out a random quote from a show but cant get it to pick randomly i tried a=randrange(820)+1 text.readline(a) and i would prefer not having to bring evryline into the program then picking like for line in text.readlines(): lines.append(text) ... any help would be great thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] curses
hello all sorry to bother I'm working on my first curses program ive been wanting to learn curses for a while now and now that a have a lop top with fedora core running in run level 3 ware im trying to program all the tools i'll use but curses will be my only gui ALAN has been helping me with this program import curses from time import sleep scr=curses.initscr() population=0 seconds=0 try: scr.nodelay(1) scr.leaveok(0) max_y, max_x = scr.getmaxyx() while 1: sleep(1) second=seconds=+1 population=population+2.5 scr.addstr(0,0,"seconds",seconds) scr.addch,max_y/2, max_x/2, str(population)[0] scr.refresh() finally: curses.endwin() depending on ware i run this i get different results on may mac OSX 10.4 i only get a wired second thing in the top left corner that looks like this secooes and when i run this on fedora core 6 i get the seconds word in top left but no number and i get a single digit in the midle that changes i think the single digit is part of population but not all i cant find out what is wrong any help would be great :) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] web browser
has anyone ever written a web browser with python and Tkinter? if so is there any documentation on it? if not does anyone know if their which tutorials i should read if i wanted to write one for my apple? i don't know vary much Tkinter so i was going to start there then i thought i would be using the urllib and urllib2 modules which i know a little about know i don't know how i would display the html i can get the html of any site with urllib but how to show it in Tkinter? if anyone knows of tutorials for any of those, or has any ideas thank you ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] the and command
hello im checking if a number is in all 5 of the other lists and when i use the and command it seems to just be checking if it's in a least one of the others, here is the program it's choppy i needed it for a quick calculation so it's not pretty but it's not long: n2=2 n3=3 n4=4 n5=5 n6=6 n7=7 l2=[] l3=[] l4=[] l5=[] l6=[] l7=[] while n2 < 100: l2.append(n2) n2=n2+2 while n3 < 100: l3.append(n3) n3=n3+3 while n4 < 100: l4.append(n4) n4=n4+4 while n5 < 100: l5.append(n5) n5=n5+5 while n6 < 100: l6.append(n6) n6=n6+6 while n7<100: l7.append(n7) n7=n7+7 possible=[] for num in l2 and l3 and l4 and l5 and l6: # here seems to be the problem possible.append(num) for a in possible: if a-1 in l7: print a any help is great thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] the and command
thanks much you really helped me if anyone wants here is the program: n2=2 n3=3 n4=4 n5=5 n6=6 n7=7 l2=[] l3=[] l4=[] l5=[] l6=[] l7=[] while n2 < 1000: l2.append(n2) n2=n2+2 while n3 < 1000: l3.append(n3) n3=n3+3 while n4 < 1000: l4.append(n4) n4=n4+4 while n5 < 1000: l5.append(n5) n5=n5+5 while n6 < 1000: l6.append(n6) n6=n6+6 while n7<1000: l7.append(n7) n7=n7+7 possible=[] for num in l2: if num in l3 and num in l4 and num in l5 and num in l6: possible.append(num) for a in possible: if a+1 in l7: print a+1 On Aug 24, 2007, at 1:25 AM, Alan Gauld wrote: > > "max baseman" <[EMAIL PROTECTED]> wrote >> im checking if a number is in all 5 of the other lists and when >> i use the and command it seems to just be checking if it's in a >> least >> one of the others, > > >> for num in l2 and l3 and l4 and l5 and l6: # here seems to be the > > Try: > > if num in I2 and num in I3 and num in I4 and num in I5 and num in I6: > > In your case you are 'and'ing the lists which is a boolean expression > and because of how Python does short circuit evaluation it returns > the last list > >>>> a = [1,2] >>>> b = [3,4] >>>> a and b > [3, 4] > > so > > for n in a and b: > > is the same as > > for n in b: > > which iterates over b... > > HTH, > > -- > Alan Gauld > Author of the Learn to Program web site > http://www.freenetpages.co.uk/hp/alan.gauld > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] clearing a text document
quick question how would i clear a text document? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] clearing a text document
right it's for a quick math "game" the rules are simple you start with any number to get the next number you, a. if it's odd multiply by 3 than add 1 or b. if it's even divide by two, the point of this is to see how long it takes to get to one are it starts to repeat 4,2,1,4,2,1... now im looking for a a number with a very high amount of numbers till you get to 1 so every time it's finds a new one i would like it to write that to a file and clear the last entry, On Aug 29, 2007, at 5:45 PM, Alan Gauld wrote: > > "max baseman" <[EMAIL PROTECTED]> wrote > >> quick question how would i clear a text document? > > A bit of context? If its a file you just open the file for writing. > > If its a list of strings in memory > > text = [] > > will clear it... > > If its a GUI text widget it will depend on which framework you are > using. > > Alan G > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] clearing a text document
cool thank you :) On Aug 29, 2007, at 11:02 PM, Luke Paireepinart wrote: > max baseman wrote: >> right it's for a quick math "game" the rules are simple you start >> with any number to get the next number you, a. if it's odd >> multiply by 3 than add 1 or b. if it's even divide by two, the >> point of this is to see how long it takes to get to one are it >> starts to repeat 4,2,1,4,2,1... >> now im looking for a a number with a very high amount of numbers >> till you get to 1 so every time it's finds a new one i would like >> it to write that to a file and clear the last entry, > Just open the file for writing and it will erase all previous > contents and create the file if it doesn't already exist. > -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] clearing a text document
thats what it does but in order to just be able to let it sit and work for as long as it can i made it a endless loop of just trying every number, for now it just displays the highest on the screen but it would be nice to get it in a text document thanks On Aug 30, 2007, at 4:53 AM, Kent Johnson wrote: > max baseman wrote: >> right it's for a quick math "game" the rules are simple you start >> with any number to get the next number you, a. if it's odd >> multiply by 3 than add 1 or b. if it's even divide by two, the >> point of this is to see how long it takes to get to one are it >> starts to repeat 4,2,1,4,2,1... >> now im looking for a a number with a very high amount of numbers >> till you get to 1 so every time it's finds a new one i would like >> it to write that to a file and clear the last entry, > > If your goal is to find long sequences why not write your program > to try every number up to some limit and find the longest? > > It's a nice use of generators, for those who know what they are... > > These sequences are known as hailstone numbers. The (unproven) > conjecture that the sequence will always terminate is called > Collatz' Conjecture. Some interesting info and pictures here: > http://sprott.physics.wisc.edu/pickover/hailstone.html > http://mathworld.wolfram.com/CollatzProblem.html > > Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] checking if a number is evan or odd
hello just a quick check in, it's about the same program i was asking about before ive let it sit for a few days now and i reached a number to high to convert to a decimal by adding 0.0 here's the program: count=1 numstart=268549802 number=0 high=0 a=0 while 1==1: numstart=numstart+1 number=numstart count=1 while number !=1: if number/2 == (number+0.0)/2: number=number/2 else: number=(number*3)+1 count=count+1 if count > a: a=count print numstart,":",count after a few days i got this error: Traceback (most recent call last): File "homework6high.py", line 11, in if number/2 == (number+0.0)/2: OverflowError: long int too large to convert to float just wondering if theirs a way to check if a larger number is even or odd thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] checking if a number is evan or odd
cool thanks the problem was from a math book imp 1 but i already did the work i was just interested in what number had the most steps i could fin wanted to get to 1000 imagine how dismayed i was when it crashed at 965 On Sep 3, 2007, at 8:23 PM, Andrew James wrote: > I'd just go with > > if number%2 == 0: >number = number/2 > > Why do you need to convert it to a float? > > Off topic: > Is this a PE problem? I remember doing the same thing. > > max baseman wrote: >> hello just a quick check in, it's about the same program i was >> asking about before ive let it sit for a few days now and i >> reached a number to high to convert to a decimal by adding 0.0 >> here's the program: >> >> count=1 >> numstart=268549802 >> number=0 >> high=0 >> a=0 >> while 1==1: >> numstart=numstart+1 >> number=numstart >> count=1 >> while number !=1: >> if number/2 == (number+0.0)/2: >> number=number/2 >> else: >> number=(number*3)+1 >> count=count+1 >> if count > a: >> a=count >> print numstart,":",count >> >> >> after a few days i got this error: >> >> Traceback (most recent call last): >>File "homework6high.py", line 11, in >> if number/2 == (number+0.0)/2: >> OverflowError: long int too large to convert to float >> >> just wondering if theirs a way to check if a larger number is even >> or odd >> >> thanks >> >> ___ >> Tutor maillist - Tutor@python.org >> http://mail.python.org/mailman/listinfo/tutor >> >> >> ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] checking if a number is evan or odd
cool thanks thats what i changed it to than just now i changed to do something else and instead of leaving the program running for 4 or 5 days as i had been i got my answer in less than a second ^_^" i realized that i was wasting way to much time checking every possible answer because the number is jumping around so much so instead i wrote a real quick program infact i wrote it in interactive that just starts at 1 and works the problem backwards for how ever long i tell it to :)) thanks for considering the homework, but this time you did'nt have to worry i did the homework last week i was just doing this for fun, it randomly asked something like "what about a number that takes 100 steps to get to 1" and i thought what about 1000 :)) now i have one running looking for a number that takes 100 steps unfortunately i dont think ill get any extra credit for doing any of this lol here is the program sorry copying it from interactive: >>> number=1 >>> count=1000 >>> count=0 >>> while count < 1000: ... if (number*2)%2 == 0: ... number=number*2 ... else: ... number=(number-1)/3.0 ... count=count+1 ... print number On Sep 4, 2007, at 3:00 AM, Alan Gauld wrote: > Max, > >> just wondering if theirs a way to check if a larger number is even >> or >> odd > > I notice this is homework so I won't give a direct answer. > But look at the mod operator '%' - It returns the remainder > of an integer division. An even number is exactly divisible > by 2. > > HTH, > > Alan G. > > "max baseman" <[EMAIL PROTECTED]> wrote > >> about before ive let it sit for a few days now and i reached a >> number >> to high to convert to a decimal by adding 0.0 > > Thats a terrible way to convert to a float. Just use the float > function > (actually a type): > > f = float(anInt) > > But to determine if its odd/even you don't need to use floats at all. > > >> here's the program: >> >> count=1 >> numstart=268549802 >> number=0 >> high=0 >> a=0 >> while 1==1: >> numstart=numstart+1 >> number=numstart >> count=1 >> while number !=1: >> if number/2 == (number+0.0)/2: >> number=number/2 >> else: >> number=(number*3)+1 >> count=count+1 >> if count > a: >> a=count >> print numstart,":",count > > > Hmm, I have no idea what this is doing... > >> >> thanks >> >> ___ >> Tutor maillist - Tutor@python.org >> http://mail.python.org/mailman/listinfo/tutor >> > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] making math problems mmmm fun
hello all this is a homework in math i dont need to program it but i would like to :) so like any other time pleas dont just give a answer tutorials or a explanation. i dont like to use script something i dont understand :) thanks basically the problem is to find a bunch of ways to put 1,2,3,4,5 into different math problems to that equal 1-25, i haven't spent to much time thinking about how to do this but i cant think of a way to do it it without writing making the program rather long here is the page from the book for the rules i will be working on this for the next week or so thanks for any help :) . you may use any of the four basic arithmetic operations- addition, subtraction, multiplication, and division (according to the order of operations rules). for example, 2+1x3-4 is a 1-2-3-4 expression for the number 1. . you may use exponents. for example, 2² - 4 - 1 is a 1234 expression for the number 3 . you may use radicals for EX: √4x2+1 is equal to 3 so 3+√4x2+1 is a 1234 expression for 6 . you may use factorials for EX: 4! means 4x3x2x1 so 3+4!+1-2 is a 1234 expression for the number 26 . you may juxtapose two or more digits (that is put them next to each other) to form a number such as 12. for example 43-12 is a 1234 expression for 31 . you may use parentheses and brackets to change the meaning of a expression for example according to the rules of order of operations 1 +4x3² is a 1234 expression for 37. you can add parentheses and brackets to get [(1+4)x3]² which is a 1234 expression for 225 . must use 1,2,3,4 exactly once thanks for the help ill post if i find anything ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] making math problems mmmm fun
hello all this is a homework in math i dont need to program it but i would like to :) so like any other time pleas dont just give a answer tutorials or a explanation. i dont like to use script something i dont understand :) thanks basically the problem is to find a bunch of ways to put 1,2,3,4,5 into different math problems to that equal 1-25, i haven't spent to much time thinking about how to do this but i cant think of a way to do it it without writing making the program rather long here is the page from the book for the rules i will be working on this for the next week or so thanks for any help :) . you may use any of the four basic arithmetic operations- addition, subtraction, multiplication, and division (according to the order of operations rules). for example, 2+1x3-4 is a 1-2-3-4 expression for the number 1. . you may use exponents. for example, 2² - 4 - 1 is a 1234 expression for the number 3 . you may use radicals for EX: √4x2+1 is equal to 3 so 3+√4x2+1 is a 1234 expression for 6 . you may use factorials for EX: 4! means 4x3x2x1 so 3+4!+1-2 is a 1234 expression for the number 26 . you may juxtapose two or more digits (that is put them next to each other) to form a number such as 12. for example 43-12 is a 1234 expression for 31 . you may use parentheses and brackets to change the meaning of a expression for example according to the rules of order of operations 1 +4x3² is a 1234 expression for 37. you can add parentheses and brackets to get [(1+4)x3]² which is a 1234 expression for 225 . must use 1,2,3,4 exactly once thanks for the help ill post if i find anything ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] making math problems mmmm fun
haha :) yeah it's the new imp stuff i like parts of the idea but other parts i really dislike basically it TRIES to make math more interactive and world like i really enjoy how most of it is really programable stuff :) where compared to normal math books it's a bit harder to program just a problem instead of a story but imp needs help with it's grading and teaching the grading is terrible i can get a A as long as i can explain and know how my way of doing it wrong "works" but will fail if i just write the write answer without explanation i dont mind the explanations bit but that what i write matters more than if i can do the work is odd adn i just haven't learned anything new yet :) On Sep 10, 2007, at 7:16 PM, wormwood_3 wrote: > Don't have any ideas to Pythonize this problem for you, but I must > say that I hope this problem was listed in a chapter entitled > "Cruel and Unusual"! > > -Sam > ________ > - Original Message > From: max baseman <[EMAIL PROTECTED]> > To: tutor@python.org > Sent: Monday, September 10, 2007 6:28:23 PM > Subject: [Tutor] making math problems fun > > hello all this is a homework in math i dont need to program it but i > would like to :) so like any other time pleas dont just give a > answer tutorials or a explanation. i dont like to use script > something i dont understand :) > > thanks > > basically the problem is to find a bunch of ways to put 1,2,3,4,5 > into different math problems to that equal 1-25, i haven't spent to > much time thinking about how to do this but i cant think of a way to > do it it without writing making the program rather long here is the > page from the book for the rules i will be working on this for the > next week or so thanks for any help :) > > > > > . you may use any of the four basic arithmetic operations- > addition, subtraction, multiplication, and division (according to the > order of operations rules). for example, 2+1x3-4 is a 1-2-3-4 > expression for the number 1. > > . you may use exponents. for example, 2² - 4 - 1 is a 1234 expression > for the number 3 > > . you may use radicals for EX: √4x2+1 is equal to 3 so 3+√4x2+1 is > a 1234 expression for 6 > > . you may use factorials for EX: 4! means 4x3x2x1 so 3+4!+1-2 is a > 1234 expression for the number 26 > > > . you may juxtapose two or more digits (that is put them next to > each other) to form a number such as 12. for example 43-12 is a 1234 > expression for 31 > > . you may use parentheses and brackets to change the meaning of a > expression for example according to the rules of order of operations 1 > +4x3² is a 1234 expression for 37. you can add parentheses and > brackets to get [(1+4)x3]² which is a 1234 expression for 225 > > . must use 1,2,3,4 exactly once > > > > thanks for the help ill post if i find anything > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] making math problems mmmm fun
wow this is a bit over my range of knowledge im impressed :) ill be happy to look at it but i think i will see if i can end up writing my own :) worse case ill do it by hand will not take long hmm wow thanks :) On Sep 10, 2007, at 8:47 PM, John Fouhy wrote: ### import operator binops = { 'add':operator.add, 'sub':operator.sub, 'mul':operator.mul, 'div':operator.truediv, 'pow':operator.pow, 'join':lambda x, y: int(str(x)+str(y)) } patterns = { 'add':'(%s) + (%s)', 'sub':'(%s) - (%s)', 'mul':'(%s) * (%s)', 'div':'(%s) / (%s)', 'pow':'(%s)^(%s)', 'join':'%s%s' } def combine(digits): """ digits :: set(int) output :: [ (value, expression) ] value :: int expression :: str -- string representation of math expression """ # We're going to solve this instance in terms of the solution # for a list with one fewer digit. # Because of non-commutativity, we have to do this twice for each # possible start digit. res = [] # Base case. if len(digits) == 1: return [(digit, str(digit)) for digit in digits] # Otherwise.. for digit in digits: remainder = digits - set([digit]) for val, exp in combine(remainder): for binop in binops: if binop == 'join': # Ensure we only join numbers, not expressions. try: int(exp) except ValueError: continue try: newval1 = binops[binop](digit, val) pattern1 = patterns[binop] % (str(digit), exp) res.append((newval1, pattern1)) except ZeroDivisionError: pass try: newval2 = binops[binop](val, digit) pattern2 = patterns[binop] % (exp, str(digit)) res.append((newval2, pattern2)) except ZeroDivisionError: pass return res if __name__ == '__main__': res = combine(set(range(1, 4))) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] making math problems mmmm fun
lol sorry i was born with bad grammar and hand writing (although it's the bit after being born that matters) On Sep 10, 2007, at 10:41 PM, Eric Brunson wrote: > > When you get done with this math problem you should consider a book > on punctuation. Not using it makes your sentences run together and > difficult to read. :-) Honestly, I just gave up after the first two > lines. > > max baseman wrote: >> haha :) yeah it's the new imp stuff i like parts of the idea but >> other parts i really dislike basically it TRIES to make math >> more interactive and world like i really enjoy how most of it is >> really programable stuff :) where compared to normal math books >> it's a bit harder to program just a problem instead of a story >> but imp needs help with it's grading and teaching the grading is >> terrible i can get a A as long as i can explain and know how my >> way of doing it wrong "works" but will fail if i just write the >> write answer without explanation i dont mind the explanations bit >> but that what i write matters more than if i can do the work is odd >> adn i just haven't learned anything new yet :) >> >> On Sep 10, 2007, at 7:16 PM, wormwood_3 wrote: >> >> >>> Don't have any ideas to Pythonize this problem for you, but I >>> must say that I hope this problem was listed in a chapter >>> entitled "Cruel and Unusual"! >>> >>> -Sam >>> >>> - Original Message >>> From: max baseman <[EMAIL PROTECTED]> >>> To: tutor@python.org >>> Sent: Monday, September 10, 2007 6:28:23 PM >>> Subject: [Tutor] making math problems fun >>> >>> hello all this is a homework in math i dont need to program it but i >>> would like to :) so like any other time pleas dont just give a >>> answer tutorials or a explanation. i dont like to use script >>> something i dont understand :) >>> >>> thanks >>> >>> basically the problem is to find a bunch of ways to put 1,2,3,4,5 >>> into different math problems to that equal 1-25, i haven't spent to >>> much time thinking about how to do this but i cant think of a way to >>> do it it without writing making the program rather long here is the >>> page from the book for the rules i will be working on this for the >>> next week or so thanks for any help :) >>> >>> >>> >>> >>> . you may use any of the four basic arithmetic operations- >>> addition, subtraction, multiplication, and division (according to >>> the >>> order of operations rules). for example, 2+1x3-4 is a 1-2-3-4 >>> expression for the number 1. >>> >>> . you may use exponents. for example, 2² - 4 - 1 is a 1234 >>> expression >>> for the number 3 >>> >>> . you may use radicals for EX: √4x2+1 is equal to 3 so 3+√4x2 >>> +1 is >>> a 1234 expression for 6 >>> >>> . you may use factorials for EX: 4! means 4x3x2x1 so 3+4!+1-2 is a >>> 1234 expression for the number 26 >>> >>> >>> . you may juxtapose two or more digits (that is put them next to >>> each other) to form a number such as 12. for example 43-12 is a 1234 >>> expression for 31 >>> >>> . you may use parentheses and brackets to change the meaning of a >>> expression for example according to the rules of order of >>> operations 1 >>> +4x3² is a 1234 expression for 37. you can add parentheses and >>> brackets to get [(1+4)x3]² which is a 1234 expression for 225 >>> >>> . must use 1,2,3,4 exactly once >>> >>> >>> >>> thanks for the help ill post if i find anything >>> ___ >>> Tutor maillist - Tutor@python.org >>> http://mail.python.org/mailman/listinfo/tutor >>> >>> >>> >>> ___ >>> Tutor maillist - Tutor@python.org >>> http://mail.python.org/mailman/listinfo/tutor >>> >> >> ___ >> Tutor maillist - Tutor@python.org >> http://mail.python.org/mailman/listinfo/tutor >> > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] quick question
hello just a quickie today :) how is python with patters or finding a rule for something ie: in out tables for example how hard would it be to write a program that take's a input of a in out table and finds the rule ex: in out 10 23 5 13 1 5 0 3 the rule is in*2+3 if possible do you know any tutorials that would help thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Tkinter text
hello im working on my first simple gui using Tkinter i've got two questions, 1st how would you go about creating a hidden text file that trys on a apple and if that does not work tries to do it on a windows computer? the program I'm making is a vary simple text editor for one file all it needs to be able to do is add text and save. as far as i can see i'll mostly need to use the text widget but i cant find a tutorial for that widget mostly just for the text entry widget which is only for one line of text. if anyone knows a good tut that would be great thank you ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tkinter text
sorry, what i was trying to say was, how would i write something that at first tries to create a hidden file on a apple computer then if the computer was not a apple creates a hidden file on a windows OS i have slowly been reading your tutorial and it's really one of the best tuts i've ever read i really like and that was the first place i checked but in the GUI section the text entry bit is for a single line of text On Oct 3, 2007, at 3:58 PM, Alan Gauld wrote: > > "max baseman" <[EMAIL PROTECTED]> wrote > >> i've got two questions, 1st how would you go about creating a hidden >> text file that trys on a apple and if that does not work tries to do >> it on a windows computer? > > I don;t undeetabnd this bit. What does the text file try on > the Apple/Windows computer? > >> the program I'm making is a vary simple text editor for one file all >> it needs to be able to do is add text and save. as far as i can see >> i'll mostly need to use the text widget but i cant find a tutorial >> for that widget mostly just for the text entry widget which is only >> for one line of text. if anyone knows a good tut that would be great > > This should only be about 20 lines of code. The Text widget plus > the standard fole open/save dialogs should dop all you need. > > For a very simple example of using the Text widget see the case > study and the Event Driven programming topics of my tutor. > > For more detail see Fred Lundh's Tkinter reference. > > When you get stuck ask here. > > HTH, > > > -- > Alan Gauld > Author of the Learn to Program web site > http://www.freenetpages.co.uk/hp/alan.gauld > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] another quickie
hello all, im sorry but i might be asking a lot of Tkinter questions for a bit. im still working on my first GUI, it is very simple all i want it to do is open a text file, write to it, than save it. so far i have a GUI with the ability to right text (nothing amazing), but i don't know how to have it display the text from a text file any help would be great from Tkinter import * top=Tk() F=Frame(top) F.pack() F.txtBox=Text(top) F.txtBox.pack() F.pack() this is all i have so far ^_^" ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] war cards
hello all, i have been rolling the idea of writing a simple script to play the classic card game war. i thought it would be good for me because their is no skill in the game. while thinking of how to write it i got stuck on one bit, how do i make it so that their is one of each card and i can split them? any help would be great ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] locating python scripts
hey i just have a small question, doesn't have much to do with programing but it has to do with python. anyways Im running a apple computer version 10.4 and have been keeping my scripts in the user folder i was wondering where and how i can change the files that python looks in when looking for programs i would like to make it so that i can have separate folders in the user folder for different projects any help would be great thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] powerball
as a fun little project i scripted a powerball program. it seems to have a bug in it that i cant find. from random import randrange wins=0 win=[] count =0 while count !=5: number=randrange(55)+1 win.append(number) count=count+1 powerball=randrange(42)+1 count=0 win.sort() while count !=146107962: numbers=[] count2=0 while count2 !=5: number=randrange(55)+1 if number in win: numbers.append(number) else: print "lose" break numbers.sort() ball=randrange(42)+1 if ball==powerball: print "win" print print print win, powerball ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] powerball
hello and thank you everyone for your help. I apologize for my ignorance when it came to knowledge of what the powerball is it is not as wide spread as i had thought it was the powerball is a form of lottery their are 5 numbers between 1 and 55, and then their is the powerball between 1 and 42 players win different amounts of money depending on how many numbers they had right the program i wrote uses the number 146107962 as the amount of tickets in play i found this number on the powerball stat as the probability of getting jackpot 1 / 146107962 included is the finished and working script if anyone would like to use or play with it. from random import randrange # for creating random numbers wins=0 # to see how many people would win win=[] # the winning numbers go here count=0 for count in range(5): # powerball uses 5 numbers win.append(randrange(55)+1) powerball=randrange(42)+1 count=0 while count != 146107962: # point of information useing for count in range(146107962) will overlaoad with this large a number numbers=[] # guesses count2=0 for count2 in range(5): number=randrange(55)+1 if number in win: # if the number is in the winning numbers continue numbers.append(number) else: print "lose" # else quite while ahead break numbers.sort() win.sort() ball=randrange(42)+1 #picks the powerball if ball == powerball: print "win" wins=wins+1 count=count+1 print print wins,"winners with", win, powerball seeing as i have left the python mailing list in the past any comments or ideas would be appreciated if sent to this email - thank you ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor