3,386 Posted Topics
Re: You could also try http://shed-skin.blogspot.fi/ If you have not very flexible dynamic stuff or metaprogramming. | |
Re: The functions here looks little over complicated, here the counting by fives version of mine. def count_fives(n): if n > 0: count_fives(n-1) print(n*5) count_fives(4) """Output: 5 10 15 20 """ Recursive multiplication by addition: def multiply(m,n): if n < 0: return -multiply(m, -n) elif n == 0: return 0 else: … | |
Re: compare number to saved smallest and biggest numbers and update accordingly. Why you need math.pow to do simple number * number and why do you need to do it twice? Test first this code is correct before expanding it further. | |
Re: You can write one, and in case of difficulties you can not overcome, you might ask question here in DaniWeb. | |
Re: I was dully my own first name and middle initial due to populárity of the name. Then I joined my favorite language sign with my name and the combination happens to be Python in Polish, so why not. (even I have not much connection to that country). Also python (the … | |
There is free tools to do the same, but I was curious to see what it takes to make one myself. For info see: [url]http://en.wikipedia.org/wiki/LC-3[/url] | |
Re: You have not operations to handle persistence through class, so I would modularize out the persistence and user interface and use OOP as 'type definitions for recipe objects' to use as any normal type in program. | |
Re: Your use of antal is strange, you save it as self.antal, but after that you seem to not refer it anywhere. What kind of result you would expect from alla_värden? Usually we use CapitalizedName for classes to separate them to instance variables. So AllaVärden, and you would make an instance … | |
Re: You need to make your own solution, not copy hoping it works, you must try to also understand and adapt the code to your use. | |
Re: I would think Python interpreter would not like this stuff you posted to Python forum (as well as your other PHP post), moving this also to PHP forum. | |
Re: module numbers you import seems not to be iterable. | |
Re: If you would use the 4 space indent, you would have more chance for people to like them. Also code snippet belongs to code snippet, not question. | |
Re: This would be much simpler without the 'fake constant named all uppercase variables' for i in xrange(int(self.hits_entry.get())): time.sleep(int(self.delay_entry.get())) webbrowser.open(self.link_entry.get(), new=0, autoraise=True) | |
Re: You did not give correct arguments as explained by usage message. | |
Re: When you have received answer, you mark thread solved. You can of course also upvote and even add comment and give/take reputation if you have power to do so. | |
Re: You must use function inside list comprehension: import random d = (1, 2, 3, 4, 5, 6, 7, 8, 9) userVal1 = 3 userVal2 = 4 x = [[random.choice(d) for i in range(userVal1)] for j in range(userVal2)] print x """ Output: [[2, 4, 7], [6, 8, 2], [2, 7, 2], … | |
Re: Use random.sample half the size of dictionary and then find it's complement in keys for the other half. | |
Here little debugged version of my calculator posted earlier in GUI calculator thread. I prepared it after listening that their teacher did more limited calculator in around 150 lines of code with their graphics module. This is 115 lines without empty lines and comment lines [CODE]>>> li=[i for i in … | |
Re: You are not passing the count to the function, so it does nothing similar, count is normally given value in return statement, in which case it's value is not 0 at the beginning of the function. The effect of the default parameter is only to take out the need for … | |
Re: Rethink your logic, you can not loop every character of the file but every line, so iterate the file object to get those or pass list of lines. You can use recursion for line split or you can just slice the line, but you must save the slice current line … | |
Re: The better practise generally is to return value and print the value, not print inside function. So if you have choise keep the call and make the function to return the value otherwise remove the print from calling it, just do not forget the parenthesis after name function_name() | |
Re: Is not syntax error but does not make any kind of sense ot do bitwise arithmetic with boolean: (isinstance( test/divisor, int )== True) & (test/divisor == int < 2) You should be using `%` (modulus operator or remainder) and integer values. | |
![]() | |
Re: > and len(data) > 0 Only way len not to fulfill this condition is data to be empty value, which is False value in Python, so the condition could be and data | |
Re: I do not think the original poster's numbers are supposed to be unique so better use random.randint, but notice that both ends of range are inclusive so one must be odd, another even to give equal chance for even/odd. | |
Re: It is often also called asin instead of ArcSin, but looks like it is ArcSin in Delphi: http://www.delphibasics.co.uk/RTL.asp?Name=ArcSin | |
Re: for statement iteration is only for reading, for writing it is recommended to use with statement for safe opening and closing of the file. with open("ignorelist.txt", "w") as fout: fout.write('\n'.join(my_ignorelist)) | |
Re: Learn about lists, do not use unique variables. You are not generating the random number yourself like you said, but using the random.randint. | |
Re: Good luck, return with your code if you get stuck. | |
Re: I got it working (except those pause values of course doing nothing, it only has value None from the assignment in beginning at line 3) by removing all nonsensical break statements. I only find it hard to understand the logic, why it says you are girl, when I answer 'boy'. | |
Re: If it fits you, you can do everything in single line. It is only one way, and what is best depends on your use/experience. import random print('{odd} odd out of 100.'.format(odd=sum(random.randint(0,99)& 1 for count in range(100)))) Take care of the fact that random.randint includes values at **both endpoints** of the … | |
Re: My program is here if you want to compare http://www.daniweb.com/software-development/python/code/287950/classic-number-guess-game-python-ternary-operator-demonstration | |
Re: use key parameter with lambda statement or functools.partial or helper function. | |
| |
Re: Check the first answer in Python in the forum of that question. It does it properly (not allowed to post it here), using two lists of months like you (not total from beginning of year but lengths of each month). | |
![]() | Re: Your usage says it takes grades and weights in order, your snippet would do something completely different, if we fix the indention problem first. |
Re: As long as you use Python3, this should run. Use the `after` method and `winfo_x()` method. | |
Re: But if you are concerned on case of the word, I would use the lower() method of strings. | |
Re: Use function with parameters and return statement | |
Re: Looks very clean way to input integer. | |
Re: You can ignore lines until 10 of Vegaseat's code if you are using Python 3, otherwise you can use `raw_input` instead of `input` on line 16. I would recommend this style though as I practise same style myself to get code function in both Python versions. | |
Re: I do not see any questions to answer, so I think you will need to wait until you show what you have done and where is the problem, and how you have tried to solve it by yourself. | |
Re: There is two possible meanings for string: 1) pointer to char to memory location starting textual information, generally pointers would be same size all 2) the actual text pointed by the pointer to char, which could be simple name or novel. Typically space would be reserved dynamically by malloc family … | |
Re: Your functions do not return any value. | |
Re: I understand otherwise than why you have strings data given but your example result is talking numbers '12' is not same at all than 12. You do must post any you own effort before expecting help, you might find builtin function zip useful. | |
| |
Re: Your concept looks strange, as you are anyway putting those in standard set. You initialize self.grade as empty list and it stays so, grade given to Dataset you ignore. |
The End.