15,406 Topics

Member Avatar for
Member Avatar for shayallenhill

I think I can learn a lot from any answer to the two questions in this post. OK, I’ve got a large object. That object has attributes and does things. Those attributes also do things. MOST of what they do is sit there like a list, int, or np.array and …

Member Avatar for shayallenhill
0
131
Member Avatar for john200000005

I have specified the path variable as C:\Python27\Lib\site-packages;C:\Python27\Tools\Scripts. To recall this on MS DOS I used python myScript.py'so the program till reponds error syntax please could you help me.

Member Avatar for rrashkin
0
65
Member Avatar for TeaAnyOne

I made this code which outputs . ... ..... ...*****. ....***... .....*..... but its supposed to output . ... ..... .*****. ...***... .....*..... Any ideas what im doing wrong? To output the triangle myChar1 = * myChar2 = . myLen = 3 myChar1 = input("Select first character: ") myChar2 = …

Member Avatar for TeaAnyOne
0
126
Member Avatar for hotblink

Hi, I need some help to make a program where python reads each line(a string) of a .txt file. -sample txt file-(EOF stands for 'End of File) I need it to be able to read up to 300 students. ID , Last , First, Lecture, Tutorial, A1, A2, A3, A4, …

Member Avatar for snippsat
0
428
Member Avatar for raghuvbhat

Hi.. i am new to python and I want to put logfile to get the logs for every function including that function name with arguments. could any one help on this. Thanks raghuvbhat

Member Avatar for woooee
0
64
Member Avatar for rocket3443

Hi, I am having a problem when I'm trying to open and read a file with python. My code goes as follows: def main(): f = open('nummer.txt', 'r') text = f.readlines() print(text) main() But when I try to run the code, I get an error. (No such file or directory). …

Member Avatar for woooee
0
448
Member Avatar for raghuvbhat

Hello.. I have function as below to create logfile and write logs to it. It works fine in python shell. But once you convert it into sql server query, its not working. Any idea why so? import logging import time from datetime import datetime labellog = "C:\LabelLog" + datetime.now().strftime("%Y%m%d_%H%M%S")+".log" logging.basicConfig(filename=labellog,format='%(asctime)s …

Member Avatar for TrustyTony
0
137
Member Avatar for TrustyTony

Now that MITx first test is over, I got feeling that this one task requested for generate and test solution is begging also for less efficient recursive solution as it is so simple. Here it is! Single liner aproved by the released grader! If you wander if you are able …

0
314
Member Avatar for apayn

Hey guys Andrew here, with another problem. My while loop is made so that it is on, or off, simple eh? That's what I thought, but it doesn't seem to be acting as I would expect it to! The problem is, when I want it to loop, in testing it …

Member Avatar for M.S.
0
300
Member Avatar for TeaAnyOne

This is some code I have made to count the most occuring vowels within the inputted message. Everytime I run it, it prints out it out 5 times, how can I fix this? I also want it to display a message when there is no vowel entered. Maybe someone can …

Member Avatar for vegaseat
0
173
Member Avatar for dylan.lange.16

Hey so i've decided to try out writing some stuff in python after a while. My approach to this probably isn't the most efficient, but i'm sure you guys will see what i'm trying to do. I'm having troubles with the last part of the program with my askForRestart function. …

Member Avatar for woooee
0
118
Member Avatar for bradrick42

I am working on some pre-processing. i have a group of text files whose names are dates (i.e. 20120201). data in each file is organized like this: 20120201_line number field1: 123124235 field2:ergjenrgjnergoiefoiefoenr . . field10:dfgkjndgknrkj 20120201_line number . . . The line number is the only thing that separates the …

Member Avatar for woooee
0
167
Member Avatar for F1Fan12

Hi All, I am writing a program in which I take data for a table from the user, and then ask for the alignment for each column. Then I have to display it. Each column mush be separated by a tab and a space. For example, let's say the user …

Member Avatar for woooee
0
5K
Member Avatar for nag18

Hi i am trying to create a game that uses 2 scripts one that creats the game instance and another that hold the varbles of monsters and the player as well as the game my problem is i am trying to creat "rooms" for each area with in the game …

Member Avatar for TrustyTony
0
97
Member Avatar for ThePythonNoob

I have two inherited classes in another class Class A(object): def printhello(self): self.message1="hello" Class B(object): def printbye(self): self.message2="bye" Class C(A,B): def __init__(self): super(C,self).printhello() def printboth(self): print(self.message1) print(self.message2) a = A() b = B() c = C() c.printboth() How do I super both A and B?, note this is just an …

Member Avatar for TrustyTony
0
2K
Member Avatar for Melly3

import random as r def main(): roll1 = r.randint(1,6) roll2 = r.randint(1,6) point= 4,5,6,8,9,10 sum= roll1 + roll2 print("phase 1") print ("You rolled:", roll1, "and", roll2) if sum == 2 or sum== 3 or sum == 12: print("Game Over. You lose" ) elif sum == 7 or sum == 11: …

Member Avatar for snippsat
0
3K
Member Avatar for alexandra.hoops.3

I have to write a program that asks the user how many pumpkin weights they have, and the reads that many pumpkin weights, printing each weight with two decimeal points and a comment and displays data about them to four decimal places. I need to find the average weight, maximum …

Member Avatar for ThePythonNoob
0
589
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
283
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
135
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
167
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
837
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
124
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
212
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
418
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
63
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
348
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
116
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
292
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
120
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
161
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
161
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
141
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
113
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
262
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
556
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
190
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
181
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
162
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
223
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
271
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
305
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
938
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
101
Member Avatar for Mogworld937

I'm trying to make it so in my game when you equip your dagger it will change the variable dagger so I can tell if its equipped or not. from sys import exit from random import randint class Game(object): dagger = 0 def __init__(self, start): self.quips = [ "GAME OVER... …

Member Avatar for woooee
0
574
Member Avatar for dean.ong.14

how to loop and how to add score? and 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 …

Member Avatar for dean.ong.14
0
140
Member Avatar for dean.ong.14

The End.