3,386 Posted Topics

Member Avatar for hughesadam_87
Member Avatar for hughesadam_87
0
165
Member Avatar for DanOath

In my Ruby (Ruby 1.9.3 under WindowsXP), it does not show the ord by indexing character, but you need to do: (Array('A'..'Z')|Array('a'..'z')|Array('0'..'9')).each do |letter| puts "#{letter}\t\t#{letter.ord}" end

Member Avatar for Taywin
0
140
Member Avatar for TrustyTony
0
519
Member Avatar for hughesadam_87

It would be usefull to know what you tried and the test which failed. I assume you are basically wanting memoize a property to an instance of the class. There would be many ways I think, some do not work in class without \__dict__ https://github.com/mitsuhiko/werkzeug/blob/master/werkzeug/utils.py#L30

Member Avatar for hughesadam_87
0
243
Member Avatar for vegaseat

Some work on it to dictionaries and changing the base currency by function updating the **mutable** dict. Also changed the rates to floats to be more usefull. '''currency.py open a currency rate URL for reading tested with Python27 and Python32/33 based on vegaseat's code ''' import pprint try: # Python2 …

Member Avatar for TrustyTony
0
494
Member Avatar for Alkajak

value function does not exist, and it does not make sense to indent the 25-27 inside the definition of a class. You are obviusly not understanding what class is about please read up little more and read some code from code snippets archive like http://www.daniweb.com/software-development/python/code/431887/the-employee-class-record-revisited Here something closer to your …

Member Avatar for woooee
0
1K
Member Avatar for nitin1

For full factorization sieve you can store the smallest prime factor for each number and then you have all numbers factored only by traversing through the sieve.

Member Avatar for TrustyTony
0
219
Member Avatar for bintony.ma

target = '4.0000000E+00' with open('test.txt') as infile, open('file_08.txt', 'w') as outfile: for line in infile: if not line.startswith('BNBCD ') or target not in line: outfile.write(line)

Member Avatar for bintony.ma_1
0
466
Member Avatar for mimah1

What are you trying to do7 Can you state your logic? i think writing some functions would help to clean the code and make it readable.

Member Avatar for mimah1
0
156
Member Avatar for anishxx323

I agree with wooeee's suggestions. However you should not use clear_scores function but do # clear the old scores scores[:] = [] or #make new empty list for scores scores = []

Member Avatar for TrustyTony
0
273
Member Avatar for amit9876
Member Avatar for nitin1

I do not know exactly what you are after, but generally Compute Science needs more like introduced in book **Concrete Mathematics** by *Graham, Knuth and Patashnik* I have not been able to read it yet much but I have it, and the auctority of Knuth can not be denied.

Member Avatar for np complete
0
125
Member Avatar for nerdnapster
Member Avatar for techyworld

Alternatively: line_count = 3 with open('original.txt', 'a') as orange: orange.writelines(('%s\n' % raw_input("Enter message %i:" % ind)) for ind in range(1, 1+line_count))

Member Avatar for TrustyTony
0
168
Member Avatar for nitin1

I would sqrt cast to long integer and use exact equality check of it's square against the integer number.

Member Avatar for somjit{}
0
174
Member Avatar for cruze098
Member Avatar for krystosan
Member Avatar for fml2012

usually you would add separator like _ between parts of name or use fixed number of digits. Otherwise you ned to code parsing function, use regular expression to find numbers (`re.findall(r'\d+', filename)`) Also iterating in opposite direction would help.

Member Avatar for TrustyTony
0
160
Member Avatar for krystosan
Member Avatar for jaynew

divmod function might prove helpfull as alternative (or integer division and %)

Member Avatar for jaynew
0
119
Member Avatar for vivsshake

Use split method `line.split('|')` and collect the information. Is the information sorted on the third field like your sample looks like? If so, you can just add up the points, otherwise use a dictionary. Do not forget to change the string of digits to integer.

Member Avatar for TrustyTony
0
133
Member Avatar for silvercats

>Jython is written in Java, yes, and PyPy is writen in Python (or limited subset RPython), but IronPython is .Net friendly implementation, written in C# (thanks, Gribouillis!).

Member Avatar for Gribouillis
0
158
Member Avatar for mbh1992

Line 60 does not make sense as it is not in a if statement. if of line 39 ends of course line 53 as indentation is outdented at line 54 to main program level.

Member Avatar for mbh1992
0
850
Member Avatar for hotblink
Member Avatar for giancan
Member Avatar for zeeters

Combination of lines 7 and 8 does not make sense as condition would allways be True as the word comes through iteration of line (and is a character not word). Are you allowed built in find method?

Member Avatar for zeeters
0
3K
Member Avatar for TrustyTony
Member Avatar for vegaseat
0
253
Member Avatar for krystosan

I do not understand so well but here version with everything I did not understand cut out def findobj(searchTxt,items): """ This function will help you find an object or an item from list of items passed to it. """ for each in items: if each == searchTxt: print each #and …

