3,386 Posted Topics
Re: Check your identifiers: http://www.developer.com/lang/other/article.php/626321/Learn-to-Program-Using-Python-Variables-and-Identifiers.htm | |
Re: You are still far off. Repeat the basics, read the assignment and explanation you got. | |
Re: type("string"). type("int"). Maybe? You do not really explain what you are really doing so we can not know. | |
Re: I do not see much difficulty for program itself for the way you have put the variables, only thing is that you have lot of Class variables that normally are to be avoided as much as possible. Maybe you should look at putting data to a configuration file http://docs.python.org/2/library/configparser.html | |
Re: return should be in place of break, I think. Also rounding to 2 decimals does not make sense after so small tolerance for error, generally you also do not round, you just format the printing. | |
Re: Post your code if you get stuck, do not forget any error messages and explanation how you tried to solve the problem you stuck with. Also make sure that all parts are fully tested before you add code one small bit at a time, so you know that bug is … | |
Re: Why would you not describe the task you have, what have you done, your ideas how you plan to do the rest of it? For example the test cases you have prepared for your coding. Then we can give some ideas to get you going. | |
Re: *@KaeLL* > Since usually the main constraint in C++ is performance This is not true, it is compiled language and still this is not normally the case even in interpreted language like Python I am mostly using. The main constraint is overcomplicating things, hard coding, making unreadable or too long … | |
Re: You might be interested in my code snippet from two years ago: http://www.daniweb.com/software-development/python/code/293490/text-file-based-information-access-by-field-name-and-number | |
Re: Nice woooee, bit nicer still if you include self.next_card = 0 in shufle_deck method and we should check when deck is dealt completely by catching index error from deck. other maybe more common method would use pop from list of cards, which makes running out of cards bit more obvious. | |
Re: You can only index array module array by integer position, I do not see why you would choose to use it. | |
Re: > I would recommend using the random.shuffle() function on the series of questions; however, to do that, you'll need to make a small change, which is to make the outer tuple holding the question-answer pairs into a list. And why should he, works for me OK with tuple, but I … | |
Re: Why are you using numeric module? Remakably similar code to http://www.stealthcopter.com/blog/2010/01/python-cryptography-decoding-a-caesar-shift-frequency-analysis/ | |
Re: Just do the black triangles on white background or vice versa. | |
Re: I would not call it absolute beginer's more like copy paster's http://mail.python.org/pipermail/tutor/2006-February/044870.html Or you are really long time beginner. | |
Re: Your indention is incorrect use code button to insert code or data files. | |
Re: If you want to do integer math only, multiply first. I do not understand what you are meaning with the formula of yours (60s cancel) You want to do fraction of day from the difference in day lengths? | |
Re: http://docs.python.org/2/tutorial/index.html (also in IDLE help) is quite nice tutorial. When you have gone through that, you should have fair grasp of the language. | |
Re: python.org tutorial is nice one to get you started http://docs.python.org/2/tutorial/index.html (also in IDLE help) height_in_meters is not `height * 2.54` but `height * 0.0254` and you need two stars to raise to power. | |
Re: Yes join does fine, here I have mocked the run finding to isolate this function from your implementations of runs. It does not make sense to save actually any other info than the first value in data it is alternating between 1 and 0. Also I am wondering wjat happends … | |
Re: Why you do readlines as you only use first one? | |
Re: I still think it is good idea to just send them download link for Python3 installer and your code to them. They just run installer and open your code. If you put it with .pyw extension they do not get the console window for GUI stuff, for console stuff use … | |
Re: There seems to be a module you can install for that http://www.hardcoded.net/articles/send-files-to-trash-on-all-platforms.htm | |
Re: That is [relative import](http://docs.python.org/2/tutorial/modules.html#intra-package-references) | |
Re: Copy pasting same if statement 4 times is not proper effort, you should test your code and ask only about the last addition. | |
Re: l see nothing about search in your code. | |
Re: Here for debugging few test cases to get you started: >>> b = Box(1,2,3) >>> b.volume 6 >>> b.area 22 >>> b = Box(5,2,3) >>> b.area 62 >>> b.volume 30 >>> | |
Re: What do you mean do not work? What is the error message, what versions of wx you have installed in Python 2.7 and what in Python 3. Are you sure you switch between the versions properly (wxversion.select)? | |
Re: Line 2 does not make sense, what is your algorithm? | |
Re: Related article is my code on subject which got me price in summer code snippet competition, you can compare with that. | |
Re: Hint how many lines you can find that has exactly 4 commas and end up having 5 values in list? | |
Re: What happens to total variables when for loop advances to next iteration? | |
| |
Re: # add jpg, tif or png and the folders to the newLst newLst += [file for file in thisdir if os.path.isdir(file) or file.endswith(('.jpg', '.tif', '.png'))] | |
Re: Could you give short example with one type and some values to show what you are really doing, I do not understand. (So otherwise I would say you are completely wrong, but I am not really OO expert) | |
Re: @RichJohnson: what is your answer's connection to raghuvbhat's question? | |
Re: I see no SQL in your code and the functions are never called. I would write: def writelogfile(a, strg): logging.debug(strg + (' function completed', ' function started')[a]) | |
Now that MITx first test is over, I got feeling that this one task requested for generate and test solution is begging also for less efficient recursive solution as it is so simple. Here it is! Single liner aproved by the released grader! If you wander if you are able … | |
Re: also anything or 'no' is always True as 'no' is not empty string. | |
Re: sorry woooee: set drops multiple vowels, doesn't it? >>> test_sentence="The quick brown fox" >>> vowels = set('aeiou') >>> vowels_counts = Counter(c for c in test_sentence if c in vowels) >>> print max(vowels_counts.items(), key = lambda x: x[1]) ('o', 2) | |
Re: No your program does not make sense for me, why would you do def resetPassword(): global password password = '' resetPassword() Instead of password = '' And you are using global everywhere and do not pass parameters in and return values out of funcitions. | |
Re: My 2 c: Your rooms should be instances of Room class. You are messing around and everything is mixed up. Use dictionary of Room and make \__hash__ for Room so room instances can be used as keys of dictionary. | |
Re: For me it is confusing to call funciton printbye, when it only sets one instance variable. I would try something like this, which delegates the messages to message attribute class MessageObject(object): def __init__(self, message): self.message = message self.__name__ = 'MessageObject' def __str__(self): return str(self.message) def __repr__(self): return '%s(%r)' % (self.__name__, … | |
Re: I think you should also call your main function ;) Luckyly the sum can not be the 6-tuple of numbers as the sum or point variables do not change inside the while at line 14. sum is also bad name for variable as it is used for function to do … | |
Re: This test question for MITx course should not be discussed before ending of the test period Nov 4. I can just say that you should do the first problem of debugging the fixedPoint before trying to use it in following parts. | |
Re: #Membership rules ##Keep It Organized * Do provide evidence of having done some work yourself if posting questions from school or work assignments | |
Re: To do it recursively as you code, I would use recursive generator with for: >>> def exponents(num1,num2): if (num2==0): yield 1 else: for r in exponents(num1,num2-1): yield r yield num1 * r >>> list(exponents(2,3)) [1, 2, 4, 8] In iterative version you could yield each subresult, or append to list … |
The End.