3,386 Posted Topics

Member Avatar for novice20

You should add as first condition [CODE]MIO_outports1[i] in map_dict1[/CODE] to only access the other part if i is not in the dictionary. Actually thinking about what you want to accomplish, you just want to do: [CODE]test = any(d[int(MIO_outports1[i])] == int(Exp_map_inport[i]) for d in (map_dict1, map_dict2) if MIO_outports1[i] in d)[/CODE] Propably …

Member Avatar for TrustyTony
0
277
Member Avatar for potchi

os.environ should work normally in Jython: [url]http://www.jython.org/jythonbook/en/1.0/InputOutput.html[/url]

Member Avatar for potchi
0
1K
Member Avatar for cool0329

Use dictionary or (defaultdict or Counter) from collections module if you are using recent version of Python. Post your code with code-tags and error messages for further advice.

Member Avatar for raptr_dflo
0
432
Member Avatar for TrustyTony
Member Avatar for raptr_dflo
0
1K
Member Avatar for WolfShield
Member Avatar for TrustyTony

[I]This is one idea for thread of some lessons learned with experience about asking wrong question and answers 'thinking out of box'. If there is need to have sticky, I suggest that this thread become sticky development thread and moderator can move the upvoted suggestions for next part in new …

Member Avatar for TrustyTony
0
223
Member Avatar for [V]

There is possible to use file as output in print statement, but it becomes cumbersome with many prints. Maybe something like this? [CODE]with open("testfile.txt","w") as myfile: myfile.write("""\ line 1 line 2 line 3 """) with open("testfile.txt") as myfile: print(myfile.read()) with open("testfile2.txt","w") as myfile: for line in ("line 1", "line 2", …

Member Avatar for vegaseat
0
134
Member Avatar for spiritsad

Could you explain your logic for deleteRear as the argument passed to it looks like NULL and if it was passed correct last node it's next pointer would be NULL, so how you are updating the second last node which actualy is needed? Of course after this helper function works, …

Member Avatar for zaraki
0
184
Member Avatar for TrustyTony
Member Avatar for TrustyTony
0
911
Member Avatar for Schol-R-LEA

Did you try to remove that file? ([Error 183] Cannot create a file when that file already exists: 'C:\\Windows\\system32\\config\\systemprofile')

Member Avatar for Schol-R-LEA
0
861
Member Avatar for Ephexeve

Or without modules: [CODE]def callable(f): try: f() return True except AttributeError: return False except TypeError: return False [/CODE] Or you can try to call it and catch exception in your code. But there is the collections.Callable, like vegaseat said.

Member Avatar for TrustyTony
0
278
Member Avatar for Gsx

Line 8 should basically be same as [CODE]if number_entered[/CODE] if number_entered is actually string (as there would be mix up between 0 and False if it were actually number). Notice that something, like generator does not need to be empty, but can produce values, even it has not length. So …

Member Avatar for TrustyTony
0
156
Member Avatar for rssk

You typed wrong, but the way you typed in your message is correct, try again! IDLE 2.6.6 >>> ["ma%d" % n for n in range(2, 5)] ['ma2', 'ma3', 'ma4'] >>> (If you copy code to message push first (CODE) or paint the code and push it afterwards.) You are expecting …

Member Avatar for TrustyTony
0
222
Member Avatar for WolfShield

Are you not letting to take care of that? That is whole point of using StringVar. Of course you can slice out the char at insert point. You have read the code of vegaseat and me from code snippets and sticky messages, haven't you? See the advice linked in my …

Member Avatar for WolfShield
0
1K
Member Avatar for Simplicity.

Could you give it another try. Your formatting is complitly mixed up. Also variables and functions have capitalized names normally recerved for object classes. Try to change names more descriptive and follow Python PEP8 standard when possible if you want help. Otherwise the helper should recode the program to understand …

Member Avatar for TrustyTony
0
195
Member Avatar for vegaseat

Your code is OK, but still I am impressed with this [URL="http://code.google.com/p/mpmath/"]mpmath module[/URL] included in Sympy, which you use for comparison.

Member Avatar for TrustyTony
3
566
Member Avatar for TrustyTony

To be more clear, I post this 'unnecessary optimization' of Vegaseat's code in new thread instead of end of old one. Just to show that this is even simpler than [URL="http://www.daniweb.com/software-development/python/code/363346/1554115#post1554115"]checking if given day is first weekday of the month[/URL].

Member Avatar for TrustyTony
0
1K
Member Avatar for TrustyTony

Little clean up of vegaseat's code for generating pi decimals. Added number of decimals desired and string type return for easy use with ''.join()

Member Avatar for TrustyTony
1
618
Member Avatar for novice20

I can not reproduce the problem, it must be somewhere else: [CODE]list1 = range(6) list2 = range(10,15) adict = dict(zip(list1,list2)) print(adict) """ Output in Python 2.7.1 and 3.2 {0: 10, 1: 11, 2: 12, 3: 13, 4: 14} """ [/CODE]

Member Avatar for novice20
0
232
Member Avatar for Jimmyteoh

And reason of the program and conversion? If you happened to study c++ and haven't learned it yet, there is only one correct answer: start to study it like you should. Others can not study for you. Also you do not give attribution of the original code, so if somebody …

Member Avatar for Nick Evan
0
212
Member Avatar for WolfShield

See decimal package: [CODE]>>> from decimal import * >>> getcontext().prec = 100 >>> Decimal(1).exp() Decimal('2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427') >>> Decimal(1).exp()**34 Decimal('583461742527454.8814029027346103910190036592389411081057829421204316676742119505811471038583648840548') >>> [/CODE] It is missing trig functions however.

Member Avatar for WolfShield
0
321
Member Avatar for WolfShield

Which documents you are using? According [URL="http://effbot.org/tkinterbook/entry.htm"]this documentation[/URL] the key is 'disabledbackground': [QUOTE]disabledbackground= Background to use when the widget is disabled. If omitted or blank, the standard background is used instead. (disabledBackground/DisabledBackground)[/QUOTE]

Member Avatar for WolfShield
0
395
Member Avatar for vmirce

Look here for number formatting: [url]http://www.delphibasics.co.uk/RTL.asp?Name=WriteLn[/url] [QUOTE]After each expression, you can add formatting options: :width Field width for strings + numbers :precision Decimal digits for numbers [/QUOTE]

Member Avatar for pritaeas
0
96
Member Avatar for jum2011

You could implement the [URL="http://en.wikipedia.org/wiki/Rotation_%28mathematics%29"]turtle movements[/URL] using complex number support in Python.

Member Avatar for vegaseat
0
266
Member Avatar for DNHK

I would also use printf format string properly (for example "%30s") instead of gotoxy.

Member Avatar for TrustyTony
0
238
Member Avatar for thekashyap
Member Avatar for thekashyap

How stable and random is the distribution of information you want to hash? Generally it is better idea to test random sample of real data and trying to find what could be the worst case in all input, and could the input change to be even worse fitting than that. …

Member Avatar for thekashyap
0
386
Member Avatar for Real Engineer

[COLOR="Red"]DaniWeb voluntaries help you with 10% of the effort that you show us (and 10% of 0% is not much!) ![/COLOR]

Member Avatar for mohamads
-1
261
Member Avatar for [V]
Member Avatar for Billy D
Member Avatar for kimkim0513

My algorithm would be something like this: 1) generate primes until 100 (100 * 100 = 10000), remove 2 (odd sum with other primes) 2) do double loop marking sums of two integers not marked before until 5000 marked (or just mark all sums 3) check that there was 5000 …

