15,179 Topics

Member Avatar for
Member Avatar for ThePythonNoob

# Advanced game of Tic Tac Toe # Author: Bob # Version: TypeError #****************************** #import modules import random import mcommandline #****************************** class Human(object): def __init__(self): self.hposition = 0 self.hmove = ["X", self.hposition] self.question = "" def makemove(self): self.hmove[1] = input("1-9: ") def question(): question = input("Yes/No: ").lower() class Board(object,Human()): def …

Member Avatar for ThePythonNoob
0
274
Member Avatar for chao.lee.927

The UI is as following . http://img.my.csdn.net/uploads/201211/03/1351957960_1171.jpg What I want is : When I press the Enter key ,the label should shows “Enter” When I press The blank space key ,the label should shows “space” How to implement this ? I know I should reimplement the keyPressEvent handler ,but I …

Member Avatar for Lardmeister
0
133
Member Avatar for apayn

Hey Guys I have some code problem with my classes. Can anyone tell me what has happened? class Location(object): def location(self, index, desc, lootvalue=0, loot_type=0): self.index = index self.desc = desc self.lootvalue = lootvalue self.loot_type = loot_type self.nuetralmobspawn = nuetral_mob_spawn self.passivemobspawn = passive_mob_spawn self.hostilemobspawn = hostile_mob_spawn def __repr__(self): text = …

Member Avatar for Lardmeister
0
165
Member Avatar for ggauravag2012

