15,406 Topics
![]() | |
Hi people. I'm trying to create a tictactoe program in python but i'm having some troubles. It's the player against the computer. Now the computer should go on random but still block/win if possible. Right now i'm kinda stuck so feel free to help. I'd prefer it as simple as … | |
[B]hi all, can anyone tell me how to open a folder on a remote machine connected on same LAN. I need to open a folder in the form "\\remote_machine\folder1\folder2\folder3"[/B] | |
ok so i really dont understand this whole recursive stuff and i need some help on a simple program. the problem is to write and test a recursive function max to find the largest number in a list. here is a non recursive function that ive made, [code] def Max(li): … | |
I am working on this program in Python that would allow me to scan for a certain phrase in a certain text document. I used the finditer function in Python's re library.The certain line of code resembled the following: [CODE]phrase=regex.finditer(page)[/CODE] I also had a print statement at the end that … | |
Hello! I'm just beginning to learn Python and I would like you to recommend me any good tutorial. I have started with the [URL="http://www.pythonlearn.com/"]http://www.pythonlearn.com/[/URL] and the [URL="http://hetland.org/writing/instant-python.html"]http://hetland.org/writing/instant-python.html[/URL]. I have found them very useful and I would like to continue learning. Furthermore, I would also like to start learning on programming … | |
Hi, i have created python exe file of my code using py2exe module. i need to add my own customized icon for this exe file how to achive this | |
I'm trying to figure out how to set up a grid using a list of lists. I want the input to be x where the program will then setup a list of x lists, each containing x entries, in this case "0"s. | |
Ok, so i've got one definition on my python code, that defines how to find the position of something in an array, then returns the list of all the places that those things are. Then I've got another definition to find the accurate centroid of a position. How do I … | |
I am working on a project where I need to parse a bunch of user text that comes in different fields. The problem is that the user input doesn't always come in on the same fields. One user might have a name in field 3 and a date in field … | |
try to get the current cursor position without removing the node [CODE]class List(object): ___slot___=('cursor', 'size') def __init__(self): self.cursor=EmptyCircleNode() self.size=0 def __str__(self): result = "<" node = self.cursor count = self.size while count != 0: result = result + str(node.data) if count != 1: result = result + ", " node … | |
I am new to python programming and struggling with a problem I would like help with. I have multiple text files that I would like to join using the first column in each file to serve as the key to align the files. Each file could be several hundred lines … | |
Hey guys I'm having some trouble with a homework question from Zelles python. I have to make a Set class then test a variety of methods. However my teacher wants us to just use lists and not actually sets. I'm getting an error for the setElements method, it keeps saying … | |
Problem with storing extracted values in SQLite - How to adress or index list of values for proper insertion into table. The Regex works fine: input logging data looks like: 0.0.0(06026104) 1.6.1(0.1501)(1011111000) 1.6.1*32(0.1446)(1010190800) 1.8.1(02484.825) 1.8.1*32(02449.574) correct regex output: 06026104 0.1501 02484.796 [CODE] with open("usage.log") as fp: for line in fp: … | |
(Python begginner, please be gently) Hi, i'm having some troubles with turning one python project i made into an executable, using py2exe (via GUI2EXE). The program is compilling well, it generates the executable, but when i try to execute it, i get the following error: ImportError: No module named twitter … | |
So far, I have: [CODE]def printSquare(x,y): for z in range(0,x): print(x*y)[/CODE] printSquare(3,'%') prints out something like this: %%% %%% %%% instead of using the '*' operation, is there a way to print x numbers of y separated by commas (for better spacing) ie: print(y,y,y)? | |
Hi, I want to know how to use Python variables in My sql statement and below is the syntax i am using import MySQLdb name="XYZ" number="123456" db=MySQLdb.Connect("localhost","root","12345","phone") cursor=db.cursor() sql= ("""INSERT INTO phonebook(number, Mobile) VALUES(%s,%s)""" , name,number) cursor.execute(sql) db.commit() db.close() but this throws the error please refer the attached screen shot … | |
Read and Write Image in Python 3.1 ? No lib Thank you so much. | |
Hi there, at university i have to program OO-style in Python. What i got now is a "Point"-class and a "Triangle"-class. The "Triangle"-class has a method [ICODE]a()[/ICODE] that needs to return the length of the AB-edge, but it doesn't instead it concatenates the Point.__str__() methods return values together, which is … | |
it keeps looping over and over again no matter what i put in [CODE]def getScores(totalScores, number): score = input('Enter their score: ') while score <=0 or score >=100: print'You must enter a number between 0 and 100' score = input('Enter a number between 0 and 100:') for counter in range(0, … | |
i get this error when i get to a certain part in the program Traceback (most recent call last): File "C:/Users/Family/Desktop/13.py", line 54, in <module> main() File "C:/Users/Family/Desktop/13.py", line 10, in main averageScores = getAverage(totalScores, averageScores, number) File "C:/Users/Family/Desktop/13.py", line 46, in getAverage averageScores = totalScores / number TypeError: unsupported … | |
hi all, can anyone tell me hoe to open a file from one machine, when the file is present on a remote machine, specifying it's IP address? | |
I am struggling with one part of my specification to complete my program :/, currently it does let me enter different items into containers and creates new containers as they are needed. However now I need the program to handle how it packs the items differently. Before when numbers such … | |
I'm trying to convert text to a variable name. So far, I've been able to solve most things with Google, but this is really frustrating: Error: Traceback (most recent call last): File "C:/Documents and Settings/Some_Kittens/Desktop/Lab20/worldClock.py", line 33, in <module> main() File "C:/Documents and Settings/Some_Kittens/Desktop/Lab20/worldClock.py", line 21, in main while not … | |
Hi! I've created three list in a class but when I print them i get <__main__.Kort instance at 0x16eb22b0> Anyone know how I can get the list to print put its "real" elements? [CODE] class Kortlek(): def __init__(self,colors=["blue ", "yellow ", "red "], forms=["triangel", "circle ", "square "], numbers=[1, 2, … | |
i have an introduction to programming class and i'm trying to write this program and the program is supposed to loop if you don't input a number within a specific range but it doesnt do it [CODE]def main(): endProgram = 'no' print while endProgram == 'no': totalScores = 0 averageScores … | |
My problem is that i have to create a program to hold a series of weights in containers (elements in a list). The max weight for each container is 20units. I have got this working as this: containers = [0] inp = input("Enter a weight, 20 or less, or enter … | |
Hi! I'm working on a solitaire game, with a different card deck. First I create a big list with 81 elements (cards in this case), cardList. From this list, six cards are ramdomly picked and put into another list, playerCardList, and printed on the court. Once the cards are printed … | |
Hey, I've got an array full of random numbers and I want to say if the array is below a certain value, say 15, then to make everything in that array that less than 15 equal to zero. So far I've tried a few things and they've not worked, and … | |
I have these 3 string: YELLOW,SMALL,STRETCH,ADULT,T21fdsfdsfs YELLOW,SMALL,STRETCH,ADULT,Tdsfs YELLOW,SMALL,STRETCH,ADULT,TD I would like to remove everything after the last "," including the comma. So i want to remove these parts ",T21fdsfdsfs" ",Tdsfs" and "TD". How could i do that in Python? | |
Hi people. I am having trouble printing out a list of items with n items per line. Here is my current code. [CODE]def printList(lst, lineCount): # given a list of items, print it out in # lineCount items per line. count=0 strList= '[ ' for element in lst: strList = … | |
Please look at my code at: [url]http://www.bpaste.net/show/11961/[/url] I appear to have gone down a "blind alley" here. Having identified the location of the Word perfect headers, I need to verify that they are indeed genuine by reading the hex value 10 bytes from the beginning of the header. If it … | |
This snippet generates the best rational approximations of a floating point number, using the method of continued fractions (tested with python 2.6 and 3.1). | |
This issue is probably discussed before. However, I can still use a little insight. I am a python beginner looking to develop a small client/server suite. The clients will reside in different PCs across a LAN and their job is to recieve a file (say, a .txt file) from the … | |
I'm making a Card class and need to make sure that the suit is valid. When I call on the Card class and construct one setting the suit to 'Jordan' it actually ok's that suit and prints 'Ace of Jordan'. Instead it should become the default, of Spades. What am … | |
Hey I'm very new to the programming world, and what i am trying to do is produce a Koch Snowflake via turtle from python2.5. this is what I have so far... [CODE] from turtle import * def snowflake(lengthSide, levels): if levels == 0: return forward(lengthSide), right(120), forward(lengthSide), right(120), forward(lengthSide) forward(lengthSide) … | |
Ok guys so i am trying to create 2 versions of a program which sorts items into boxes. The first version i have to create puts the item weights (integer between 1 and 20) into the first "box" they will fit into. So given the input 11,17,3,5,4 the list the … | |
Monday morning, our final exam is to write a Python program according to whatever the teacher will throw at us. Any ideas as to how or WHAT to study to be ready for anything? (Most of the class expects to fail this, btw. I don't want to be among those … | |
I have to create all the method signatures in the ResizableArrayList and then fill it in with comments. And each method is supposed to be blank with a return null or --1. How do i do this? | |
I am working on a program with classes and a main function. This game involves tanks moving around a grid of defined size, and shooting at each other. Each tank has a name, armour and firepower. On the grid, there are randomly generated squares that contain extra armour or firepower. … | |
Hey everyone, new here. I'm looking for a little help with my program. Its supposed to take a txt file called test.txt, and removes all spaces trailing at the end of lines. ex. (note the spaces) "python " -> "python" "daniweb is great" -> "daniweb is great" " forum" -> … | |
Hope you kind folk can spare a bit of advice. I'm trying to find a clever way to modifying a part of an image without replacing the image completely. For instance, let's say I have an image of a car and I would like to show the tire is flat. … | |
Hello :) I'm from Brazil, so sorry about my english. This is the first code I post here - I'm a begginer in Python. It is a function to calculate determinants of matrices. You can attach it to a class if you wish. Please leave a comment if you wish … | |
I'm a Python semi-beginner and i have to do a prac but the problem is i've totally forgetten how to do it! Can you please help me get started with part 1 even if its just 1.a because every time i tried to get it to work it keeps saying … | |
Guys, how do I add an item to a list using a loop? My loop in a nutshell does this: [CODE]for w in book_line.split(" "): word_list = [] if w != "": word_list.append(w.lower()) return word_list[/CODE] While experimenting with this I got mainly two results: 1.) When I use return word_list, … | |
Hello, I am completely stuck on a question I was assigned and was hoping for a little guidance to get me started. The question is: Create a program that outputs the molar mass of a molecule. The user will enter a molecule with each atom individually (CO2 would be entered … | |
Hi! I am trying to do a project in which I draw a Christmas tree with about 3 segments, filled in with color and with writing below it saying "Merry Christmas". Sadly, I have no idea where to being! I'm able to draw the Christmas trees using stars by defining … | |
Hello. My instructor want me to write a magic Square code. And here is what the square is supposed to print: 11 18 25 2 9 10 12 19 21 3 4 6 13 20 22 23 5 7 14 16 17 24 1 8 15 Here is my current … | |
I am reading a text file inside Python that contains salaries and the raise they will receive as a percent. I am trying to multiply the initial salary by the percent and print the salary after the raise has been applied. I keep receiving an error message which is as … | |
i have my code and i want to cycle through the following colors blue green orange red yellow. i got blue but i dont know how to the rest [CODE]from Tkinter import * myfont = ("Arial", 1, "bold") window = Tk() window.title("grid") window.geometry("500x420") frame = Frame(window) frame.grid() button0 = Button(frame, … | |
Guys I have a text file, and I am trying to get my program to focus on a specific part of the text. How would I do that? I tried this to no avail: [CODE]f = open("book.txt") f.readlies()[10:3340][/CODE] |
The End.