Member Avatar for TrustyTony
0
251
Member Avatar for WolfShield

You could try to click the button to restore the default association or reinstall the Python, it does not take long. Reinstall also reinstalls the Idle to right click menu.

Member Avatar for WolfShield
0
191
Member Avatar for trelokamenos
Member Avatar for mrnutty
0
108
Member Avatar for Python Joe

Worked for me I just changed the name of image to one of minds and defind my_menu as simple print message. The message was printed OK.

Member Avatar for Python Joe
0
499
Member Avatar for TrustyTony
Member Avatar for TrustyTony
1
269
Member Avatar for nighthawk10
Member Avatar for vegaseat
0
296
Member Avatar for Lardmeister

You are changing list, not tuple [CODE]>>> my_tuple (1, 2, 3, [4, 5, 6]) >>> type(my_tuple[3]) <class 'list'> >>> id(my_tuple[3]) 14727328 >>> my_tuple[3][2]=7 >>> id(my_tuple[3]) 14727328[/CODE]

Member Avatar for vegaseat
0
187
Member Avatar for jack4321

There is lots of info in Internet just google or check wikipedia. If you want to experiment (best way), read a tutorial and do stuff with [URL="http://sourceforge.net/projects/lazarus/"]Lazarus IDE for Free Pascal Compiler (FPC)[/URL]

Member Avatar for TrustyTony
0
82
Member Avatar for wiredtoawall

You Assign the file only if choice=1, so choice=2 crashes. It should be more obvious how many books must enter and which number is now. No need to limit program to ten books. Better to search by title than ask number of book. Program should repeat until user wants to …

Member Avatar for wiredtoawall
0
179
Member Avatar for batchprogram

You have control statement with comparison and casts in your code! Also modulus was not allowed!

Member Avatar for rubberman
0
2K
Member Avatar for tax
Member Avatar for tikoti

I do not want to give out solution code to you but the counts of different outcomes from my correct solution (I am tonyjv in projecteuler also, 131 solved problems) are for debugging: Draws 865512042, pwins 7009890480, cwins 4355187942 pwins means Pete wins. And no extra modules were needed for …

Member Avatar for TrustyTony
0
515
Member Avatar for shadowscape

Could you tell how you tested each function during writing the code? We need proof that you did the code, so give us brief pseudo code or add plenty of comments. Surely it is pure chance that [url]http://www.daniweb.com/software-development/c/threads/331884/1417642#post1417642[/url] looks quite similar to your code. You seemed to have forgotten the …

Member Avatar for rubberman
0
201
Member Avatar for Shansal

If you would multiply all values by constant, say 1000000, and divide solution accordingly, maybe it could work out to transform the problem to integer realm.

Member Avatar for Gribouillis
0
290
Member Avatar for Shansal

(Default)Dictionary accessed by the first value could be good place to collet the values... Go ahead and show us your code.

Member Avatar for TrustyTony
0
175
Member Avatar for tucker001

I do not see requirement of writing your own sum, min and max; so you better concentrate finding better system of taking any number of user input. Do not worry about maths if you are really allowed to use standard functions, but input values to list by apppend method. You …

Member Avatar for predator78
0
316
Member Avatar for jero-skyer
Member Avatar for fadi_1234

My C is bit rusty but in pseudo code (max_of_random - min_of__random)/(wanted_max-wanted_min)*random_value +wanted_min

Member Avatar for mrnutty
0
137
Member Avatar for woody0114

One thing you did not have is code-tags. Push the button and then paste your code. You are then more likely to get help as your code is enormously more understandable and faster to read. #include<iostream> #include<string> #include<fstream> #include<vector> using namespace std; void encrypt( char userinput[ ] ); // prototypes …

Member Avatar for woody0114
0
939
Member Avatar for jimmymack

Recomended free IDE seems to be however Code::Blocks for cross platform or Microsoft's free for testing VC Express.

Member Avatar for TrustyTony
0
537

The End.