15,185 Topics
| |
I am having trouble with this problem, I need to enhance the red intensity of each pixel This is what i have [CODE]import cImage def makeRedScale(imageFile): myImageWindow = ImageWin("Image Processing",600,300) oldImage = fileImage(imageFile) oldImage.draw(myImageWindow) width = oldImage.getWidth() height = oldImage.getHeight() newImage = emptyImage (width,height) for row in range(height): for col … | |
Hi, How do I find the frequency of each item in a list in Python? For example if there are five 'apple', two 'banana', and so on in the list, how do I write a program so that it displays the item as well as the number of times it … | |
Hi guys, Have been doing some wxPython programming and haven't had any major issues until I wanted to display images! Basically I take readings from an external device (simple input device) and set the image in a panel based on this reading. However it seems that the picture does not … | |
Please someone help to print function has to print numbers like Snack and ladder game when 2 variables rows and columns are passed to a function. ex: fun(4,3) 12 11 10 7 8 9 6 5 4 1 2 3 | |
Hello: I've been attempting to create a treemap (binary search tree) insertion and display function for a bit and am puzzled by the recursive calls. I've tried quite a few things, but the problem seems to be in my mapInsert function. Here's all the code I've written so far in … | |
The following is a recursive function designed to return the factorial of a number. [CODE] def factorial(number, target): if number == 1: return target else: target = target*number factorial((number-1), target) print factorial(7, 1) [/CODE] As you'll see if you run it however it doesn't return my 'target' variable (the factorial … | |
I have dictionary with single element lists. [CODE]dictionary={'a':['A'], 'b':['B'], 'c':['C']} [/CODE] How can i change it to [CODE]{'a':'A', 'b':'B','c':'C'}[/CODE] | |
Hi I have a question about a problem I'm having with raw_input function in python. I'm writing a CL program that requires a comment to be entered by the user, however problems arise when someone makes a mistake entering said comment. [CODE=python]comment = raw_input(Enter comment: )[/CODE] User Input: Archie^?ve testing, … | |
I dont know what goes wrong in this piece of code?!! I keep getting the following error. File "<stdin>", line 11 t1.append(list[temp]) ^ SyntaxError: invalid syntax [CODE]tl = [] for inlist in token_list: temp=[] for token in inlist: temp.append((zlib.adler32(token,65521)) tl.append(temp)[/CODE] | |
I have a class with a button, it runs the command automatically when the gui is constructed (which i dont want it to do) but then doesnt work again after. What am I doing wrong? Builtin commands such as endcommand work as they should. relevant excerpts (ignore the indent problem … | |
Hello, I have been working on this code but I can't seem to make it work. I want to implement function index() that takes as input the name of a text file (as a string) and a list of words. For every word in the list, the function will print … | |
Okay, I started learning Python last weekend on Saturday with some tutorials and a book. With this being my first programming language my program won't amaze you :P The program I made is a calculator for working out how much turf a person would need given the length and the … | |
Is it possible to sort a list of numbers from largest to smallest? Like if I had a list of numbers in variable a | |
im wanting to sort files by size and pick the top 20 i have managed this with the glob.glob statement but it does not work quickly and does not pick up if a file is modified/ added while the code is running. i have worked out how to do this … | |
Hi I am in a web programming class and have been struggling greatly with this assignment. I am not very familiar with Functions and so forth but I have been truthfully working on this for a few days now. I am at the point where I am stuck. I would … | |
Takes an XML, XHTML, HTML, Javascript or CSS file and creates a pretty printing version. | |
I am new in Python. May any one tell me how to validate XML file in python from DTD and Schema document.... | |
[CODE]f = open("summatest.01.sis", "rt") n = (f.readline()) jada_elemendid = f.readline().strip().split(' ') otstav_summa = f.readline().strip() f.close() # Valjund vfal = file("sum.val", "w") lmargid = [] def otsi(k): if (k < n): print n k = k + 1 lmargid.append("+") if otsi(k): return True lmargid.append("-") print lmargid else: z = jada_elemendid[0] for … | |
In python it will give a decimal like 52.2 and I was wondering if there was a way to make it round all decimals up to the next number like 53. | |
If I have a list and I already have split the line in the file. I also have figured out the code to average the numbers in the list now I have want to figure out a way to somehow take the average from the list of numbers and give … | |
Hello fellows... Is there something like static function variables in python? I know there are static attributes of a class, but what if i want to use a static variable inside a function? somthing like this (stupid) code in c++ for example: [code]int static_num() { static int x = 0; … | |
To maximize the value of the knapsack The output should like this >>>Bags=[mkBag('cooper',30,120),mkBag('silver',20,100),mkBag('gold',10,60)] >>>knapsack(Bags,50) [('gold',1.0),('silver',1.0),mkBag('copper',0.666666666)] [CODE] class Bag(): __slots__ = ('name', 'weight','value', 'ratio') def mkBag(name,weight,value): bag=Bag() bag.name = name bag.weight = weight bag.value = value bag.ratio=value//weight return bag def printbag(bags): print("Name:", bag.name, "Weight:",bag,weight,"Value:", bag.value) def knapsack(bags,maxweight): bags=sorted(bags, key=lambda mkBag: mkBag.ratio) … | |
Hello, We are trying to use Django with couchdb, is this a good idea??? It is going to be a health software, so is it better to use couchdb. Also we are going to use wtforms. Will this make a good combination for a complete software. Any more suggestions will … | |
Hello, I'm a new python user and I'm trying to create a python program that will run on a targate and communicate with the terminal. The main idea is to run several commend and short programs and analyze the results. for example running those 2 commands: cd /home/user/folder ls | … | |
below is how an snmp get is issued using pysnmp errorIndication,errorStatus,errorIndex,varBinds = cmdgen.CommandGenerator().getCmd( cmdgen.CommunityData('xxxx', 'xxxx', 1), cmdgen.UdpTransportTarget(('192.168.5.157', 161)), (1,3,6,1,4,1,18489,1,2,1,4,5,[B]1[/B],0)) In the OID part, the integer in bold keeps changing from 1 to 38. I need to put the above in a loop, instead of issuing 38 seperate gets. how can … | |
The map() function applies a function to every member of a list. Here a list of numbers 32 to 255 is changed to a list of the corresponding ASCII characters. Then map() is used in a more complex application to combine the two lists to form a dictionary containing number:character … | |
I have a list of lists [CODE]x=[['a', 'b', 'c', 'd'], ['e', 'f'], ['g', 'h']][/CODE] I need the following output. [CODE]a-b a-c a-d b-c b-d c-d e-f g-h[/CODE] How can i do this? Can a regular expression be used here?? | |
haiii Do anyone know how to convert array like this ['26','18','20'] into [26 18 20] because i have to plot graph for these value, ['26','18','20] array is not allow me to do that ,i got ['26','18','20'] from database table with data type varchar....problem is i shouldnot change the datatype .... … | |
[B]hi... I have a value, value=4501-E001 I am concerned about only the value before hyphen i.e., 4501 I need to check whether various values begin with 4501, followed by something, n am not concerned about "something" that follows. How can this splitting be done in python?[/B] | |
I am making a program for my CS class. Is there a way, in python, to set more than one value to a variable? Am I thinking about this in the wrong way? I need to make a program that asks a bank account holder for their username. If that … |
The End.