15,185 Topics
| |
Hello, This is a really simple question but I just don't see the error here: [CODE]def foo(): x = input('write something: ') if x == 1 or x == 2: print('OK') else: print('NO') print(x)[/CODE] Why does it keep printing NO? Also, I have a more complicated one: def foo(x, y): … | |
Hi all, i was writing a gui for a small desktop application i made as a part of learning python.I use python 2.7.I used Tkinter.I am new to python and this was my first trial with Tkinter. First i created 9 buttons arranged in the form of a 3*3 matrix … | |
So I have a program I am making but I need to make it more efficient, is there any way to condernse the following code into a more compact and efficient code? [CODE]r1p1=o r1p2=o r1p3=o r1p4=o r2p1=o r2p2=o r2p3=o r2p4=o r3p1=o r3p2=o r3p3=o r3p4=o r4p1=o r4p2=o r4p3=o r4p4=o r5p1=o r5p2=o … | |
I wrote this as reaction for Pascal newbie's question in Pascal Delphi forum. | |
Hello all!!! It's been a while but glad to have enough time to be back. My question is basically one of design. I'm working on a new project using pygame at the moment, mainly to brush up on and enhance some Object Oriented skills. The project itself is basically going … | |
| Hello, I am a newbie in python. I have a unicode in Tamil. When I use the sys.getdefaultencoding() I get the output as "Cp1252" My requirement is that when I use text = testString.decode("utf-8") I get the error "UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-8: character maps to … |
Hey fellows, I've created a fairly large math suite for my spectrometer research, which is basically a set of programs that does several math operations, generates plots etc... It's beginning to get pretty bulky, and seems like it would benefit from a nice class; wherein, I could store all the … | |
Hey friends lets checkout a small, simple and cute python program for taking photos with with your webcam without the help of any third party application programs. [CODE] import os import datetime import opencv.adaptors from opencv import highgui import Image def get_image(camera): im = highgui.cvQueryFrame(camera) # Add the line below … | |
I wrote a program which I tested in the IDE of python 3.2, it worked but whenever I open the program directly or run from command prompt, it doesn't run correctly, after the user inputs the correct answer, the program keeps saying try again. [URL="http://www.daniweb.com/software-development/python/code/359115"]here's the program it's in the … | |
Hello everyone, I have created my own random text generator with a custom method, no Markov chains included, and now I would like to try it on a different text corpus that is larger from that of NLTK's and I wanted to know which Data structure should I use in … | |
Hi all, I'm trying to read data from this xml file that looks like this: <VEGETABLE > < FRUIT > <FRUIT name="apple">1</FRUIT> <FRUIT name="Orange">2</FRUIT> <FRUIT name="Benana">6</FRUIT> I wrote the following script:[CODE]import sys from xml.dom.minidom import parse from cmath import sqrt # Load XML into tree structure tree = parse(sys.stdin) #Find … | |
I am trying to implement this code for hash table in python and i don't understand why i and k are not used in the while loop. Can somebody help me please, [CODE] import random data = [] m = 10 t = [] for i in range(10): data.append(random.randint(0, 100)) … | |
I"m trying to determine if the user is root or not then prompt to become root user; [CODE]if os.geteuid() != 0: # If not root user... os.system("gksudo crack.py") # Open root password window else: # Do Nothing if os.geteuid() == 0: # If you are root user... os.system("You are now … | |
Hello, my task is to create a basic game using Pygame. I decided to do the basic snake game like the one that was on all of the old mobile phones. However when inputing some of the basic code, i realised that once i have paused my game i have … | |
I have to creat a program that draws squares instead of circles. It also has to draw additional squares for each mouse click, and at the end print a message "Click again to quit" after the loop, and wait for a final clikc before closing the window. This is what … | |
I am trying to only have the words print out if they occur the same number of times as in the fibonacci sequence. If a words show up 1,2,3,5,8 etc then it will print up. I have gotten the program to print up the words based on how many times … | |
Greetings all! Anyway excuse my English. I can't understand how I can do this: <loop cycle; variable is filled by some values> <loop is still running, but simultaneously another command is running> <loop is terminated; i want to read variable> More specifically (it concerned with Scapy module, but I'll explain … | |
For some reason it just jumps to the else statement instead of going to if and elif. Any input would really be apreciated. [CODE]a=raw_input( "What is your name: ") b= int(raw_input( "What year were you born: ")) c= int(raw_input( "What year is it now: ")) print "Hello",a,"you are",c-b,"years old." class … | |
I have stated to make a program called virtual Tv, I have been having troubles with variabels and I need the variable: state to be able to be change and accessed outside the class and inside, but I think that state is a local variable at the moment. [CODE]import random … | |
I want to limit the size of a list control box. Let us take the following code: [code] import wx class Students(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(380, 230)) hbox = wx.BoxSizer(wx.HORIZONTAL) panel = wx.Panel(self, -1) self.list = wx.ListCtrl(panel, -1, style=wx.LC_REPORT) self.list.InsertColumn(0, 'name') self.list.InsertColumn(1, 'age') hbox.Add(self.list, … | |
Hello. I have been trying to run a simple script in Windows 7 DOS using the python command, but it returns this error message: 'python' is not recognized as an internal or external command, operable program, or batch file. I've looked up how to fix on Google, but I can't … | |
For this program I am trying to figure out how to sort/print the words out based on frequency of appearance in ascending order. As of now I can only get the words to sort/print based on alaphabetical order [CODE] from collections import Counter import string while True: filename=raw_input('Enter a file … | |
Hi guys, thanks for all the help lately, but I require some more :o I need it that the user is able to choose what is on the controller, when I type in a valid option I test for it that it gets to that point but it does not … | |
I need to know how to copy some folders not all from a source tmp/folder. I'm new to python and I want to better understand python. I can't use copytree because I don't wish to copy all folders. I want to be able to pick the folders I want to … | |
I'm looking for a simple way to rotate a shape in python, tkinter. The shape I'm rotating is a triangle (polygon) if it matters. Thanks in advance for all the help | |
Hi! i'm doing a final project for a university introduction course in web programmation. I'v Coded this: [CODE]class MainHandler(BaseHandler): def get(self): #product_comments = Comments().get_all() user = users.get_current_user() if user: member = Members().get_by_id(user.user_id()) baskets=Baskets().get_by_member(member) template_args = {'baskets': baskets} products = Products().get_all() product_comments = [] for product in products: comments = Comments().get_by_product(product) … | |
Hey All, I have written a script that uses elementTree to work on python 2.4. Took quite a while and worked a threat but now I need to get it working on 2.3.4. I can't upgrade the version of python. Is there an equivelent version of the element tree for … | |
This is a simple word jumble game, I actually adapted it from one I used from practice. It's written in Python 3.1 using the pyscripter. NO modules needed. | |
I was just able to get PyQt4 to work on my system, and I'm now have that of python2.6, and that of python 3.2, but I have been trying to open Qt designer but all it does is just open a process in the background eating up my PCs memory, … | |
hi all ..... [CODE]for(i=0, i<680,i++): i =m [/CODE] wen i run a program it is showing error in for loop like wen i run a program it is showing error in for loop ..... |
The End.