Member Avatar for krystosan
0
157
Member Avatar for delta_frost

Your words about not paying attention to too small probability sounds like famous last words of programmer ;) :(

Member Avatar for TrustyTony
0
181
Member Avatar for enterpise

My short course of percent calculation: 1. 1 =100% <=> 1% = 0.01 2. Percent calculation does not exist, it is just multiplication. Everything else follows from these two facts.

Member Avatar for enterpise
0
113
Member Avatar for tammy12w
Member Avatar for M.S.

The code could be massaged for example like this: from math import * class Triangle(object): """Checks if given sides can make a Triangle then shows the Angles.""" def __init__(self, a, b, c): self.__check_triangle(a,b,c) self.a = a self.b = b self.c = c self.calculate_angles() def __check_triangle(self,a,b,c): """Checks if given sides can …

Member Avatar for M.S.
0
253
Member Avatar for TrustyTony
0
99
Member Avatar for Darshinie

Here Dani's tutorial from tutorials section (tab) of the forum: http://www.daniweb.com/software-development/computer-science/tutorials/1727/an-introduction-to-algorithms

Member Avatar for TrustyTony
0
54
Member Avatar for athulram

I do not think you should include 0 as possible value to your triplets. And of course there is more efficient methods than brute force. >>>print(list((a,b,c) for a,b,c in itertools.product(range(1, 100), repeat=3) if a<=b<=c and a**2 + b**2 == c**2)) [(3, 4, 5), (5, 12, 13), (6, 8, 10), (7, …

Member Avatar for athulram
0
4K
Member Avatar for M.S.

Your code is actually very nice for beginner! I would slightly rearrange the calling the functions and do itertools.takewhile from sorted wordlist to rechecking whole word list. from string import punctuation as punc from itertools import takewhile def find_longest(text): """ find length of longest word and what are those words …

Member Avatar for M.S.
0
310
Member Avatar for PythonMonty

You must start from simple functioning program and build on it, here little advanced # make code work in both Python2 and Python3 from __future__ import print_function, division try: input = raw_input except: #Using Python3 pass conversion = input("Enter 'F' to convert to Fahrenheit, 'C' to convert to Celsius: ").upper() …

Member Avatar for HiHe
0
795
Member Avatar for ddree

Do show effort solving your problem and ask about specific problem in your code.

Member Avatar for woooee
0
1K
Member Avatar for sainitin

You can use set and & for intersection: d1 = """ 12313 : 23546 12313 23214 32465 """ d2 = """ 13132 : 23546 12323 32125 32125 32121 """ ds1 = set(line[8:].strip() for line in d1.splitlines() if line) ds2 = set(line[8:].strip() for line in d2.splitlines() if line) print ds1 & …

Member Avatar for vegaseat
0
222
Member Avatar for enakta13

Good luck from me also, at least you allready got the assignement statement, maybe you could move on to loops for a challenge, maybe those i,j,k variables is hint from your teacher for that? And you could only include modules which are standard and used in your code (and no …

Member Avatar for TrustyTony
0
162
Member Avatar for resmi sanker

Duplicate finding usually is simplest by just doing sorted copy and removing the duplicates (sequentiailly) from the ordered data. If you would use genetic programming, you would make it to find a algorithm better than this.

Member Avatar for James_6
0
131
Member Avatar for zvjezdan.veselinovic

Basically you should keep movement state in one separate variable and only touch it when movement affecting keys have been pressed. So you move not only when key is pressed but every tick and key pushed conditions only change the movement variable.

Member Avatar for zvjezdan.veselinovic
0
215
Member Avatar for M.S.

I would think you would be better off to add functionality to inbox.Inbox by inheriting, I do not see what object the DelSMS corresponds with.

Member Avatar for M.S.
0
175
Member Avatar for Gribouillis

It is, I think, necessary why would somebody to consider this kind of complication to use. One reason is that the importing of large modules takes considerable time, so it would be nice to delay the import itself to time when the function from module is actually called, so execution …

Member Avatar for Gribouillis
1
529
Member Avatar for bryceburry

There was accidental mixup in variable names in woooee's answer. def checkAll(char): wins_list = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]] for first, second, third in wins_list: if check_line(ch, first, second, third): return True

Member Avatar for TrustyTony
0
445
Member Avatar for Sasquadge
Member Avatar for Sasquadge
0
1K
Member Avatar for TrustyTony

The forum does not seem to accept url with () http://www.daniweb.com/software-development/python/threads/434692/python-launcher-doesnt-work#post1866059

Member Avatar for deceptikon
0
152
Member Avatar for dboxall1234

What kind of she bang line you got? http://www.google.com/search?q=python+shebang+mac

Member Avatar for dboxall1234
0
749
Member Avatar for supravat

Did you use Google 'py4A bluetooth' that finds for example this http://www.slideshare.net/george_goh/pycon2011-android-programmingusingpython see page 33 example.

Member Avatar for M.S.
0
312
Member Avatar for darkenmac
Member Avatar for darkenmac
0
308

The End.