Posts
 
Reputation
Joined
Last Seen
Ranked #287
Strength to Increase Rep
+9
Strength to Decrease Rep
-2
97% Quality Score
Upvotes Received
44
Posts with Upvotes
36
Upvoting Members
22
Downvotes Received
1
Posts with Downvotes
1
Downvoting Members
1
19 Commented Posts
5 Endorsements
Ranked #341
Ranked #284
~190.09K People Reached
Favorite Forums
Favorite Tags
Member Avatar for amrutraj

Problem is, there's no way to know "when the internet is disconnected" ahead of time. You might be able to get to 99.99% of all websites but can't get to the one you're trying at the moment. Is "the internet disconnected" in that case? What if it's the other way …

Member Avatar for musawir_2
0
278
Member Avatar for aaron.breen.50

You would want something like this: for t in range(120,-1,-1): minutes = t / 60 seconds = t % 60 print "%d:%2d" % (minutes,seconds) # Python v2 only time.sleep(1.0) ... but that just prints out the time left. If you're supposed to put the time in a separate window, well, …

Member Avatar for rproffitt
0
8K
Member Avatar for vegaseat

I don't see much here on generators. They are a nice feature of Python that everyone should know. Generators are neat ways of doing certain things that involve iterative work. For example, instead of calling a fibonacci function to return fibonacci numbers in a list (say), we create a [I]generator …

Member Avatar for vegaseat
23
34K
Member Avatar for Shaji_1

Good suggestion rr, but I think that just capitalizes the first word of each line. Instead of `readlines()` you want `readwords()`, except that doesn't exist. I think judicious use of `split()` is in order, and remember each line will end with `\n` so you'll want to be sure to delete …

Member Avatar for TrustyTony
0
306
Member Avatar for Miyuki

You could start with this and maybe clean it up a bit. [code=Python] import struct import sys blocksize = 0x2000 errstart = 0 # File offset of start of error span errend = 0 # File offset just past end of error span diffct = 0 # Difference region count …

Member Avatar for Jack_9
0
515
Member Avatar for iuessele

I use 'T' instead of '10', but you can change this as needed[code=Python]import random rank = random.choice( ('A','2','3','4','5','6','7','8','9','T','J','Q','K') ) suit = random.choice( ('c','d','h','s') ) card = rank + suit print card # or print(card) for Python >= 2.6[/code]

Member Avatar for alexander.selin.7
0
13K
Member Avatar for akerman

I would use numpy and represent the matrix as an ARRAY datatype. Additionally, I'd look around numpy to see if somebody has already solved your problem. If not, please submit your solution when you got it working.

Member Avatar for BearofNH
0
162
Member Avatar for MrNoobieCoder
Member Avatar for Kai_Chang
0
6K
Member Avatar for bnn678
Member Avatar for tony75

Have you got a server listening on port 25? This is not the Windows default configuration. (>netstat -aon). It's easy enuf to write your own mail server that just looks for connects, accepts them, and logs appropriate data.

Member Avatar for tony75
0
1K
Member Avatar for marium.aslam.18
Member Avatar for SumTingWong59

Your example probably doesn't handle the case `L<W`, though that's a simple fix. I don't think I know what a tray is. If you hand me a 6-inch square of cardboard and a pair of scissors, I would cut out a 1-inch by 1-inch square at each of the 4 …

Member Avatar for SumTingWong59
0
145
Member Avatar for Guillermo_1

Why is line 11 (`for col...`) there? Shouldn't you just iterate over all the rows? Notice you don't use `col` anywhere in the program. I think `caca` ends up being a list of all the cell values in row `i`. In which case, after line 13, you would want something …

Member Avatar for BearofNH
0
183
Member Avatar for speen

Also, range(0,255) will only create a 255-entry list. If you want all 256 entries, indexed 0 to 255, use range(256).

Member Avatar for speen
0
243
Member Avatar for turbo22
Member Avatar for BearofNH
0
1K
Member Avatar for johnny_disco
Member Avatar for BearofNH
0
225
Member Avatar for robert99x

An `or` operation is evaluated left-to-right. In this case, if `self.getopt('-v')` returns 1 then the user entered `-v` on the command line, in which case we set self.verbose to `True` and ***go on to the next statement***. If there was no `-v` on the command line, we evaluate the second …

Member Avatar for robert99x
0
289
Member Avatar for John_47

> The integral rapidly becomes negligible if x is large so i understand you would simply use the limits of -5 to 5 to calculate this integral. However, i'm still unsure of how to do this. Unless I'm mistaken, I think you can fix this by inserting between line 11 …

Member Avatar for John_47
0
214
Member Avatar for HiHe

After a while you get used to using tuples where feasible. For instance, I've just written a program to generate an image with alternating yellow and pink (!) stripes. First lines of code were: yellow = (244, 244, 0, 255) pink = (255, 142, 200, 255) (for R,G,B,Alpha). Why choose …

Member Avatar for vegaseat
0
683
Member Avatar for glez_b

You didn't tell us what was in the DirViento column. I sincerely hope you are not trying to convert a temperature value in degrees to a temperature value in radians...

Member Avatar for glez_b
0
3K
Member Avatar for matthew.s.thomas.14
Member Avatar for matthew.s.thomas.14
Member Avatar for BearofNH
0
381
Member Avatar for Subhradeep

I've done this sort of stuff before. To answer your second question, here's a code sub-snippet: import copy import Image import numpy as np img = Image.open('E:\\JCH\\Snap.jpg') newx = img.size[0] newy = img.size[1] # Image is (newx,newy) pixels imga = np.asarray(img) # This is the secret; convert img to array …

Member Avatar for Gribouillis
0
2K
Member Avatar for bright.silva

> not_lapped= True """used to test if there was no lapping""" I don't see how this can work. You should be writing: not_lapped= True # used to test if there was no lapping > """this was the best i could come out with but didnt solve the problem""" You should …

Member Avatar for bright.silva
0
264
Member Avatar for hmx7

> I have no idea what to do. The underlying calculations are pretty simple but I myself am confused about what the other stuff means. You almost have to RTTM (Read The Teacher's Mind). For example: > ... For your demo, calculate the GPA to 2 decimal places for these …

Member Avatar for hmx7
0
786
Member Avatar for vegaseat

> Now here is a brain teaser, list all the states that joined the Union after 1865 Add the following to the end: print('-'*35) print("US states admitted after 1865:") for state in instance_list: if int(state.date[-4:]) > 1865: print("{:15} {}".format(state.state, state.date[-4:])) Works for me ...

Member Avatar for vegaseat
2
677
Member Avatar for farmwife

I don't know how others are faring here, but every time I try to post something I get an error message complaining my code is improperly formatted. Even if it's all comments! After which I'm often no longer able to type into the editing box. Something is clearly hosed. Is …

Member Avatar for vegaseat
0
215
Member Avatar for Jacklittle01

Well, pickle.dump() should have no problem saving a variable, as in `pickle.dump(variable,f)`. Now if pickle doesn't like that it will raise an exception, but I suspect if you just try it will work fine...based on pickle.dumps() working on a test case I just tried. You will probably find your real …

Member Avatar for Gribouillis
0
245
Member Avatar for vegaseat

> However, > print float('0x123abc') > does not work Isn't this a bug in Python?

Member Avatar for BearofNH
1
2K
Member Avatar for حسن_3

I'm a little curious about the control work starting at line 40 above. When you get a pygame.QUIT event, setting done=True doesn't automagically exit the loop...you just fall thru to the next set of code. It doesn't look like you should. Howzabout using **break** instead? Speaking of which, shouldn't the …

Member Avatar for حسن_3
0
313