15,190 Topics
![]() | |
My company recently hosted a programming competition for schools across the country. One team made it to the finals using the Python client, one of the four default clients provided (I wrote it). Most of the other teams were using Java or C#. Guess which team won? http://www.windward.net/codewar/2013_01/finals.html * *This … | |
I have this code so far #Add two digits def add(a,b): return a+b #Subtract two digits def sub(a,b): return a-b #Multiply two digits def mul(a,b): return a*b #Divide two digits def div(a,b): return a/b #returns an integer that the user enters def getCommand(): cmd = input("Choose: ") return cmd #Execute … | |
I have 2 text files: *cities.txt* San Francisco Los Angeles Seattle Dallas *master.txt* Atlanta is chill and laid-back. I love **Los Angeles**. Coming to **Dallas** was the right choice. New York is so busy! **San Francisco** is fun. Moving to Boston soon! Go to **Seattle** in the summer. *output.txt* <main><beg>I … | |
Hi ALL, I want to analyze my data by a python script. The data are in multiple file and they are kept in different directories. Moreover, the name of the files in those directories are same but have different extension. I want to get my output just by providing a … | |
Hello Daniweb, I'm learning Python at the moment, and I'm starting by looking at automating some of my server tasks, namely things like backups, virus scans and checking for IP changes (being on a dynamic IP, automating this task will be very helpful). I've started by creating some code which … | |
# Purpose: Tax input amount # #----------------------------------------------------------------------- # VARIABLE DEFINITIONS salesAmount= 0.0 salesTax=0.0 total=0.0 #----------------------------------------------------------------------- # CONSTANT DEFINITIONS #----------------------------------------------------------------------- # FUNCTION DEFINITIONS #----------------------------------------------------------------------- # PROGRAM'S MAIN LOGIC salesAmount = float (raw_input("Enter the sales amount:")) salesTax = float(salesAmount*0.08) total = salesAmount + salesTax print "The sales amount is $", salesAmount print … | |
You may want to call Python's list the answer to other computer languages' arrays. Here we take a look at the things you can do with lists, create an empty list, list the attributes and methods, load, append, count, insert, join, pop, remove, remove duplicate items, reverse, search, sort, establish … | |
I have a table with product codes, the first two chars of the product code is the product group. using the product group I'd like to test the content of certain data. Would this be proper coding or is there a better way ? if prodcust_code[:2] == "AB" do: ABsubroutine … | |
Really quick question, if I want to return the data that is returned by snesVar in videoGame as a string on every line, what is the correct code to use? def videoGame(): count = 0 snesVar = [] for data in os.listdir('/SNES/SNES Roms'): if data.endswith('.src') or data.endswith('.srm'): snesVar.append(data) return snesVar … | |
Hi all, I am trying to rewrite the following code, to avoid having to write 60 individual loops,I would really appreciate your help with this. # Long Version - not ideal num = 60 n = [open('n%i.txt' % i, "w") for i in range (num)] for a2s1, a2s0, a1s1, a1s0 … | |
![circuit](/attachments/small/2/circuit.jpg "align-right") Here is a version in Python of program from classic Lisp book (see http://www.daniweb.com/software-development/legacy-languages/code/446235/simple-scheme-functions-for-finding-impedance-for-norvigs-implementation for the details) for calculating impedance of a circuit. (Example circuit with 1MOhm like in the book's code not like in diagram) | |
![Lisp001](/attachments/small/2/Lisp001.jpg "align-left") ![Lisp002](/attachments/small/2/Lisp002.jpg "align-right") I did translation to minimal Scheme implementation of Norvig written in Python (http://www.daniweb.com/software-development/python/threads/359370/norvig-an-even-better-lisp-interpreter-in-python) of the impedance code defined in classic book **Lisp by *Patric Henry Winston* and *Berthold Klaus Paul Horn*** from year 1981 (first computer book I ever bought). Errata: diagram has 10 MOhm when … | |
I need to write a program that implements Newton's method ((guess + x/guess) / (2)). The program should prompt the user for the value to find the squareroot of (x) and the number of times to improve the guess. Starting with a guess value of x/2, your program should loop … | |
I am working on an assignment in college using RUR-PLE as a starting program. I don't know if you know what that is or not, but I was wondering how to use it? I enter in this code: x = input("How many beepers are in this maze?") def place_all(): repeat(put_beeper,totalBeepers) … | |
This PySide (PyQT) code sample shows you how to apply a StyleSheet to a GroupBox containing a number of RadioButtons. | |
A little fun drawing with the Python module turtle. Well commented to help the beginner. | |
I mainly need help with creating the 3 by 4 matrix (part 3 of the assignment) as i am confused as how i would create it. However this is the entire assignment: 1. Write a function that returns the sum of all the elements in a specified column in a … | |
I am reading the book for web2py. It is running through some python syntax examples. When I ge to this closure example I am not understanding how 'y' gets its value. This is the code. >>> def f(x): def g(y): return x * y return g >>> doubler = f(2) … | |
Hello, I have got [this](http://www.yasinuludag.com/darkorange.stylesheet) a Qt stylesheet, how do I load it to my PyQt module after creating a QString Object. if I do from PyQt4 import QtCore s = QtCore.QString('c:\myProject\darkFantasy.stylesheet') the above code loads the path string rather than the actual stylesheet. So how do I load the … | |
#McListBox Example #Jan.20, 2013 import tkinter as tk import tkinter.font as tkFont import tkinter.ttk as ttk #import re Actors_list = [("Rowan","Atkinson"),("John","Candy"),("Morgan","Freeman"),("James","Garner"),("Cary","Grant"),("Kate","Hudson"), ("Jack","Nicholson"),("William","Powell"),("Arnold","Schwarzenegger"),("Tom","Selleck"),("John","Wayne")] Movies_list = [[("Bean","1997"),("Mr. Bean's Holiday","2007"),("The Lion King","1994"),("Johnny English","2003"),("Johnny English Reborn","2011"),("Keeping Mum","2005"),("The Black Adder","1982-1983")], [("Dr. Zonk and the Zunkins","1974"),("Tunnel Vision","1976"),("SCTV","1976-1979"),("1941","1979")], [("The Pawnbroker","1964"),("Blade","1973"),("The Electric Company","1971-1977"),("Attica","1980"), ("Brubaker","1980"),("Street Smart","1980"),("Driving Miss Daisy","1989"),("Glory","1989"),("Unforgiven","1992"), ("Outbreak","1995"),("Se7en","1995"),("Amistad","1997"),("The … | |
Im new to python and im runnung xubuntu! I was wondering if there is a site that does tutorials for Python in xubuntu?? | |
Hi everybody, is there anyone with experience with opencv for python? I was wondering if there is a way to allocate some memory on demand, since when I try processing images (usually bigger than 800x800 pixels) I get a "OpenCV Error: Insufficient memory (unable to allocate 59500564 bytes)" message. (bytes … | |
Hi guys, I have a code that intercepts calls to methods via __getattr__. Something like: def __getattr__(self, attr, *fcnargs, **fcnkwargs): out=getattr(self._df, attr)(*fcnargs, **fcnkwargs) etc... My goal is when a user calls a method, if it is not a method of self, the program attempts to run it on one of … | |
I'm fairly new to python. I've been using a modified verson of McListBox from a posting by vegaseat to get 2 treeviews going. It's been working well until I've been trying to be able to click on one to select what will be shown in the second. Anybody have an … | |
I'm trying to create a little text module for pygame. I've got everything up and running but I can't seem to get list.pop() to work. Whenever a person presses a key I put the chr() version of it into a list, then I iterate over that list to print out … | |
Nevermind, fixed it, I was being stupid. | |
Hey Guys i have a list like ['10015, John, Smith, 2, 3.01', '10334, Jane, Roberts, 4, 3.81' , '10208, Patrick, Green, 1, 3.95'] i need to split this list and create a list of this form 10015 John Smith 2 3.01 10334 Jane Roberts 4 3.81 any ideas how to … | |
hello im a hobbyist who is somewhat new to c++ with lots of experience in python. in python i was able to use dictionaries that could be accessed by keys and values with no limits on data types that can be stored but now im trying to port a simple … | |
# "toNumbers(strList) is a list of things,each of which represents a number.Modifies each entry in the list by converting it to a number." # Here is my code and it won't work,please help,thank you! import string def toNumbers(strList): nums = [] for i in strList: nums = nums.append(int(i)) return nums … | |
If you draw shapes that are closely spaced and shifted, you can create interesting interference patterns, so called moire patterns. Here is an example using the Python module PyGame to do the drawing. |
The End.