15,175 Topics
| |
I'm completely new to Python and unsure how to run this script. The script is to take in an image folder and for each image, if the size isn't a power of 2, it will add "paddings" to it to make sure it's a power of 2. (These pictures are … | |
import math def board_gen(width, height): height = int(height) width = int(width) xo = ['O','X','O','X','O','X','O','X','O'] strt_ltr = 1 board = [] for row in range(1, (height+1)): strt_ltr = int(math.sqrt((strt_ltr-1)**2)) line = xo[strt_ltr:(width+strt_ltr)] board.append(line) return board config = ['O','X','O','X','O','X','O','X','O'] if (height%2==True): print config[0:width] else: print config[1:width] I do not know where to … | |
OS: Win7x64 6.1.7601 py: 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] I was able to create a logging class that posts to a file; however, despite reading several tutorials and the traceback docs from python.org, and creating a 'handleError' method, I'm unable to get my code … | |
I am trying to create a python program but i have a question about a certain part of the loop for example i have [CODE] question = input("press 1 or 2") if statement == 1: print "somthing" elif statement == 2: print "abc" [/CODE] ok my question now is for … | |
As most of us know in tkinter in order to properly display an image it must be assigned to a variable, however what if you don't know that amount of images that are going to be necessary? i.e. A friend list, how would one display the friends pictures? | |
I'm trying to utilize partial in order to bind an image to it's associated name in a list "you'll see what I mean" but I'm getting a TypeError thrown on it, this is my first time trying to work with partials so I'm just not quite sure what's going on: … | |
Hello! I didn't read the rules or anything, so I don't know if I'm posting in the right place, but I need help with a program as soon as possible. I have to answer this question: Find the first ORF in a sequence from a position (findORF(DNA, position)). It must … | |
I have to take ascii values from characters in a paragraph and make them print like: 116 = t = (# of times it appears) i have everything printing right except for the number of times it appears. I don't know what I am doing wrong with this counter. any … | |
here is my code: [CODE]conbi = ['a1','b1','c3','c4','f7'] left_unmatched = 5 wrongtimes = 0 right = 0 guess = input('Shoot: ').split(' ') guess = list (guess) for i in range(len(guess)): if guess[i] in conbi: left_unmatched -=1 right +=1 print ('Hit:',right,'Missed: ',left_unmatched) print ('Hit:',right,'Missed: ',left_unmatched)[/CODE] when I enter a1 b1 c3 c4 … | |
Can someone help me convert the following C++ code to python, please. I am fairly new to python. [CODE]void main() { int i,j,cnt,l,count[50]= {0}; char str[50]; clrscr(); printf("Enter the string: "); scanf("%s",str); printf("\n\tOriginal String is: %s",str); printf("\n\n\tEncoded String is: "); l = strlen(str); for(i=0; i< l; i*=1) { j = … | |
Hi, I have this code to communicate to an RFID device that outputs hex values. [CODE]import serial COMPort='COM13' mySer=serial.Serial(COMPort, 9600, timeout=2) try: mySer.flushInput() print "".join(["0x%2x " %(ord(c)) for c in list(mySer.readall)]) print msg finally: print 'Close' mySer.close()[/CODE] but cause error [ICODE]Traceback (most recent call last): File "C:\Python26\rfidtest.py", line 6, in … | |
I am Making A program for malking a phonebook. for that i am storing a list in dictionary. Like this: [code] phbuk={} def add(): a=raw_input('Name :') b=raw_input('Email :') c=raw_input('Mobile :') name=[a,b,c] d=len(phbuk) phbuk[d+1]=name [/code] Now if i want to delete a particular record just by giving name then how can … | |
hi, i am interested how is possible to work with python from dos and if somebody have some simple example. | |
From a thread on another forum, I wondered how difficult it would be to create a Tic-Tac-Toe game that could not be beaten. Since it is easiest if the computer goes first and chooses the center square, this code implements that portion. The logic is fairly simple; occupy the center … | |
I have the code [CODE] import sound def rem_vocals(snd): '''Return a copy of the original sound with vocals removed. The original sound is unmodified. The number of samples in the copied sound is the same as the original file.''' new_song=sound.copy(snd) for samp in new_song: left=(sound.get_left(samp)) right=(sound.get_right(samp)) result=(left-right)/2.0 Left=sound.set_left(samp, int (result)) … | |
[CODE]s = raw_input("Enter a string: ") a = 0 i = 0 for i in range(len(s)): if s[i] == ' ': a = a + 1 print str(a) + '. ' + 'There was a space in position ' + str(i) + '.' [/CODE] i keep on trying to sub … | |
I have been working with python for about a month now, but today I came across a problem I have yet to see; multiplication tables. I have absolutely no idea where to start or how to begin to format said table. The problem will be listed below, and if anyone … | |
I am writing a program that contains python code that will decode an English message that was encoded using a Caesar cypher with a fixed rotation length. It makes use of letter frequencies in the English language to determine the rotation length.The program should also have some comments within your … | |
Hello, I am trying to make an application that will run a simulation on a headless server. In short, it does the following: 1. load an image from the database 2. display a text as an overlay on top of the image 3. capture the 'screen' and save the image … | |
Here is capital letter style caesar crypted message. We can simply try all possible shifts for first few words (ignoring punctuations, which is left as is). If both first words succeed we assume we cracked it. You could also use Vigenère encryption, but keeping non-letters is less simple, our Vigenère … | |
Hi, I am a beginner for Python. There is one problem I encounter with a coin flip program which there are "None" involved with the print out. Any help will be appreciated. [CODE] import random def flip(): cflip = random.randrange(2) if cflip == 0: print("Heads") else: print("Tails") def main (): … | |
I want to start playing a .wmv file as soon as it is loaded in wxPython. I wrote a small code for it. The code does not give any error, but it does not show any video as well. It just shows a gray screen. Following is the code I … | |
does anyone have any note on rewriting C/C++ programs in Python?? google and bing give me the exact opposite, and I've got a headache from searching... please note that I can't read C++ if you need the program I'm rewriting, please let me know | |
I just got a MacBook Air and I would like to download the Python programming language and an IDE like Pyscripter. Could someone suggest what to download and any threads on this site that I might want to read before getting started? | |
Disclaimer: I am not looking for a full answer to this lab, only hints. I know people get frustrated when others ask to do their homework for them. ;P Hey guys - first post here, although I have used this website many times to assist me with my Programming classes. … | |
Hi All How can I select some random names from a list, so that in next time, those previously selected names become omitted from the list? for example, say we have 100 names in test.txt file, and we want to select 3 names randomly. then by recalling the selection function, … | |
Just fooling around I came across an issue updating a digital-clock like label. This: [CODE]self.now=time.strftime('%a. %b %d %Y %H:%M:%S',time.localtime()) self.clock=ttk.Label(self,text=self.now) self.clock.pack() while True: self.now=time.strftime('%a. %b %d %Y %H:%M:%S',time.localtime()) self.clock['text']=self.now[/CODE] simply freezes the program, I've managed to get it to update on certain events like the user hitting a button but … | |
Dear seniors, I am a newbie in wxPython and I have to write a code that can immediately start playing a video after I load the file. I have been going through a lot of forums tried to implement 10 - 20 codes, but the wx.media is not playing the … | |
Sometimes, you just want to run a system command from python and capture its output. Currently, the standard way to do this is to call the subprocess.Popen with convenient arguments and use the communicate method. After writing such code a few times, I wrote this little Command class to ease … | |
i've got an assignment to write a program that simulates a game of snaps in python but don't know how to get started, your help would be appreciated! Here is the question: Write a program to allow the simulation of a game of Snap. Assume two humans will play, but … |
The End.