3,386 Posted Topics

Member Avatar for lewashby

You could also try http://shed-skin.blogspot.fi/ If you have not very flexible dynamic stuff or metaprogramming.

Member Avatar for TrustyTony
0
325
Member Avatar for Waseemaburakia

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: …

Member Avatar for fonzali
0
217
Member Avatar for Caulm64

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.

Member Avatar for sneekula
0
10K
Member Avatar for tayspen
Member Avatar for Mahesh_9

You can write one, and in case of difficulties you can not overcome, you might ask question here in DaniWeb.

Member Avatar for Schol-R-LEA
-1
145
Member Avatar for mrnutty

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 …

Member Avatar for Reverend Jim
0
687
Member Avatar for TrustyTony

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]

Member Avatar for TrustyTony
5
2K
Member Avatar for mima79

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.

Member Avatar for mazharul41
0
705
Member Avatar for a8med

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 …

Member Avatar for a8med
0
174
Member Avatar for dean.ong.14

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.

Member Avatar for TrustyTony
0
499
Member Avatar for dean.ong.14

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.

Member Avatar for pzuurveen
0
209
Member Avatar for booicu
Member Avatar for aditya369

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.

Member Avatar for Nils_1
0
267
Member Avatar for Crazyscript77

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)

Member Avatar for Crazyscript77
0
187
Member Avatar for sinnebril
Member Avatar for Pioggia254

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.

Member Avatar for vegaseat
0
173
Member Avatar for flebber

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], …

Member Avatar for TrustyTony
0
237
Member Avatar for flebber

Use random.sample half the size of dictionary and then find it's complement in keys for the other half.

Member Avatar for flebber
0
542
Member Avatar for TrustyTony

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 …

Member Avatar for fonzali
1
2K
Member Avatar for glao

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 …

Member Avatar for glao
0
193
Member Avatar for Josias_1

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 …

Member Avatar for TrustyTony
0
336
Member Avatar for glao

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()

Member Avatar for glao
0
149
Member Avatar for bnn678

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.

Member Avatar for bnn678
0
374
Member Avatar for talat.zaitoun
Member Avatar for Jacklittle01

> 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

Member Avatar for vegaseat
0
175
Member Avatar for LucyLogic

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.

Member Avatar for vegaseat
0
508
Member Avatar for schroaus

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

Member Avatar for pritaeas
0
377
Member Avatar for laura301019

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))

Member Avatar for vegaseat
0
195
Member Avatar for danielPROGRGAMS

Learn about lists, do not use unique variables. You are not generating the random number yourself like you said, but using the random.randint.

Member Avatar for TrustyTony
0
472
Member Avatar for tinku.cater
Member Avatar for rabowling

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'.

Member Avatar for vegaseat
0
496
Member Avatar for booicu

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 …

Member Avatar for vegaseat
0
3K
Member Avatar for tinku.cater
Member Avatar for Vusumuzi

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

Member Avatar for fonzali
0
244
Member Avatar for ant1vanden

use key parameter with lambda statement or functools.partial or helper function.

Member Avatar for vegaseat
0
171
Member Avatar for marethamogale
Member Avatar for ksekwamote
Member Avatar for Bhavya scripted

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).

Member Avatar for TrustyTony
1
473
Member Avatar for talat.zaitoun

Your usage says it takes grades and weights in order, your snippet would do something completely different, if we fix the indention problem first.

Member Avatar for slate
0
177
Member Avatar for antonio.neal.39

As long as you use Python3, this should run. Use the `after` method and `winfo_x()` method.

Member Avatar for antonio.neal.39
0
296
Member Avatar for matthew.s.thomas.14

But if you are concerned on case of the word, I would use the lower() method of strings.

Member Avatar for TrustyTony
0
133
Member Avatar for nytman
Member Avatar for MrNoobieCoder
Member Avatar for MrNoobieCoder

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.

Member Avatar for MrNoobieCoder
0
276
Member Avatar for williampalme

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.

Member Avatar for TrustyTony
0
290
Member Avatar for supriya badam

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 …

Member Avatar for irum.nageen.3
0
2K
Member Avatar for RHNation
Member Avatar for bright.silva

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.

Member Avatar for bright.silva
0
272
Member Avatar for varun mahawar
Member Avatar for TrustyTony
0
117
Member Avatar for dp121307

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.

Member Avatar for TrustyTony
0
697

The End.