15,190 Topics
![]() | |
I'm a beginner with python and I'm trying to write a program that asks the user for how many classes they have taken, then asks them for the class codes and prints the classes they have left to take. I can get the program to run perfectly for one list … | |
[CODE] list1 = [4,5,6] for n in list1: print "list1:", list1 print "n:", n list1 = [7,8,9] [/CODE] output: list1: [4, 5, 6] n: 4 list1: [7, 8, 9] n: 5 list1: [7, 8, 9] n: 6 list "list1" is not affecting even though it is re-assigned in for loop. … | |
Hi guys, I'm trying to make an enemy object follow a player object but I'm having a problem with picking up the player co-ordinates, it gives me an error "Player object has no attribute x" Here's whats iv'e got: [CODE] import pygame pygame.init() class Player(pygame.sprite.Sprite): def __init__(self): pygame.sprite.Sprite.__init__(self) self.image = … | |
![]() | Hi, I'm looking for a way to getthe domain a computer is connected to and the name of the domain controller if possible. I've looked at the os, socket and platform and can't find anything. I have been able to retrieve various bits of system info using these modules but … ![]() |
I was wondering, is it possible to do something like the following? The given code obviously doesn't work. [CODE] l = 5 (l == 5)*(k = 7) #Returns error message.[/CODE] The reason is, I'd rather avoid doing something like the following for the project I'm currently working on. [CODE] if … | |
Hi :) Can anyone help me? I want to display image in my GUI using tkinter (python 3.2.2) Do i need to download this python image library ==> PIL-1.1.7.win32-py3.2 or actually it was already in tkinter? How about the code? Thanks for the help. | |
Hello! I have a class project and attempting to use a listbox to read a string of tab data from a simple text file. When the string of data is printed to the python shell the rows of string data appears to be spaced. However, when the string of data … | |
I keep getting this error and i don't understand why. [code]Traceback (most recent call last): File "E:\University\Workspace eclipse\dictionares\src\dcts\dicts.py", line 105, in <module> fr_runt() File "E:\University\Workspace eclipse\dictionares\src\dcts\dicts.py", line 95, in fr_runt run.run() File "E:\University\Workspace eclipse\dictionares\src\dcts\dicts.py", line 58, in run self.data.write(file, key, value) File "E:\University\Workspace eclipse\dictionares\src\dcts\dicts.py", line 23, in write fh = … | |
I just joined this community, after searching and not finding what i was looking for. I am new to programming, I'm just 15, my dad programs for a living, but doesn't know much with python. Forgive me if my code is sloppy, i have been told so by my dad … | |
In the following code I am trying to select a file either from a file chooser or just typing out the path. The problem is I want the comboboxentry to change background color when something is put in it. The code works fine if it's a combobox (Line 7 is … | |
I would like to create a function using the code below called drawMove which takes 2 parameters (x or 0) and square number. That draws an x or 0 in the numbered boxes on the grid below. Input should be: drawMove(turtle,cellsize,O,6) ---> this should draw a O in the 6th … | |
Hey guys, I have a simple numpy datatype: [CODE]spec_dtype = np.dtype([ ('wavelength', float), ('intensity', float) ])[/CODE] I chose to use this in my program because it's very easy to read in 2-column spectral data files using the genfromtxt() method. Therefore, I made a fairly sizable program around this datatype. Now … | |
I am having problems with a GUI I'm working on. The idea is to have a tree list of signals and be able to drag them onto the plot. Eventually having a long list of signals and multiple plots etc.. However the code segmentation faults after a seemingly random number … | |
I am trying to create a function which would take a list and be able to count the number of ints floats and str in that list. output should be: list = ['v', 3.0,1, 'etc'] freq = countDataTypes(list) print(freq) [2,1,1] any help would be greatly appreciated so far: [CODE] >>> … | |
![]() | def fnKey(dic, value): return [k if value == v else pass for k, v in dic.iteritems()] can anyone tell me why this doesn't work? i'm trying to return the key for a known value from a dictionary |
I'm writing a program that checks a txt file with a list of words (one word per line). I'm just this side of done, I think. [CODE]def StripPunctuation(s): answer="" for c in s: if c.islower() or c.isupper(): answer=answer+c.lower() return answer def Reverse(s): answer="" for c in s: answer=c+answer return answer … | |
I am having trouble correcting the syntax on this problem so far and I can't seem to find my mistake any ideas on what I am doing wrong ? The object of the program is to ask user for amount of money to put in the pot, and play until … | |
i have no idea what this means... and i really need help starting my new python web app project... [CODE]root@ubuntu:~# python solif/manage.py syncdb Traceback (most recent call last): File "solif/manage.py", line 14, in <module> execute_manager(settings) File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 438, in execute_manager utility.execute() File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File … | |
hi, am trying to work this one out for dictionaries. I have this 2 dict that i want to merge. a= {16: {(7, 8, 0): {0: 4, 1: 5, 2: 6, 3: 7}, (7, 7, 0): {0: 0, 1: 1, 2: 2, 3: 3}}, 18: {(7, 8, 0): {0: 12, … | |
I'm trying to use the exec command in python to try to get a function to call on different dictionaries and functions as needs change without making my program bigger than it needs to be. Unfortunately I keep getting this error: File "Game Files\Intro.py", line 214, in Anim exec compile('%slegs … | |
say for example the first 5 apples you buy cost .50 and the next 5 apples you buy after that cost .40 and every apple after that is .30. How would I go about creating a function that could tell okay apples 1-5 cost .50 then add any extra in … | |
Hello, I am a very entry level python user so my knowledge is behind at the moment but I am have a problem creating a function that will take an x range and pass it through as a parameter to my function and output all the results. For example this … | |
Hello, i'm new to python, I mostly program in C++. i'm adding values, but it doesn't give me the right answer. [CODE] x = input("Enter number: "); y = input("Enter a another number: "); z = x + y; print("Answer is: " + z); [/CODE] if i enter 5 + … | |
I have a wx Gui that gathers all the necessary info and starts an external command line app. Whilst it is running my gui freezes as you'd expect so I've been experimenting with putting the external app in a thread of its own. My original code ends with the line: … | |
So im trying to create a times table: Write a program to print a multiplication table (a times table). At the start, it should ask the user which table to print and how high the table should go. The output should look something like this: Which multiplication table would you … | |
Trying to help my brother who has just started learning Python at school. He's not the brightest so any help is appreciated. I consider this quite hard for someone who has barely started, although he has missed a few lessons through illness. Solution is welcome but please try to explain … | |
Hello, I am learning python and am having trouble getting this program to work correctly. [CODE]from Tkinter import* import time import tkMessageBox import random def Questions(): number1 = random.randrange(1,25,1) number2 = random.randrange(1,50,2) answer = number1 + number2 prompt = ("Add " + str(number1) + " and " + str(number2)) label1 … | |
I am new to python and cant figure out what I am doing wrong with the global variables. Here is an example of the problem I am having. number = 0 def test(): global number number = raw_input("Please type a number.") def prints(): global number if number2 != 1: print … | |
I'm probably missing something really obvious, but I downloaded the Python 2.72 release, and now I can't figure out what to do. I've tried googleing it but everything says to just install it. Is that install the setup.py file? If it is, how do I run a python file if … | |
I started making a simple drawing program, to use for a level maker, and I came across a slight issue [CODE]from Tkinter import * class Main: def __init__(self,root): w,h = root.winfo_screenwidth(), root.winfo_screenheight() current = {} canvas = Canvas(root, width = w, height = h, bd=0) canvas.pack() root.overrideredirect(1) root.geometry("%dx%d+0+0" % (w, … |
The End.