15,185 Topics

Member Avatar for
Member Avatar for Fernando_1

# 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 …

Member Avatar for vegaseat
0
217
Member Avatar for vegaseat

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 …

Member Avatar for vegaseat
3
406
Member Avatar for biscayne

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 …

Member Avatar for vegaseat
0
236
Member Avatar for clouds_n_things

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 …

Member Avatar for clouds_n_things
0
129
Member Avatar for padton

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 …

Member Avatar for TrustyTony
0
177
Member Avatar for TrustyTony

![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)

0
2K
Member Avatar for TrustyTony

![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 …

0
622
Member Avatar for carbonicacid81

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 …

Member Avatar for vegaseat
0
5K
Member Avatar for Andyvonschweal

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) …

Member Avatar for Lucaci Andrew
0
251
Member Avatar for vegaseat

This PySide (PyQT) code sample shows you how to apply a StyleSheet to a GroupBox containing a number of RadioButtons.

3
3K
Member Avatar for vegaseat

A little fun drawing with the Python module turtle. Well commented to help the beginner.

3
288
Member Avatar for ricepicker417

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 …

Member Avatar for vegaseat
0
2K
Member Avatar for flebber

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) …

Member Avatar for flebber
0
147
Member Avatar for krystosan

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 …

0
151
Member Avatar for Rod53718

#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 …

Member Avatar for Rod53718
0
5K
Member Avatar for lucaspenney08

Im new to python and im runnung xubuntu! I was wondering if there is a site that does tutorials for Python in xubuntu??

Member Avatar for lucaspenney08
0
68
Member Avatar for giancan

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 …

0
114
Member Avatar for dashing.adamhughes

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 …

Member Avatar for dashing.adamhughes
0
178
Member Avatar for Rod53718

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 …

Member Avatar for Rod53718
0
3K
Member Avatar for Frensi

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 …

Member Avatar for Lardmeister
0
236
Member Avatar for Echo89
Member Avatar for shanew21

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 …

Member Avatar for snippsat
0
194
Member Avatar for glenwill101

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 …

Member Avatar for glenwill101
0
3K
Member Avatar for UnchainedDjango

# "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 …

Member Avatar for UnchainedDjango
0
646
Member Avatar for vegaseat

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.

2
726
Member Avatar for noamjob

Hi, I want to perform a search with Python in this site: [url]http://www.draftexpress.com/search.php[/url] I want to search for a player who's first name is "james". The problem: The page with the result's url is: [url]http://www.draftexpress.com/search.php#results[/url] Obviously, when opening this page directly, I don't get the page with the results for …

Member Avatar for rmhapp
0
468
Member Avatar for bdheeraj

hello everyone i created a python file DailyExpensessave.py when i need to import this in another python program i was getting this error > Traceback (most recent call last): > File "C:\Python32\DailyExpensessave", line 1, in <module> > from DailyExpenses import * > ImportError: No module named DailyExpenses Both the python …

Member Avatar for sneekula
0
575
Member Avatar for giancan

Dear friends, is there a way to execute a dos command in a frame inside a wx.window GUI (and not in the usual external window)? Thanks

Member Avatar for sneekula
0
1K
Member Avatar for vegaseat

This small code example shows you how to approach the beginning concept of an very simple "IDE" for Python.

0
806
Member Avatar for welshly_2010

having a little trouble trying to convert this pseudo code into python, could any help receiveFile () { lastblock := 0 newblock := 0 ; repeat repeat event := getFrameFromUDP(m) ; case event of data : newblock := getBlockNoFromFrame(m) ; transmitAckOverUDP(newblock) | timeout: transmitAckOverUDP(lastblock) esac until newblock==lastblock+1 ; lastblock = …

Member Avatar for vegaseat
0
7K

The End.