4,305 Posted Topics
Re: Well, it is our policy on the forum not to do homework for you, but here are some elaborations (tests) that should help you in a hintful way ... [code=python]# months abbreviated dictionary (created from a list) mad = {'MAR': 3, 'FEB': 2, 'AUG': 8, 'SEP': 9, 'APR': 4, 'JUN': … | |
Re: I just read an article in the Guardian about large scale windfarming off the Scottish coast. That must be a perennially windy corner. They are using knowledge gained with oil rigs there, and are using super large blades. Why they are rusty I don't know, but then way out there, … | |
Re: It almost looks like graphics22 is a variant of the graphics module written by John Zelle for use with the book "Python Programming: An Introduction to Computer Science" (Franklin, Beedle & Associates). This is a custom wrapper for Tkinter. Unless you have a detailed manual for it, help from us … | |
Re: What does a typical element in your list look like? If it's a file, what does a typical data line look like? | |
Re: 9/11 was a conspiracy alright, a conspiracy by Mister Laden and friends. He and most of his friends are still on the loose, thanks to the fact that our boys are too busy pilfering Iraq right now. With boys I don't mean our troops, but their leaders. | |
Re: That may be tough because a continuous key press is interpreted by your operating system as a repeated key press. | |
Re: Actually the whole exercise is a great example of Python's slicing operator ... [code=python]# slicing operator seq[begin : end(exclusive) : step] # step is optional # defaults are index begin=0, index end=len(seq), step=1 """ separate info in line into ID#,Last,First,Territory#,Office#,Salary,SSN,Department#,JobClass 00001,ADAMSON,JAMES,01,01,40000.00,145503242,01,02 """ line = "00001JAMES ADAMSON 010104000014550324201021500067500040010011593" # extract the … | |
Re: For plotting you can also install VPython, see ... [url]http://www.daniweb.com/code/snippet376.html[/url] or wxPython, take a look at ... [url]http://www.daniweb.com/code/snippet689.html[/url] | |
Re: Look at your conditions: 90 - 100: A 80 - 89: B 70 - 79: C 60 - 69: D < 60: F The last line says, if the score is less than 60, then the grade is an F. That would be the easiest to write for the computer … | |
![]() | Re: Iamthwee, kicking somebody into a new thread is not very funny, neither is your avatar and your location. I have enjoyed many of your contributions in the past, but this one fails. ![]() |
Re: At least they are using their money for a constructive project, rather than killing, maiming and bombing. | |
Re: [quote=EnderX;457897]Given that it's Lardmeister saying it, and his responses elsewhere in this forum, I'm assuming he was mixing them with 'Liberty Cabbage' (aka sauerkraut).[/quote] Clearly a major mistake by Lardmeister, here is the official story ... [quote] On [URL="http://en.wikipedia.org/wiki/March_11"][U][COLOR=green]11 March[/COLOR][/U][/URL] [URL="http://en.wikipedia.org/wiki/2003"][U][COLOR=green]2003[/COLOR][/U][/URL], [URL="http://en.wikipedia.org/wiki/United_States_House_of_Representatives"][U][COLOR=green]Representatives[/COLOR][/U][/URL] [URL="http://en.wikipedia.org/wiki/Bob_Ney"][U][COLOR=green]Robert W. Ney[/COLOR][/U][/URL] ([URL="http://en.wikipedia.org/wiki/Republican_Party_%28United_States%29"][U][COLOR=green]R[/COLOR][/U][/URL]-[URL="http://en.wikipedia.org/wiki/Ohio"][U][COLOR=green]Ohio[/COLOR][/U][/URL]) and [URL="http://en.wikipedia.org/wiki/Walter_B._Jones"][U][COLOR=green]Walter B. Jones[/COLOR][/U][/URL], … | |
Re: Check the spelling of 'folder' ... [code=python]mytype = ikmo.getObjectType() print mytype # see if returns 'Folder' or 'folder' if(ikmo.getObjectType() == 'Folder'): sReturnURL = 'Present?object=1.11.1234' else: sReturnURL = 'Present?object=%s' % (oid) [/code] | |
Re: Might be your spelling, in one case you have it listed as .\Templates\html\temlate1.html the error shows '.\Templates\html\template1.html' | |
![]() | Re: From a google by redmarvel ... [QUOTE] A program is never finished until the programmer dies. A paperless office has about as much chance as a paperless bathroom. A user friendly computer first requires a friendly user. Bad or missing mouse driver. Spank the cat [Y/N]? Best file compression around: … |
Re: He who has the most things when he dies wins! | |
Re: If you are uncomfortable with lambda, you can also use itemgetter() from the module operator ... [code=python]from operator import itemgetter first_list = [ " marek brutalski 20", "zenia markownikowa 10", "teresa parufkowa 90", "bogumila pierdawa 40", "genowefa tempawa 50"] second_list = [x.split() for x in first_list] # first column is … | |
Re: One way to do this is using a high speed list comprehension ... [code=python]# combine two 2D lists using a list comprehension # a list is Python's more flexible array container a = [[1, 2, 3], [2, 3, 4], [3, 4, 5]] b = [[4, 5, 6], [6, 7, 8], … | |
Re: Please don't wrap your whole post into quote tags or your code tags won't work! | |
Re: Most commonly used function ... [code=python]def int2bin(n): '''convert denary integer n to binary string bStr''' bStr = '' if n < 0: raise ValueError, "must be positive" if n == 0: return '0' while n > 0: bStr = str(n % 2) + bStr n = n >> 1 return … | |
Re: [code=python]# set is builtin starting with Python24 new_list = [2,34,5,5,6,6,7,2] print new_list # [2, 34, 5, 5, 6, 6, 7, 2] new_set = set(new_list) print new_set # set([2, 7, 34, 6, 5]) [/code]Shorter ... [code=python]# use set() to make a list unique, order is lost mylist = [2, 34, 5, … | |
Re: [quote=cscgal;453565]At that point just wait a couple of years for the inheritance.[/quote]Shades of [B]Anna Nicole Smith?[/B] | |
Re: Lardmeister, for a twelve year old you are one heck of a clown! | |
Re: [code=python]# %r uses repr() and %s uses str() # for example ... print "%r tag requires exactly two arguments" % "this" print "%s tag requires exactly two arguments" % "this" """ my output --> 'this' tag requires exactly two arguments this tag requires exactly two arguments """ [/code] | |
Re: Thanks G-Do for your information, so NumPy eventually replaces Numeric and Numarray. Interesting! When I was coding in C, I used to sample lab data and put it into a circular or ring buffer to keep the thing from overflowing. This was an easy way to calculate a moving average. … | |
Re: [quote=jwenting;451918]I'd consider being locked up with Paris to be "cruel and unusual" punishment and therefore illegal... I'd rather be locked up in a fictional CIA torture prison than that.[/quote]Very funny! Paris must have some redeeming features though! I am too old for that! In some countries a thief looses a … | |
Re: Here is the way I figured it out: Let's say 5! = 1 * 2 * 3 * 4 * 5 the 1 drops out then 5! = 2 * 3 * 4 * 5 apply the log operator log(5!) = log(2) + log(3) + log(4) + log(5) for(j = … | |
Re: Be careful with a slice copy ... [code=python]old_list = [1, [2, 3,[4]], 5] new_list = old_list[:] # now change old_list old_list[1][0] = 1111 print old_list # [1, [1111, 3, [4]], 5] print new_list # [1, [1111, 3, [4]], 5] oops! [/code]If you want to make a copy of a list, … | |
Re: Beyond the finite universe is most likely another finite universe. | |
Re: Even though Python has // as an integer division operator, I most commonly use the / operator. Right now you can use the / or the // operator for integer divisions, and here is were I get into trouble. [code=python]a = 4/5 print a # oops the result is 0 … | |
Re: [quote=MrShoot;446737]Interesting, could you explain me a bit this part? [code=python]conv_list +=[el.lower()][/code] What exactly would the += do there?[/quote]This is just a shorthand of ... [code=python]my_list = ["CANADA", "HELLO", "I TOLD YOU SO"] conv_list=[] for el in my_list: conv_list = conv_list + [el.lower()] print conv_list """ my output --> ['canada', 'hello', … | |
Re: Welcome to DaniWeb! Python's syntax might be easy for a beginner, but you have to remember that Python's power comes from knowing which of the many modules to use to make coding easier. In your case the module time will save you a lot of time (no pun intended). With … | |
Re: I suspect that it is the trace fluorides in the salt. Everytime I go to the dentist, she smears some fluoride paste on my teeth, and now I have hair growing between my teeth. | |
Re: Skydivers can achieve a maximum of 120 mph during the free fall part of their dive. So 130 mph is a real achievement! | |
Re: Just remember that the first time a function is invoked/called, its code gets loaded into memory. If you give an argument a default that is mutable, you have to be aware of how that will behave. In practice, most of the time you won't do a default with a mutable. … | |
Re: This happens with many computer languages. You are trying to compare floating point values directly. Your 0.8 might be more like 0.799999999999999 and the compare flunks! You can make this work by giving it a range you can compare within ... [code]if 0.79999 < status < 0.80001: ... do something` … | |
Re: I am not familiar with this old graphics module, but generally you draw the face inside a rectangle/frame/canvas and move the whole rectangle/frame/canvas around. | |
Re: We need to see some code so we figure out which GUI toolkit you are using and which picture format you want to load. | |
Re: Here would be a typical example ... [code=python]# experiments with wx.StaticText(), set a font for the text import wx class MyFrame(wx.Frame): def __init__(self, parent, id, title, data): wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, size=(500, 380)) panel = wx.Panel(self, -1) # font type: wx.DEFAULT, wx.DECORATIVE, wx.ROMAN, wx.SCRIPT, wx.SWISS, wx.MODERN # slant: wx.NORMAL, … | |
Re: An interesting project, it will force you to learn three languages (Python, HTML and XML) all at the same time. Python has quite a number of XML related modules. Your project might be more a string handling project though. | |
Re: Two comments: 1) pack() does not have row and column, that is for grid() 2) do not mix pack() and grid() in the same frame | |
![]() | Re: Don't know why, but it makes my heart beat better: "A Whiter Shade Of Pale" by Procol Harum |
Re: Thanks for the info, there is always room for one more good example to learn from! | |
Re: For posting Python code on Daniweb: Please use the [B][noparse][code=python][/noparse][/B] and [B][noparse][/code][/noparse][/B] tag pair to enclose your python code. Another note: Also make sure that the thread's title has something to do with your problem. | |
Re: Check the "Open Graphics Library" (OpenGL), there is a Python wrapper for it called PyOpenGL. VPython (VisualPython) might be easier to deal with: [URL]http://vpython.org/[/URL] Here is a VPython example ... [code=python]# a simple red cylinder in space # experiments with visual Python (VPython) # download from: [url]http://vpython.org/[/url] import visual as … | |
Re: Do you want to break the list into 2 lists at a set index? [code=python]file = ['S','D','S','D','S','D','N','S','D','S','D','N'] break_index = 6 list1 = file[:break_index+1] list2 = file[break_index+1:] print list1 print list2 """ result --> ['S', 'D', 'S', 'D', 'S', 'D', 'N'] ['S', 'D', 'S', 'D', 'N'] """ [/code] | |
Re: Once you get familiar with constructs like list comprehension, they become quite easy to read. List comprehensions also give quite an improvement in speed too. | |
Re: Maybe, when they cut the throats of the goats, some sacrificial blood spattered onto the plane's loose wiring and made it hold its contact. No, it was most likely the god of flight and fertility. Neat title for the thread Salem! | |
Re: I use both DrPython (Windows and Linux) and PyScripter (Windows). DrPython needs wxPython and is very stable, relies on plugins for advanced features. PyScripter comes as an .exe file (written in Python for Delphi) and has some excellent features out of the box. The one I like is that it … |
The End.