15,185 Topics
| |
I'm confused on how i can change or "toggle" the text of a button from say "D" to "A" when clicked, and then back to "D" if clicked again. So far I have this: [ICODE]from Tkinter import * from tkFileDialog import * class Game(Frame): def __init__(self,root): Frame.__init__(self,root) self.grid() self.buttons() def … | |
Hi guys I'm trying to place a user input into a database(mysql) [CODE]newplayer=raw_input('Please enter a new player name: ")[/CODE] the sql commands to insert data is [CODE]sql="""INSERT INTO PLAYERS(NAME) VALUES('newplayer')"""[/CODE] When i check the database it shows newplayer instead of what the user has entered. any ideas of how i … | |
Hi All, I want to create a pattern like this using python.. [CODE]Aa0Aa1Aa2Aa3Aa4Aa5......Ab0Ab1Ab2.........and so on.[/CODE] Thanks... | |
[code=python]import random secret = random.randint(1,99) guess = 0 tries = 0 print "AHOUY! I'm the Dread Pirate Roberts, and I have a secret!" print "It is a number from 1 to 99. I'll give you 6 tries. " while guess != secret and tries < 6: guess = input("What's yer … | |
I'm trying to write code to count the number of times a whole number can be divided by 2 before reaching 1. When I run my code it prompts me to enter a number as you'll see in my code below, but once I do so, nothing happens, just a … | |
I recently received an assignment in class and I need help really bad. The idea behind this assignment is to create a Network Backup Routine that that has a selection menu (New Backup Item, Remove Backup Item, Exit), I have been trying to create this program but with a sub … | |
I use the following code to read a CSV file with 6 columns. The headers are assigned correctly (i.e. print headers works) but when I try to read the rest of the rows as variables under those headers. The first column is 'time' and it is read correctly. But when … | |
I am trying to write a program that 1. Lets the user write new students and there overall grade to the file, 2. Opens the file to view course info(student and their grade) 3. Shows course stats(mean and range for the class). Here is what I have so far, can … | |
These are the original instructions: "Design and write a python program that emulates a Magic Eight Ball. Your program should continually prompt the user to enter a question and then display the answer as long as the user wishes to continue. Store eight Magic Eight Ball answers in an array. … | |
Hi, I'm trying to create a new file. In this file I want to add some results I have received from my code. Unfortunately I get a error message saying I can't combine str with list. So then I tried to make a string out of the list and ended … | |
Hey everyone, I have a set of classes which, when instantiated, take up a lot of memory. I'm trying to write a program which can inspect class attributes and methods given a list of classes, without actually instantiating them. Let's say I wanted to see if the following class had … | |
Hello, Ok so this is a fun assignment, but I just can't figure it out. My Python program should ask the user for a series of words, then fill in the proper places in the story using the user’s answers. We will use the [...] notation for placeholders. For example, … | |
Hello! I need to: 1. Prompt user for text file 2.Analyze file and graph (with bar plot)the 25 most frequent words with length greater than 4 3.The x axis needs to show the word. The a axis is the frequency. I've built the bulk of the program so far, but … | |
Hi there, This is my first time posting so I am sorry if its not perfect I am working on a FreeCell game right now where I need to deal a deck of cards into 7 separate piles. This is the code I have right now for dealing it into … | |
Hello, i'm back with new question :) So i found how to make non-blocking gui with threading: [CODE] class SearchThread(threading.Thread): def __init__(self): super(SearchThread, self).__init__() self.window = frame.panel_one self.window2 = frame.panel_two def run(self): seit = self.window.inputArea.GetValue() se = self.window.engine.filest(seit) for it in se: self.window2.transferArea.AppendText(it) [/CODE] and i bind it to check-box: … | |
helo, I learn Classes and methods according to a manual "Think Python: How to Think Like a Computer Scientist" I am stuck on "Polymorphism" There is a part using built-in function sum. I don't know what to do... It should be connected to __add__ function, but still the code must … | |
Hi Guys, I am trying to copy files from one location to another with administrator access in python. I dont have write access to the particular location but admin have. I want to copy those files with admin permission. This is very urgent. Thanks in advance. konnara | |
Hi all! I was hoping I could get some help. I have a input file of data in 5 columns eg. [CODE]A 1 10 B 0.7 B 1 203 A 0.98 C 2 805 C 0.99 ...[/CODE] So what I'm trying to do, is when each item in the first … | |
I am trying to code the hangman game.. i have the game running but i need to attach it to graphics.py. please help it needs to be done by midnight. here is my code so far the last parts just the ideas to atach it to graphics. [CODE]from graphics import* … | |
This snippet defines a simple decorator to post-process a function's return value through a sequence of filters. As a first application, the decorator can transform a generator function into a function returning a sequence type (list, tuple, dict). | |
Converting a decimal integer (denary, base 10) to a binary string (base 2) is amazingly simple. An exception is raised for negative numbers and zero is a special case. To test the result, the binary string is converted back to the decimal value, easily done with the int(bStr, 2) function. | |
[CODE]def countStrs(StrToSearch, pattern): count = 0 starting_point = 0 for element in pattern: while element in StrToSearch [starting_point:] : count += 1 starting_point = StrToSearch.find(element,starting_point) + 1 print "the string","'"+element+"'", "occurs", count, "times." def main(): file = open("pidigits.txt", "rU") lineStr = '' numbers =['0','1','2','3','4','5','6','7','8','9'] pattern =['1234','56789'] number_processor = 0 for … | |
Ive created a dictionary with all the letters of the alphabet, assigning each one to another random letter. encode={'b':'a','B':'A','c':'e','C':'E','d':'i','D':'I','f':'o','F':'O','g':' u','G':'U','h':'b','H':'B','j':'c','J':'C','k':'d','K':'D','l':'f','L':'F','m ':'g','M':'G','n':'h','N':'H','p':'j','P':'J','q':'k','Q':'K','r':'l','R':'L' ,'s':'m','S':'M','t':'n','T':'N','v':'p','V':'P','w':'q','W':'Q','x':'r','X': 'R','y':'s','Y':'S','Z':'t','z':'T','a':'v','A':'V','e':'w','E':'W','i':'x',' I':'X','o':'y','O':'Y','u':'Z','U':'z',' ':' ','!':'!'} Now what Im trying to do is to create a single function that takes the input, does the calculation, and produces the output, using … | |
input.csv 1,2,text, date, qwertyuiopasdfghjklñzxcvbnm, yhnujmik,2121212121 [code] import csv reader = csv.reader(open('input.csv', 'rb'), delimiter=',',quoting=csv.QUOTE_NONNUMERIC)) csv_out = csv.writer(open('output.csv', 'w')) for row in reader: content = row[0] + row[4] + row[5] + row[11] + row[12] + row[13] + row[16] + row[17] + row[22] csv_out.writerow( content ) [/code] # I want it to save … | |
Hi, i've used the Beautifulsoup module to parse the site and grab the img tag from it, but the problem is , Beautifulsoup while parsing not returning the whole content of the given url. The truncated content contain the image location I want to download: [CODE] from urllib2 import urlopen … | |
I was wondering if there is a way to record video from a USB webcam to a .avi file (including sound). I know how to view video and capture screenshots, but I'd like to be able to record a section of video. If there really isn't then is there a … | |
[B]Hello , I'm new here as I'm new in python.. :D I need help in viewing database's data ,[B][U] I could view data in python[/U][/B] but i need to view it in GUI . [B][COLOR="Red"]i'm using:[/COLOR] - Qt designer - pysqlite[/B] Thank you all :)[/B] | |
I want to translate text inputted multiple times then output it. I am using the maketrans() function. I want to translate multiple times, by a number of times a user would input. | |
This is my code for anagrams not utilizing the ready prepared file of anagram synonyms to celebrate 11.11.11 11:11:11. If you start program it warns you about missing subdirectory dict and creates it. You may put any word files, one word per line, to file <dictionary name>.txt. Program lists available … | |
i am new to Python. And I am trying to make a drop down menu which will have some options (eg 4 options). I also need a Ok button in the same window. The user needs to select an option and click on "Ok". I need only single selection. When … |
The End.