2,190 Posted Topics

Member Avatar for slasel

In addition to lambda, you can also use partial to pass a variable indicator to a function. Also, using pack() and grid() in the same program leads to unpredictable results. from Tkinter import* from functools import partial root=Tk() root.title("Replicate DNA yourself!") def inn(variable_passed): positions = ((10, 10), (60, 50), (110, …

Member Avatar for vegaseat
0
286
Member Avatar for bobys

In Tkinter is would just be top.title("New Title") Or use a Label and Entry box if you have several entries and want a separate title/label for each one. Ah, you are using input, i.e. the console > x= input("blah blah blah") then you would just print a line to get …

Member Avatar for bobys
0
331
Member Avatar for eternalcomplex

Start with the deck class by itself. A hand would be a list of cards dealt from the deck, so you can have as many lists/hands as you want. Something to get you started class Deck(object): def __init__(self): suits = ('C', 'S', 'H', 'D') ranks = ('A', '2', '3', '4', …

Member Avatar for TrustyTony
0
481
Member Avatar for Aoi.Ragnarok

First, use a dictionary or list of lists to hold the question and answers instead of 100 if statements. I assume you don't know about dictionaries yet so this uses a list of lists. words = [['ano', 'um'], ['ima', 'now'], ['eego', 'english']] random.shuffle(words) for this_question, this_answer in words: print (this_question) …

Member Avatar for woooee
0
154
Member Avatar for kevin.deasis.1

What does "won't work" mean? Also, use a list that you pass to the functions instead of the global variables, a1, a2, etc. You are comparing a 3 item sub-list in done to a list that is 4 items which will never be equal. done = [['a1','a2','a3']] for testing in …

Member Avatar for woooee
0
405
Member Avatar for dean.ong.14

You want to use numberAsked in the while loop instead of while len(Questions) > 0 : Also, you can use random.shuffle on the Questions list and then take them in order instead of deleting and checking for length.

Member Avatar for dean.ong.14
-2
173
Member Avatar for ashley9210

This will give you a general idea of how to start if I understand what you want. def drawRectanglePatch(x, y): win = GraphWin("Test", 300, 300) for i in range(10): for j in range(10): topLeftX = x + i * 10 ## topLeftY = y + j * 10 incr = …

Member Avatar for woooee
0
198
Member Avatar for ashley9210

It is not obvious what you are trying to do. Nor is it obvious what GUI toolkit you are using, although it is not Tkinter or Wx which is all that I use, so we can not run your code (no imports posted). If you are trying to draw the …

Member Avatar for woooee
-1
94
Member Avatar for ashley9210

You should be using "x" and "y" passed to the function for your start position instead of the hard coded one. You can then pass a different x, y (start) to the function, assuming you are always drawing the same size triangle. In Tkinter (which doesn't look what you are …

Member Avatar for woooee
0
494
Member Avatar for biscayne

> def replaceVariablesWithCsvData(self, headerRow, row, lines): # lines as list of strings This function does not create a list. It creates one long string. For more precise help come up with a simple example and some test data so we can see what happens compared to what should happen.

Member Avatar for biscayne
0
2K
Member Avatar for nUmbdA

See the definition for append mode = "a" [Click Here](http://www.tutorialspoint.com/python/python_files_io.htm) which explains why checking is not necessary.

Member Avatar for ZZucker
0
117
Member Avatar for anonymous0318

You have to add the last group, and note that the counter is initialized to one since we are comparing this pixel to the next pixel, so this pixel is the first in a series. __You should also test your program with the first 2 pixels different and with the …

Member Avatar for woooee
0
224
Member Avatar for fdama

Ask the user to enter a number to be guessed say between 1 and 100. The computer selects a random number in that range. If the computer guesses too low, then that number+1 becomes the lower number in the range for the next random number to choose from and so …

Member Avatar for woooee
0
269
Member Avatar for crazyjdog

> the problem is that the program creates an empty file >Not sure what to do next Test your program (note that the file is not technically "empty") def main(): inpath = input("Enter an input file: ") line = input("Enter what you want to remove: ") outpath = input("Enter an …

Member Avatar for woooee
0
104
Member Avatar for HiHe

The epoch is OS dependent and has nothing to do with Python. Since we don't know what OS you are using the question can not be answered except to say print gmtime(0) and see what it tells you. 28800 seconds is something like 8 hours so it may be the …

Member Avatar for HiHe
0
390
Member Avatar for pashah

First, read the [Homework Help](http://www.daniweb.com/software-development/computer-science/threads/573) thread. Look at one of the [Python Tutorials](http://wiki.python.org/moin/BeginnersGuide/Programmers) for assistance as this is pretty basic stuff that is included in most tutorials. Feel free to post back with specific code problems for help.

Member Avatar for pashah
0
176
Member Avatar for Matigo

This doesn't have anything to do with Python. See if the task manager gives a create time or does something simple, like number the processes sequentially so you can tell which is which. Perhaps someone else will know something more about Visual Basic and the Task Manager.

Member Avatar for Lardmeister
0
1K
Member Avatar for nUmbdA

You should first test the calc_average function. `print calc_average(75, 75, 75, 60, 90)` Also you might want to convert to a float which depends on the version of Python you are using.

Member Avatar for Lardmeister
0
333
Member Avatar for woah123

First read http://www.daniweb.com/software-development/computer-science/threads/573/we-only-give-homework-help-to-those-who-show-effort then see if it is the same homework problem as http://www.daniweb.com/software-development/python/threads/439588/python-data-extraction-help or http://www.daniweb.com/software-development/python/threads/439504/converting-a-list-to-a-a-string-of-integers

Member Avatar for woah123
0
206
Member Avatar for nickick
Member Avatar for woooee
0
218
Member Avatar for Triarius_1

This thread appears to use the same data, and so is probably the same homework problem as http://www.daniweb.com/software-development/python/threads/439504/converting-a-list-to-a-a-string-of-integers We should perhaps combine them into one. > ['ID ', ' Last ', ' First', ' Lecture', ' Tutorial', ' A1', ' A2', ' A3', ' A4', ' A5\n'] In the case …

Member Avatar for vesuvius
0
391
Member Avatar for TeaAnyOne

You are perhaps over thinking this with all of the complicated print statements. You now want a second function with num_dots, num_spaces, and num_stars, and print and then add/subtract from each field accordingly. def top_down(my_len, spaces): num_dots = 1 for ctr in range(my_len): print ' '*spaces + '.'*num_dots num_dots += …

Member Avatar for TeaAnyOne
0
126
Member Avatar for hotblink
Member Avatar for raghuvbhat
Member Avatar for rocket3443

Automatically executing in the current directory is considered dangerous as an attacker could add their own bash for example in the current directory. It would be executed if the current directory is searched first and could do anything the programmer wished. You can add PATH=$PATH:. and export it to .bashrc …

Member Avatar for woooee
0
448
Member Avatar for apayn

What happens when "variables != '2'" ? ## Three variables print "HOW MANY VARIABLES WOULD YOU LIKE?" for ctr in range(3): print ctr+1 names_list=["FIRST", "SECOND", "THIRD"] MainLoop = 1 while MainLoop == 1: name_of_variables=[] variables = raw_input ("Enter Variables ") for ctr in range(int(variables)): name = raw_input ("NAME YOUR %s …

Member Avatar for M.S.
0
299
Member Avatar for TeaAnyOne

> I also want it to display a message when there is no vowel entered Check the length of a set intersection test_sentence="The quick brown fox" v = set(['a', 'e', 'i', 'o', 'u']) print v.intersection(set(test_sentence)) or set some indicator msg = input("Enter a sentence: ") #v = set(['a', 'e', 'i', …

Member Avatar for vegaseat
0
170
Member Avatar for dylan.lange.16

One of the many [Python functions tutorial](http://www.tutorialspoint.com/python/python_functions.htm).

Member Avatar for woooee
0
117
Member Avatar for bradrick42

Use [readlines()](http://www.peterbe.com/plog/blogitem-040312-1) to get a list of the records. You can then [access a record in the list](http://www.tutorialspoint.com/python/python_lists.htm) by offset value just like any other list.

Member Avatar for woooee
0
167
Member Avatar for F1Fan12

You first split the sentence into words, then print accordingly. I will leave dealing with punctuation to you. A simplified example: test_input="help I don't know how to do these tables." test_list=test_input.split() ctr=0 for outer in range(3): for inner in range(3): print test_list[ctr], ctr += 1 print

Member Avatar for woooee
0
5K
Member Avatar for Melly3

What is the while loop supposed to do?? Right now it just prints. Note that while sum == point: will never be True because you are comparing an integer and a tuple.

Member Avatar for snippsat
0
3K
Member Avatar for alexandra.hoops.3

> but I have continuously been getting an error saying that a str object cannot be interpreted as an integer We have no idea what or where this may be. Post the complete error message which includes the offending line and also state which version of Python you are using …

Member Avatar for ThePythonNoob
0
588
Member Avatar for ThePythonNoob

Note how the class Board is declared inheriting Human. Also, the __init__ in Board overrides the __init__ in Human so you have to explicitly call it with "super" in new style classes, otherwise the variables in Human's __init__ are not declared. class Board(Human): def __init__(self): super(Board,self).__init__() self.board = [] self.mark …

Member Avatar for ThePythonNoob
0
283
Member Avatar for shanenin

a[0:9:-1] #why is this not equivilent to a[::-1] start at a[0], (then -1 = a[-1] which doesn't exist), and go in reverse order until the number is less than 9, which zero is. You want, a[end:start-1:-1], but why even try to reinvent the wheel that is already working.

Member Avatar for snippsat
0
124
Member Avatar for bigwill2010

This statement is part of your problem self.master.bind('<Configure>', self.resize) Also, you misspelled "tag". Other than that, moving the circle works fine for me. Since you always print the text in the same place and test the same coordinates, you will always get the same results. You have to keep track …

Member Avatar for bigwill2010
0
8K
Member Avatar for vargabbaruah

You are choosing from the dictionary's values not the keys, and then using the values instead of a key for lookup while wordlimiter < 10: ## returns values linked to first_word next_word = random.choice(worddict[first_word]) you possibly want next_word = random.choice(worddict.keys()) ## or test for membership next_word="" while next_word not in …

Member Avatar for woooee
0
161
Member Avatar for SandD

Please read the sticky threads [Homework Help](http://www.daniweb.com/software-development/computer-science/threads/573) If you have no idea then there is not much that can be done with this problem. I would suggest that you start with something easier where you do have some idea of what to do.

Member Avatar for vegaseat
0
162
Member Avatar for findlay

And you first want to check that the index is in the dictionary to avoid an error message. dictionary={a:1, b:2, c:3 ...etc} lookup=[a, a, b, c, c ... etc] results = [dictionary[key] for key in lookup if key in dictionary]

Member Avatar for woooee
0
271
Member Avatar for Kerma
Member Avatar for CharlyJ

When will the variable "a" be found in the following code? a = '' for word in range(len(board)): ## do you really want to look for a='' if a in make_str_from_row(board, word): return True > I have a function that checks if a str is part of a list of …

Member Avatar for naresh123
0
937
Member Avatar for Mogworld937

You did not include the complete error message so we have no idea which variable gives the error. Dagger should possibly be a data attribute/instance variable instead of a class variable http://www.linuxtopia.org/online_books/programming_books/python_programming/python_ch22s06.html http://www.diveintopython.net/object_oriented_framework/userdict.html#fileinfo.userdict.init.example

Member Avatar for woooee
0
574
Member Avatar for SSeema

Please read the [Homework Help](http://www.daniweb.com/software-development/computer-science/threads/573) sticky.

Member Avatar for SSeema
-1
196
Member Avatar for valorien

There is no need to reverse the list twice as you can use -1 in a for loop and start at the back end. Other than that, you have to look at all elements from the back of the list to the first non-0xFFFF however you do it.

Member Avatar for valorien
0
152
Member Avatar for ised

To get you started: for ctr in range(8): print 2**ctr, for ctr in range(6, -1, -1): print 2**ctr, print for ctr in range(2): print 2**ctr, for ctr in range(0, -1, -1): print 2**ctr, print for ctr in range(1): print 2**ctr, for ctr in range(-1, -1, -1): print 2**ctr, print To …

Member Avatar for ised
0
3K
Member Avatar for jworld2

On Linux, you can add a path to the PYTHONPATH variable in ~/.bashrc. Add this line export PYTHONPATH=${PYTHONPATH}:/new/path:/another/path:/colon/separates The next time you boot, the PYTHONPATH will reflect the changes.

Member Avatar for vegaseat
0
5K
Member Avatar for Lyled93

You should send the time value entered to the class, so this statement should be in a function that is called when the "Convert" button is pressed conv = Converter(5) and should send the value from the Entry instead of "5" (links to [using get to read an entry](http://effbot.org/tkinterbook/entry.htm) and …

Member Avatar for woooee
0
589
Member Avatar for doobz

Instead of complicated and+or statements without parens so no one knows what the computer is actually doing elif row1.value == row2.value == row3.value and row4.value == row5.value or row3.value == row4.value == row5.value and row1.value == row2.value: use --> for unique value in list of rolls/dice, count each unique value …

Member Avatar for woooee
0
761
Member Avatar for sgeep

What that post means is, you execute the return from rollin (which is 'None') because of the parens. It should be rolldice = Tkinter.Button(row2, command=rollin, text = "Roll") See [Click Here](http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm) for info on bindings and callbacks. Also, you do not include the parens when you call dx.roll within rollin() …

Member Avatar for TrustyTony
0
837
Member Avatar for Inshu

Start by printing x, y, and z. And print the return. These are always good places to start. def calcdist(data): for p in data: x = p[:1] y = p[:2] z = p[:3] print "x, y, and z =", x, y, z for i in range(len(data)): dist = sqrt((x[i]-x[i+1])^2 + …

Member Avatar for woooee
0
222
Member Avatar for james5050

It is very easy. Just lay it out in a list and print the list. A simplified example. to_draw = [[" ", "O"], [" ", "|"], ["\\", " ", "/"], [" ", "|"], [" ", "|"], ["/", " ", "\\"]] for each_list in to_draw: print "".join(each_list)

Member Avatar for vegaseat
0
843

The End.