15,179 Topics
| |
I am trying to make the shape move here is my coding bif="space.jpg" import pygame, sys from pygame.locals import * points=[(-60,20),(-60,-20),(-20,60),(20,60),(60,20),(60,-20),(20,-60),(-20,60)] colour=(0,191,255) pygame.init() screen=pygame.display.set_mode((1280,800),0,32) background=pygame.image.load(bif).convert() x,y=0,0 movex,movey=0,0 while True: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() if event.type==KEYDOWN: if event.key==K_LEFT: movex=-1 elif event.key==K_RIGHT: movex=+1 elif event.key==K_UP: movey=-1 … | |
file_spellcheck = input("Name of the document to be spell-checked: ") with open(file_spellcheck, "r") as i: spellchecking = i.read() for item in spellchecking: items = item.split() if items in with open("file.out", "w") as i: i.write() I need to make a spell checker that uses another file as a dictionary. So let's … | |
| I'm trying to write a program in which a message box is to appear on the application window when the application is launched. The code below produces the message box, but it appears as a separate window that is not over the application window. Is there a way to fix … |
#Import Story text = open('./alice.txt', 'rb').read() #Split the text into individual words def split_text(text): #Import known words index index = open('./words.dat', 'rb').read().split() index_file = open('./words.dat','wb+') for word in index: index_file.write(word) index_file.write('\n') import string #Remove punctuation out = "".join(c for c in text if c not in string.punctuation).lower() # split the … | |
I have been programming for quite a while in Python but have just started to learn OOP properly. I find it really confusing and I don't really understand it. Especially the implicit self that python automatically passes. It just isn't clicking, really. May someone provide an easy explanation of what … | |
how do I run a python class without creating an object | |
Hi I got this error ImportError: No module named Crypto.Cipher Where can I find the module for windows and debian linux? How can I fix error both in windows and Linux? importerror no module named crypto.cipher windows Traceback (most recent call last): File "C:\Users\Win/\Desktop\client.py", line 2, in <module> from Crypto.Cipher … | |
I'm trying to create a program that will prompt the user for a list of text files to read from, then read those text files and build a dictionary of all the unique words found. Then finally put those unique words into another file and make it alphabetical order from … | |
I have a dictionary [CODE]dict1={'18':['4000','1234'],'12':['7000','4821','187','1860','123','9000']}[/CODE] I want to sort the keys and values such that, the output is, [CODE]dict1={'12':['123','187','1860','4821','7000','9000'],'18':['1234','4000']}[/CODE] I tried something! but it didn work [CODE]>>> for values in dict1: ... dict1[values].sort() ... >>> dict1 {'18': ['1234', '4000'], '12': ['123', '1860', '187', '4821', '7000', '9000']}[/CODE] Full sorting happens for … | |
My code has a raw_input in it - when I press Enter, it completely ruins the code which says that the string index is out of range. The annoying thing is that if you don't press Enter and type something in, it works perfectly fine. So my question is - … | |
Hi there, I am planning to create one robot choosing center. But I do not know how to use the idea to execute in python software. my idea is, let say a customer wants to choose a robot how to use the rule below to execute in python: IF the … | |
I have a python code that reads several csv files and writes teh data to a single file but every time it loops back around to the next file it prints the headers again. Is there a way to stop this I can post my code if it is nessisary. | |
Hello I'm currently working on a Interface for fun as a side project using Tkinter. I was wondering if anyone had a small code for a password and shutdown button I do have the button however it doesnt shut down the program. the password has a text box and is … | |
I have two text files and I want to compare them and save the matched columns to a new text file. file1: 114.74721 114.85107 114.85107 2.96667 306.61756 file2: 115.06603 0.00294 5.90000 114.74721 0.00674 5.40000 114.85107 0.00453 6.20000 111.17744 0.00421 5.50000 192.77787 0.03080 3.20000 189.70226 0.01120 5.00000 0.46762 0.00883 3.70000 2.21539 … | |
Hello all, please help me in writing a tic-tac-toe python program which actually learns as it plays with the user. So, starting as a dumb opponent, the program should be able to learn from the games being played against the user and evolve as a clever opponent it plays along... … | |
| Hello How can we know which GCC version is compatiable with a given Python version ? Regards |
| Hey guys, this is my first project since I completed [CodeAcademy's](http://www.codeacademy.com) Python course yesterday. Besides that course, this is my first time programming and I would really appreciate input on my program. I decided to create a database to help me keep track of the anime I watch. For this … |
I have this code that works well. It works in a way that I have to type a function such as soccer for the games.soccer module to be active then i can type a query such as 'latest scores', again after i close this then type autocare for this to … | |
python3 Hi I am trying to compare these two (strings) of numbers. There may not be a space inbetween the numbers in the file, but here its just for clearity. I want to take the value of 40 and compare it with 14 then 18,35 and so on until 54 … | |
Hi, I want to send back reply to the same email but with different email account. Here is my script mail = outlook.Session.GetItemFromID(ID) subject = mail.Subject if mail: message_reply = mail.Reply() message_reply.From='_from_email' #not working message_reply.Body = "THE FOLLOWING TASK HAS BEEN MARKED AS COMPLETED: \n\n" message_reply.CC= '_CC_Email' message_reply.Send() I tried … | |
Hi All Dears, I hope this finds you well! Im a new Python learner. My aim is to use a script that will fetch any web site news. I came across URLLIB & URLLIB2 Anyone to kindly provide a guide on how to do this? In advance thanx alot! | |
I am trying to toggle between the two toolbars (in two different panes) and couldn't do it with the code below. Not sure where the problem is.... I should only see "Page number" details when I click on "Read/Write" and "Hello world" when I click on "Write". Any ideas are … | |
My Rational class code: from __future__ import division import math as _math def _gcf(a, b): # Returns the greatest common factor of a and b. a = abs(a) b = abs(b) while b: a, b = b, a % b return a class Rational(object): def __init__(self, numerator=0, denominator=1): # Contructs … | |
Ok i had this in another question i asked yesterday and now im posting it in its own thread. I have a code that is supose to read files that are sent to me daily and after they are read i need to have them moved from their origional folder … | |
Hello I am new to python coding and have a couple of things that I could really use some help on. I need to move some sor files from one folder to another and to add a date and time to the facts sheet that it produces if any one … | |
I have a 2D contour plot and I want to fit it with 2D Gaussian. This is the script I used to plot the 2D contour. import numpy as np from pylab import * from scipy.stats import kde x = np.genfromtxt("deltaDEC.dat",delimiter="\n") y = np.genfromtxt("cosDEC.dat",delimiter="\n") n = len(x) H, xedges, yedges … | |
Python keeps getting stuck on this line because there is no attribute "numerator" (and I'm assuming it'd say it has no attribute for denominator either). third = Rational(25, 10) print ("third: 0/1".format(third.numerator(), third.denominator())) For my Rational class, I've got def gcd(a, b): if b == 0: return a else: return … | |
Hi, I didn't know where to place this thread :) Any recommendations for an IDE app to save snippets of code within the program, I looked online, and there are many options, too hard to pick ! :) | |
I am trying to toggle between the two toolbars and couldn't do it with the code below. Not sure where the problem is.... Any ideas are very welcome!!! Here is the code: `Inline Code Example Here` import wx import wx.grid import wx.html import wx.aui from time import * import cStringIO … |
The End.