Posts
 
Reputation
Joined
Last Seen
Ranked #2K
Strength to Increase Rep
+0
Strength to Decrease Rep
-0
100% Quality Score
Upvotes Received
1
Posts with Upvotes
1
Upvoting Members
1
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
1 Commented Post
0 Endorsements
Ranked #13.9K
Ranked #2K
~26.7K People Reached
Favorite Forums
Favorite Tags

10 Posted Topics

Member Avatar for vegaseat

[quote=sneekula;361498]Predict the outcome of this Python code: [code=python]def sub_one(x): print "x before if -->", x if x > 1: x = x - 1 sub_one(x) print "x after if -->", x return x x = 5 final = sub_one(x) print "final result -->", final [/code]Can you explain the odd behaviour?[/quote] …

Member Avatar for vegaseat
20
18K
Member Avatar for Panarchy

[quote=Panarchy;384462]Thanks anyways. I will just learn C, then C++, then Java.[/quote] You're finding difficulties with Python and "just" moving to C? Let me warn you, you're walking into dangerous territory... C isn't nearly as simple as it sounds.

Member Avatar for EarthHorse
0
5K
Member Avatar for aot

[quote=BearofNH;396092] Per demetrio, threading is probably what you need. Or, if suitable, [/quote] I third that statement. Time to look at some tutorials as to how to work with threads!

Member Avatar for txfoo
0
1K
Member Avatar for jonamasa

Is there any problem in making the self argument in the action functions mandatory? [code=python] import functools class SubDevice(object): def __init__(self, action): #always pass a reference to self as first argument self.action = functools.partial(action, self) self.state = "ready" def action1(self): #the argument list has to contain self! if self.state == …

Member Avatar for jrcagle
0
265
Member Avatar for fonzali

There are basically two ways to solve a sudoku: 1) Solve it by logic, using simple rules such as the ones we, human beings, use, such as "if a square has only one possibility, than that number must be there". There are several solvers on the net that implement this …

Member Avatar for fonzali
0
1K
Member Avatar for CelestialDog

There is a lot of bad style / redundancies in your code, which is perfectly acceptable since you're a beginner. Your use of while loops when for loops would do is a clear sign of that. Something also leads me to believe that you have already programmed in a language …

Member Avatar for ffao
0
137
Member Avatar for anyedie

If you have an array of choices arr_choices, it's trivial to get a random element from it (I advise you to take a look at the documentation for the random module, if you haven't already): [code=python] import random random.choice(arr_choices) [/code] So what you need to do is write a loop …

Member Avatar for katharnakh
0
102
Member Avatar for cameyo

First, I have to tell you that the data will be separated by one space only, regardless of how many there were in the original file. This is a simple code which has no concerns whatsoever with memory/speed, as it keeps the whole file in memory. [code=python] inp = open("somefile", …

Member Avatar for katharnakh
0
129
Member Avatar for olufunkky

You have mistyped __init__ :) It's __int__ in your phonedb class, look carefully...

Member Avatar for olufunkky
0
151
Member Avatar for Matt Tacular

[quote=jrcagle;381747]since the largest number to be tested has to be sqrt(n), and sqrt(len(primes(n)) < sqrt(n), since len(primes(n)) < n. [/quote] Note that it's not the sqrt(len(primes(n)) natural number, it's the sqrt(len(primes(n)) [I]prime[/I]. I'm curious as to how this works exactly, perhaps it's because the primes array grows faster than sqrt(n), …

Member Avatar for vegaseat
0
288

The End.