if f(guess)-guess < epsilon: TypeError: unsupported operand type(s) for -: 'function' and 'float' This error message is being displayed. here is my code: def fixedPoint(f, epsilon): """ f: a function of one argument that returns a float epsilon: a small float returns the best guess when that guess is less …

Member Avatar for TrustyTony
0
826
Member Avatar for shanenin

These would seem to be equivalent but according to the interperter they are not. I have been banging my head with this for along time >>> a = '123456789' >>> a[0:9] '123456789' >>> a[0:9:1] '123456789' >>> a[::1] '123456789' >>> a[::-1] '987654321' >>> a[0:9:-1] #why is this not equivilent to a[::-1] …

Member Avatar for snippsat
0
121
Member Avatar for apayn

Hey! Sorry if the title looks a little odd and confusing. Basically what I want it to in my code, have Python input something as if it were the user. Does anyone know how to do this? Thanks Andrew!

Member Avatar for Lardmeister
0
209
Member Avatar for PhilEaton

Hello! I am having trouble getting the abspath when entering only an executable file. How can I fix this to return the full abspath? I am taking user input and opening a process (application). Here is my code: file = "/" + arr[2] + ".exe" print(file) path = os.path.abspath(file) print(path) …

Member Avatar for PhilEaton
0
415
Member Avatar for ThePythonNoob

Im interested to practice my python more in this area, for example I would like to do projects which would anyalyse a web page and look for a specific text or to send a post on to a site like twitter or facebook. I have no knowledge of this area, …

Member Avatar for Lardmeister
0
61
Member Avatar for sick vapor

Hello, I'm fairly new to python and I've currently run into a road block in this problem. I set up this code: def average(the_list): return the average of the list def deltalist(the_list,a): return a list which is each of the element of the_list subtracted by a def squarelist(lst): return a …

Member Avatar for sick vapor
0
2K
Member Avatar for Blacktono4

Hey guys, this marks my second post on the Forums. I recently asked about the def statement and the import statement. After that being answered I wanted to ask another question and thought best to start another thread. What is a class? What does it do and how does it …

Member Avatar for Lardmeister
0
320
Member Avatar for Blacktono4

So this marks my very first forum page on this great database of information named DANIWEB. So just quickly, as i am still in school and learning python, I really need to know, just an explination on: The def statement, what you can do with it and how to use …

Member Avatar for Blacktono4
0
114
Member Avatar for bigwill2010

Write a Python program that draws a circle with radius 50 pixels and centered at the center of the canvas. Give the canvas white background color and make it expand with its frame whenever the user resizes the frame. The program will respond to some mouse and keyboard events as …

Member Avatar for bigwill2010
0
8K
Member Avatar for dean.ong.14

My import random not working...... can anyone help me? and i need to make sure that people can quit in the middle of the quiz... THX import random # make input equal to Python3 style input even in Python2 def question (): try: input = raw_input except: pass question =" …

Member Avatar for dean.ong.14
0
288
Member Avatar for Delightfully

def exponents(num1,num2): if (num2==0): return 1 else: return num1*exponents(num1,num2-1) Hey I was wondering how I can generate a list of exponents using a for loop or a while loop so that the numbers display like this: Input (2,3) Output 2,4,8 What I have so far only returns the answer, Please …

Member Avatar for TrustyTony
0
2K
Member Avatar for d8m9

Hi, Iam trying to post a form with cookies using [Requests module](http://docs.python-requests.org/en/latest/). When I post the form and see the page with the results, there is an error in the page, saying that I didnt fill one field right. Iam absolute sure I fill that field right. When I post …

Member Avatar for d8m9
0
2K
Member Avatar for eleiloon

Hi All, I'm trying to make a tree and identify some 16s rRNA sequencing with genbank using biopython or python, but I have no Idea how can I start. Could you please help me?

Member Avatar for rubberman
0
114
Member Avatar for vargabbaruah

I have been learning Python for a month now and just finished coding my first Markov chain. def markovmaker(filename): import random fhin = open(filename, 'r') worddict = {} newlist = [] wordlimiter = 0 for line in fhin: wordlist = line.split() for word in wordlist[:-1]: pos = wordlist.index(word) if word …

Member Avatar for woooee
0
160
Member Avatar for krystosan

I have downloaded [PyDev](http://nchc.dl.sourceforge.net/project/pydev/pydev/PyDev%202.7.1/PyDev%202.7.1.zip) But I dont understand how to or what file to run...I know its a basic question but I am windows ga; used to run apps by clicking on icons...

Member Avatar for krystosan
0
156
Member Avatar for techyworld

Can someone tell me what is the difference between while(1) and while (true) in python?

Member Avatar for TrustyTony
0
138
Member Avatar for Inshu

How to load a yml file in python and work with it ?? I used : import cv data = cv.Load("Z:/data/xyz_00000_300.yml") But when I print data.. it just gives the detail of the image like number of rows and columns etc.... I want read what is there in the pixel …

0
111
Member Avatar for Frensi

Hi all, I'm trying to do this challenge from the book I'm following, but I'm so confused. I need to get a variable from one class, and use it as data in another class. As you see in my code, in the Shuttle class, I need to get the score …

Member Avatar for TrustyTony
0
258
Member Avatar for shills300

hi guys. our teacher posted a bonus a while ago that has me scratching my head. he still will not show us how to do it. i was wondering if u guys could crack it. here are the instructions: [Click Here](http://prntscr.com/inqqz) there are also **2 ** files to supplement: **.txt** …

Member Avatar for shills300
0
549
Member Avatar for nasnoma

supportData = {('nas','fat'): 0.5, ('nas'): 1.0, ('fat'):0.6, ('van'):0.72, ('jos'):0.55,('van','jos'):0.10} L = [('nas','fat'),('van','jos')] for freqSet in L: H = [''.join(list(i)) for i in freqSet] prunedH = [] #create new list to return for conseq in H: freqsetlist = list(freqSet) freqsetlist.remove(conseq) conf = supportData[freqSet]/supportData[tuple(freqsetlist)[0]] if conf >= 0.5: print freqsetlist,'-->',conseq,'conf:',conf When I …

Member Avatar for Schol-R-LEA
0
189
Member Avatar for ThePythonNoob

Hi I need some help with this code, at the moment I am just trying to get the commandline function to work. It should when I type a command like help or exit react to it, however I have to type the command 3 times for it to work which …

Member Avatar for ThePythonNoob
0
179
Member Avatar for SandD

Word Wrap I am new to python and I have no idea how to do this...Can you please help me.. For this option, first ask the user what the maximum number of columns for printing will be. ("How wide should the output be?") Next, the user will enter in a …

Member Avatar for vegaseat
0
159
Member Avatar for yogesh.sdot

Hi i just started learning pygame and i was trying to run a simple block of code but an error keeps popping up: import pygame from pygame.locals import * screen = pygame.display.set_mode((640, 400)) when on running i get this error : module 'pygame' from 'C:/Python27/Files\pygame.pyc'> Traceback (most recent call last): …

Member Avatar for vegaseat
0
221
Member Avatar for findlay

Hello, Is there any way to access a large number of keys in a dictionary efficiently. Perhaps via indexing with an array of lookup values. Some pseudo code may help; dictionary={a:1, b:2, c:3 ...etc} lookup=[a, a, b, c, c ... etc] print dictionary[lookup] thanks, Joe

Member Avatar for woooee
0
265
Member Avatar for Kerma

Hello I'm quite new to Python and would require some advice. I'm trying to create a picture viewer that changes pictures with regular intervals. The problem arises when I try to use time.sleep() along my go(), which changes the image. The code first loads images from a folder and uses …

Member Avatar for woooee
0
302
Member Avatar for CharlyJ

Hello, I'm creating a word guess game for an assignment. I am nearly finished, but I am having difficulties with one function in particular. I have a function that checks if a str is part of a list of list of str and returns true of false. Now I am …

Member Avatar for naresh123
0
926
Member Avatar for dean.ong.14

i need help. i want to make sure that people can ask how many question the want to answer in my quiz. how can i do that? # make input equal to Python3 style input even in Python2 try: input = raw_input except: pass print("Welcome to my yes or no …

Member Avatar for dean.ong.14
0
100

The End.