3,386 Posted Topics

Member Avatar for Cyl11

Maybe this is too much help, but here anyway. You could retype the keys instead of selecting from list, but it is good practice to avoid stupid typing mistakes to assure same spelling: [CODE]from pprint import pprint students = ['Joe', 'Jenny', 'Tom'] courses = ['MATH101', 'COMP202', 'BIO101'] students_courses = {students[0]: …

Member Avatar for Cyl11
0
133
Member Avatar for now how abt tht

This is how it works for me: [CODE]#include <stdio.h> #include <stdlib.h> int main(){ int *n, m = 2; *n = 5; printf("Numbers *n: %i m: %i", *n, m); n = &m; printf("\nNumbers *n: %i m: %i", *n, m); return EXIT_SUCCESS; } [/CODE]

Member Avatar for jnawrocki
0
134
Member Avatar for Rupindersingh

I think there is nothing you can learn better in DOS (Dirty Operating System, wasn't it :icon_twisted:) environment than Windows. I would suggest you partition your hard disk and run Linux for alternative environment for nice way to do things. DOS has so little support for youtr programs that you …

Member Avatar for Adak
0
432
Member Avatar for abders

You must give write string argument. [CODE]print "creating a text file" # 'w' mode creates new file with open("write_it.txt", "w") as text_file: score = 5 name = raw_input("What's your name?: ") text_file.write("%s, %s" % (score, name)) [/CODE]

Member Avatar for abders
0
993
Member Avatar for aint
Member Avatar for JoshuaBurleson
Member Avatar for hughesadam_87

Exclude -Wno-longHdouble should mean that you should [b]not[/b] have it and you have not. Are you sure that the makefile does not work as is? Maybe you have ready binary compiled with other flags (including the flag).

Member Avatar for TrustyTony
0
84
Member Avatar for Gaving30

I would say that biggest possible factor is third or 7th of the non-prime odd number not ending with 5.

Member Avatar for TrustyTony
0
444
Member Avatar for TrustyTony

Again "pseudo-code" for [URL="http://www.daniweb.com/software-development/cpp/threads/379255/1632559#post1632559"]C++ program[/URL]. Quite primitive and simple, but I post it anyway. Generalized to take even even number as parameter.

0
132
Member Avatar for d3zz

Difficult to understand your goal, but here is something running end result of playing with it: [CODE]#! /usr/bin/python from Tkinter import * from functools import partial def p(lol): buttons[lol]["text"] = 'Hi from %i!' % lol def plade(root): for n in range(0,4): buttons[n] = Button(root, text= 'Button%i' % n, command=partial(p, n)) …

Member Avatar for d3zz
0
260
Member Avatar for tristanbacon

[CODE]deck= [(value, suit) for value in values for suit in suits)] random.shuffle(deck) [/CODE] dictionary is not appropriate, use list.

Member Avatar for TrustyTony
0
250
Member Avatar for Creatinas
Member Avatar for TrustyTony
0
44
Member Avatar for zpzp16

For example [CODE]z = [item for item in x if item not in y][/CODE] should work if you do not want sets. If you want set difference this should work (can not test in my mobile) [CODE]z = set(x)- set(y)[/CODE]

Member Avatar for woooee
0
143
Member Avatar for tky
Member Avatar for cse.avinash

Sum of logarithms looks more attractive, but to 10**9 takes still time. I did timed loop in my favorite language and it took 7.198 s to calculate value 65657060 for 10**7 and that is still two decades down. Result was accurate at least for 10**5 (456574), which is OK to …

Member Avatar for TrustyTony
0
280
Member Avatar for Thropian

In stackoverflow there was code on how to use complex numbers for rotation of polygon: [url]http://stackoverflow.com/questions/6481170/trying-to-rotate-a-triangle-with-complex-numbers-in-tkinter-python[/url] And ActiveState explains how to change oval to polygon for rotation: [url]http://code.activestate.com/lists/python-list/161757/[/url] You might be better off using for example pygame: [url]http://pygame.org/docs/ref/transform.html[/url]

Member Avatar for TrustyTony
0
1K
Member Avatar for IconceptBhuvan

Audacity does support: [CODE]Sun Au / NeXT This is the default audio format on Sun and NeXT computers, and usually u-law compressed, so it is not a very high quality format. U-law compression is a very simple, fast but low quality way to reduce the size of the audio by …

Member Avatar for TrustyTony
0
97
Member Avatar for Cheerios

[LIST=1] [*] read files in loop [*] for each file split lines containing ' - ': [/LIST] [LIST] [*]use first value for key to dictionary [*]split and convert second value as list of floats (maybe you should consider numpy array, makes sum easier) [ if key is in dictionary add …

Member Avatar for TrustyTony
0
213
Member Avatar for aragonnette

I get error from import workerpool. Looks like not standard library. Installed it with pip, and changed little code to see what happens, looks like it does a lot at least, when moving shutdown after collecting workers. [CODE]import os import urllib from datetime import datetime import workerpool class DownloadJob(workerpool.Job): def …

Member Avatar for aragonnette
0
213
Member Avatar for g_amanu

You do not do looping but let numpy to do matrix operations, when using numpy. I think nums should contain numbers instead of strings and that you should not add [] to it for anums but keep same dimensions as nums. [CODE]import numpy a = [1, 2, 34, 54] mean …

Member Avatar for g_amanu
0
7K
Member Avatar for Anuradha Mandal

1 has not prime factor 2,3 or 5. If you had all numbers less than n satisfying the condition available, could you use those numbers to produce numbers which also satisfy the condition and are bigger than or equal to n? Don't you know which numbers less than 6 satisfy …

Member Avatar for WaltP
0
137
Member Avatar for SpiritualMadMan

Does not make sense for me, maybe with some kind of design diagram I could find sane implementation. But from your verbal explanations I could not make it, maybe some native English speaker is able to. Here is result of trying to catch the meaning of code and commenting out …

Member Avatar for SpiritualMadMan
0
147
Member Avatar for uvaryani

Just paste your code after pushing the (code) button, include full erroo mesages and explain what you tried to fix it.

Member Avatar for woooee
0
285
Member Avatar for needpython_help

I have no problem with your sample info with simple Python way without unnecessary complications: [CODE]data = """ 1302971105851,Sat Apr 16 17:25:05 2011,3318,Call received,XXXXXXXX 1302991884760,Sat Apr 16 23:11:24 2011,3319,Call received,XXXXXXX 1303018741819,Sun Apr 17 06:39:01 2011,3320,Call made,XXXXXXXX 1104770564325,Mon Jan 3 16:42:44 2005,1,Text received,From3 1104770734612,Mon Jan 3 16:45:34 2005,2,Draft text,None 1312544050806,Fri Aug …

Member Avatar for Enalicho
0
858
Member Avatar for TrustyTony

Here is simple math program to list number whose all factors are in given set of factors. I have included my timing decorator, which uses my timestring function, so I included that and imports for decorator in the decorator function, bit against the rules. Of course I could have used …

0
274
Member Avatar for JoshuaBurleson

I would do something like: [CODE]class Switch(object): def __init__(self, on=True): self.on = on self.off_word = 'off' def turn_off(self, key): self.on = key!=self.off_word def __str__(self): return "Switch(on=%s)" % self.on myswitch = Switch() while myswitch.on: myswitch.turn_off(input('Enter a word: ')) print(myswitch) [/CODE]

Member Avatar for Enalicho
0
242
Member Avatar for nuclear

I copy pasted your code in empty project in Lazarus and it run without error: [CODE]program Project1; {$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Classes { you can add units after this }; {$R *.res} var arr : array of integer; begin WriteLn('Hi!'); Readln; end.[/CODE] Also I run as …

Member Avatar for Duoas
0
127
Member Avatar for clousot
Member Avatar for kayoh

Something like: [CODE]class Processor(object): def __init__(self): self.byte0 = 0 processor_count = 4 processors = [Processor() for count in range(processor_count)] for j in range(4): print processors[j].byte0 [/CODE] or [CODE]class Processor(object): def __init__(self): self.byte0 = 0 def __str__(self): return '%r, byte0 = %i' % (self, self.byte0) processor_count = 4 processors = [Processor() …

Member Avatar for kayoh
0
288
Member Avatar for gge18

No you haven't got it yet: [CODE]>>> f = FrequencyList() >>> f [] >>> f.add('a',3) Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> f.add('a',3) File "K:/Tony/shannon_game.py", line 48, in add self.head = Node(Frequency(letter, 1)) NameError: global name 'Node' is not defined >>> [/CODE] I fixed it but …

Member Avatar for CoscNinja
0
426
Member Avatar for fingerpainting

Usually you must limit operations very much, to simlify things. see: [url]http://www.genetic-programming.com/gppreparatory.html[/url]

Member Avatar for TrustyTony
0
198
Member Avatar for aragonnette

You must use locale and cmp parameter for sorting: [CODE]# -*- coding: cp1254 -*- import locale print locale.getlocale() locale.setlocale(locale.LC_ALL, locale='Turkish_Turkey') print locale.getlocale() names = 'Mary, Adam, Jane, Sall, Istar, Omar, Paul, Ulla, Zackarias, Örnek, Şelale , İstanbul, Ürgüp'.split(', ') print ','.join(sorted(names)) print ','.join(sorted(names, cmp=locale.strcoll)) [/CODE]

Member Avatar for TrustyTony
0
345
Member Avatar for g_amanu

This worked for me as I put some excel files with three colummns of numbers starting at row 21 in sheet 'RawTrackingData': [CODE]import xlrd import os path = 'data' with open('Trying_excel.csv', 'w') as f: column_values=['', '', ''] for filename in os.listdir(path): fullname = os.path.join(path, filename) if fullname.endswith('.xls'): print('Handling %s' % …

Member Avatar for g_amanu
0
2K
Member Avatar for g_amanu
Member Avatar for Gribouillis
0
1K
Member Avatar for casper1

Divide by 8 and reverse the remainders. Don't steal other's thread, please but start new one of your own!

Member Avatar for casper1
0
234
Member Avatar for theguitarist

[QUOTE=Narue;1628631]No, that's a positive number. Don't confuse bit shifting with multiplication, especially when it comes to negative quantities. That depends on whether the left hand side of the expression is signed or unsigned. If it's signed, the vacated bits are filled with the sign bit. Otherwise, they're filled with 0.[/QUOTE] …

Member Avatar for Narue
0
163
Member Avatar for Tomashqooo

I can not reproduce your problem: [CODE]try: from tkinter import * except ImportError: from Tkinter import * root = Tk() frame = Frame(root, width=640, height=480) frame.pack() #now to change the frame size frame.configure(width=200) mainloop() [/CODE]

Member Avatar for TrustyTony
0
166
Member Avatar for braveahmat

My idea: Avoid tricks with dlls and use [URL="http://ironpython.codeplex.com/"]IronPython[/URL]

Member Avatar for TrustyTony
0
51
Member Avatar for Simplicity.

Clean up your code, if you want response, by using sensible variable names, not using meaningless functions like [CODE]def Initialize(v): return v [/CODE] which is equivalent of simple v and does not create Initialize object like name suggest. Also please put first imports, global constants, then function definitions and at …

Member Avatar for TrustyTony
0
135
Member Avatar for Neilzepan

I think the example result is wrong as you do not want to stay at year 1885 with 0 gram plutonium, but to come home without jury rigging a steam train! Your problem is that you take year from listo, but instead of using it and keeping track which you …

Member Avatar for TrustyTony
0
122
Member Avatar for sravanthi89

Only strange thing I see is print line in exist case, which has twice % instead of tuple: [CODE] print( '"%s" exists in the list at index "%s"' % (f_exists, f_in)) [/CODE] Just enable the while loop, fix exit, fix little output format and you are done.

Member Avatar for sravanthi89
0
78
Member Avatar for mason79

That's what Daniweb is about, even I do not know matlab, it is likely that somebody will, just post your code and describe your problem in detail. Also be carefull to give impression of effort you have given to solve the problem yourself, then you are more likely to get …

Member Avatar for Aviras
1
70
Member Avatar for FutureDev86

@pyguy62: unfortunately you had much to correct here my fast work over of your code, basically you are continueing to change the classes instead of having instances. Also you mix too much your output inside the program logic. [CODE]from __future__ import print_function import random try: input = raw_input print('Welcome Python2 …

Member Avatar for TrustyTony
0
323
Member Avatar for D33wakar

There could be usefull and easier stop condition based on num considering line: [CODE]num=num/10;[/CODE] for loop and the i variable are not good fit for the purpose. I suggest while instead.

Member Avatar for TrustyTony
0
453
Member Avatar for rajesh kannan

You could do worse than use Python ([url]www.python.org[/url]), but many languages would work. But you have to get mind set of programming and logical thinking first.

Member Avatar for TrustyTony
0
34
Member Avatar for jbrandon52

if the result off query would be independant of the one asking I would produce web page of results and give that to others requesting the information other either with password or checking for trusted domain (could be faked but sequrity was not so big concern). It is also possible …

Member Avatar for Gribouillis
0
469
Member Avatar for aiwasen

Some definitions of best combo could be: [LIST=1] [*]Does not crash too often. [*]Is not insufferable slow doing things (like compiling for many minutes or running your program many minutes) [*]You agree with the philosophy of the system/language. [*]You get other users/companion developers to use (usually biggest hurdle). [/LIST]

Member Avatar for Rashakil Fol
0
255
Member Avatar for tubby123

It is of course heavy operation, but I think that would basically mean producing new string with two letters added instead of one letter for replacement. In this case, for my opinion, clearest is to use copy anyway. You could copy whole string segment in one memcopy type operation by …

Member Avatar for Narue
0
123
Member Avatar for aiwasen

You might like to look into OpenBOOT which provides facility for FORTH programming at BIOS BOOT level. [url]http://www.openfirmware.info/Open_Firmware[/url]

Member Avatar for johnmiller48
0
86
Member Avatar for Niles64

data is different variable than __data. [CODE]class Test(): __data = 1 def output(self): print self.__data def set_data(self, value): self.__data = value # set public class variable for class Test Test.data = 3 my_test = Test() my_test.data = 2 print 'Class data changed for instance my_test', my_test.data my_test.output() my_test.set_data(5) my_test.output() your_test …

Member Avatar for TrustyTony
0
208

The End.