3,386 Posted Topics

Member Avatar for wizard25

I did recursive Python code for this, which might give you idea. It is not that simple to recode to Prolog, though. http://www.daniweb.com/software-development/python/code/478650/spiral-numbers

Member Avatar for TrustyTony
0
772
Member Avatar for TrustyTony

I [saw interesting problem](http://www.daniweb.com/software-development/legacy-languages/threads/478323/prolog) of generating spiral of numbers and realized I could reuse [my code for rotation](http://www.daniweb.com/software-development/python/code/371536/rotate-sequences-left-or-right) I posted earlier.

3
778
Member Avatar for Joe_6

You pass in `write_csv` an `url`, but I do not understand where those other variables like `final_model_num` are coming.

Member Avatar for Joe_6
0
182
Member Avatar for Gaven

Use variable to remember how many different numbers have been selected and increase that every time new is selected. Store current count of unique numbers with the current counter to dictionary. count_store[this_random_int] = current_count What exactly you want as result, I do not know without example.

Member Avatar for ZZucker
0
398
Member Avatar for cahram
Member Avatar for alyons

I do not really understand what exactly you are after, but for example in this snippet I save a graphics file and load it as BMP file. http://www.daniweb.com/software-development/python/code/371844/mandelbrot-with-tkinter-and-shedskin

Member Avatar for ZZucker
0
9K
Member Avatar for seotheo
Member Avatar for TrustyTony
0
228
Member Avatar for tjames95

Of course you had not previously installed pygame or followed instrunctions:[QUOTE]You may need to uninstall old versions of pygame first. NOTE: if you had pygame 1.7.1 installed already, please uninstall it first. Either using the uninstall feature - or remove the files: c:\python25\lib\site-packages\pygame . We changed the type of installer, …

Member Avatar for Schol-R-LEA
0
2K
Member Avatar for abaddon2031
Member Avatar for dcampbell

Hint: >>> transform = dict((a.strip() for a in pair.split('to')) for pair in 'Therapist to T, Patient to P'.split(',')) >>> counts = dict((a, 0) for a in transform) >>> counts['Therapist'] += 1 >>> print transform['Therapist'] + str(counts['Therapist']) T1 >>> counts['Therapist'] += 1 >>> print transform['Therapist'] + str(counts['Therapist']) T2

Member Avatar for dcampbell
0
248
Member Avatar for chiste91

Sound suspiciously so that you enter loop at keydown and don't exit it at keyup.

Member Avatar for shafaqsajjad
0
11K
Member Avatar for geetylerr

Not most beautiful user interface, but it works for me. Of course, as I am using Python 2.7, I redefined input same as raw_input for it to work, by adding to beginning try: input = raw_input except: pass

Member Avatar for TrustyTony
0
2K
Member Avatar for Manisha_2
Member Avatar for Manisha_2
0
173
Member Avatar for ItsAdZy

The editor question is very personal issue, TAB completion of commands or variable names is for me the main point of IDE. The IDE however changes the environment of running program and running time, so ultimately you must test it also from command line. I have managed quite OK with …

Member Avatar for RogueHaxor
0
1K
Member Avatar for Diego_4

I think it is too cumbersome for user to enter number of task, if you do not print the tasks with number before asking them. Do not use input in Python2 it is too dangerous, use `int(raw_input("prompt"))`

Member Avatar for TrustyTony
0
174
Member Avatar for Rabee_1

By what software you are accessing the braille output to know it is connected well? With https://pypi.python.org/pypi/accessible_output/0.7.5#braille-outputs ??

Member Avatar for iamthwee
0
481
Member Avatar for abaddon2031

1600 entries should not be problem in PC's of today. So why actually you want to do it? Are you really getting memory error? Working in memory is simpler and faster.

Member Avatar for rrashkin
0
234
Member Avatar for eortiz10

I think this is how you should have done it # include <iostream> # include <cmath> # include <string> using namespace std; void fallingDistance2(double &, double); double fallingDistance1(double); const double g = 9.8; double t; double d; int main() { cout<<"calculated by passby values.\n"; cout<<"Time \t\t Distance\n"; cout<<"-------------------\n"; for (t=1;t<=10;t++) …

Member Avatar for klikendish
0
2K
Member Avatar for pittdaniweb

For me the only significant difference except for superficialities (put first statement of for as first inside while and third at end of while and keep the middle one) is that for parameters are optional, while parameter is not, so for( ; ; ) is correct infinite loop but while() …

Member Avatar for rajii93
0
814
Member Avatar for takumi05

You would normally not touch the number, but only format [the way it is printed](http://docs.python.org/tutorial/inputoutput.html).

Member Avatar for nadeem.lalani.3
0
221
Member Avatar for kxjakkk
Member Avatar for knan
Member Avatar for PC

Do not index string without checking that string exist i.e. if my_string: # processing string or use `try...except` block

Member Avatar for Gribouillis
0
186
Member Avatar for abaddon2031

You can read and ignore the first line of other than the first file. I assume then form of these files is exactly same. Something similar to: def files_to_one(new_file, *files): with open(new_file, 'w') as fout: for fileno, fn in enumerate(files): with open(fn) as fin: print fileno, fn first = fin.readline() …

Member Avatar for abaddon2031
0
296
Member Avatar for Nafisa Morsalin
Member Avatar for abaddon2031

I do not understand what you want to ask, your code is reasonable, except I do not recommend to repeat the field names instead of simple assignment using copy method to make fresh copy of dictionary. You may also have chicken and egg problem where to get the first file …

Member Avatar for abaddon2031
0
310
Member Avatar for Diego_4

`'\n'.join(str(element) for element in data)` Where data is iterable sequence you want to show one element per line.

Member Avatar for TrustyTony
0
321
Member Avatar for danielki

First thing I notice is line 9, where you write to new file for writing when file does not exist, even it is just created and can not have anything to read and secondly is opened for writing, not reading.

Member Avatar for David W
0
549
Member Avatar for TrustyTony

Here is simple text file example for beginners, using try..except for reading old content as it may not yet exist.

Member Avatar for TrustyTony
1
473
Member Avatar for BadManSam
Member Avatar for ZJRG.1997

You first want the input as float, then int, later back to str, I think I am not quite sure what you are after. You assign variables with assignement as you have done already with your x,y and z variables. Can you give your code and error message for what …

Member Avatar for Gribouillis
0
217
Member Avatar for debasisdas
Member Avatar for James_28
8
17K
Member Avatar for ram619

No they are different lists with same items. If you want the items also as copies you should use deepcopy http://www.python-course.eu/deep_copy.php

Member Avatar for vegaseat
0
170
Member Avatar for Reverend Jim

I somehow liked also the way Teemu Selänne and team handled the pronze game. Great finishing game for the most valuable player Teemu, couldn't be more proud. :-D

Member Avatar for vegaseat
0
295
Member Avatar for biljith

Doesn't look Python code for me! [CODE]from sys import stdout def rev(a): while a: a, d = divmod(a,10) stdout.write(d) rev(int(raw_input('Give number: '))) [/CODE]

Member Avatar for ReaseySo
0
271
Member Avatar for brittany.nelson.526

local variables of results function are not also defined, maybe you missed parameters?

Member Avatar for TrustyTony
0
322
Member Avatar for Maurice_3
Member Avatar for lewashby

`**` unpacks the dictionary, so the call with `**greens` is same as writing the arguments as given to dict. Format takes keyword arguments with any names and uses them to replace them in curly brackets in the string.

Member Avatar for TrustyTony
0
166
Member Avatar for lfc3798

bin standard function might also be usefull as well as looking to the Code Snippets of certain active members.

Member Avatar for TrustyTony
0
273
Member Avatar for Tcll

We need test cases input/correct output to help you out, if I catch your meaning, mantissa has assumed 1 as first number except when exponent is 0. What is offset of exponent. I would rewrite your nice formulas by writing one function to pop n bits out from least significant …

Member Avatar for Tcll
0
849
Member Avatar for Sarfaraz_1

Yes, considering how you initialize the circular queue, it does not agree with your definition of is_empty, for example. Nothing in your implementation looks like circular queue for me, I do not see head pointer, for example. Actually circular queue does not make much sense for me, when Python has …

Member Avatar for TrustyTony
0
726
Member Avatar for itsnauman
Member Avatar for Rebecca_2

2. Finding the table 3. Copying the table exactly with open('data.txt') as data: data_parts = data.read().split("""Comparison of initial and final structures : --------------------------------------------------------------------------------""") print data_parts[1]

Member Avatar for slate
0
262
Member Avatar for Vish0203

I see similarity to my yoyo range (downvoted even it is :( ) http://www.daniweb.com/software-development/python/threads/282438/yo-yo-for

Member Avatar for wshane796
0
295
Member Avatar for joseph_7
Re: help

Why are you assigning file's read method to variable txt, that is deceptive naming? And you are not using the method anywhere. txt = open(filename).read

Member Avatar for TrustyTony
0
240
Member Avatar for peto29
Member Avatar for Vish0203

I did your task like this, but it can cut the file in middle of the line, and the file will not end with '\r\n'. def create_file_numbers(filename, size): with open(filename,'wb') as f: f.write('\r\n'.join(str(n) for n in range(size//2+1))[:size]) create_file_numbers('testnum.txt', 1000) Bit lazy for the needed range to get to string length …

Member Avatar for TrustyTony
0
163
Member Avatar for bnn678

You do not use full path name nor the .py extension. The file must be at system search path or path pointed by PYTHONPATH environment variable.

Member Avatar for bnn678
0
245
Member Avatar for sh0na
Member Avatar for Fakeyede

I think, if you learn to understand what happens in my program: http://www.daniweb.com/software-development/python/code/439343/recursive-and-iterative-nuggets , you have fair chance of solving this problem.

Member Avatar for TrustyTony
0
286

The End.