1,175 Posted Topics
Re: re Q1: In this case you want to make sure that guess will be an integer, even if the user enters a floating point number. Actually with Python30 the int() becomes very important, since input() now returns a string. re Q5: This shows you the danger of using global. When … | |
Re: You will have to add a few extra print statements to space it out: [code=python]import random house =["Mansion", "Apartment", "Shack", "House"] spouse =["EMPTY", "EMPTY", "EMPTY", "EMPTY"] car =["EMPTY", "EMPTY", "EMPTY", "EMPTY"] kids =["0", "1", "2", "5"] print "Enter the name of three people you could marry: " name1 = raw_input("Name1: … | |
Re: Also, Python30 should give you an error if you use the print statement instead of the print function. Do you find pycurl easier to use than the usual cookielib and urllib2 modules that come with Python? | |
Re: Re: Why does it make another file with the ending ".Pyc" at the end? When you saved your class module as awclassPet.py, then Python will also create a compiled bytecode version of this file the first time it is used by an application. The precompiled file awclassPet.pyc will speed things … | |
Re: If I would be a beginner, I would simply start with Python30 and Swaroop's online tutorial book. If you bump into old code and have compatibility problems ask, there are enough old timers here to help. Or you could always try the 2to3.py utility that comes with Python30. Enjoy our … | |
Re: [QUOTE=revenge2;768841]ok so, just practising here sorry for useless console app but why not use {} to separate blocks. [CODE]number = 2 guess = 2 if number == guess: print ('yep its identicle') [/CODE] when i run that it says indentation error, but when i do [CODE]number = 2 guess = … | |
Re: There is "no beauty" in even simple C code! Let's all thank the Python development team for giving us a readable syntax. Come to think of it, they all were very fluent in C since the core of Python is writtten in C. I guess the true beauty of C … | |
(牛 Ox 丑 Chou) should start on January 26, 2009 Not completely sure. | |
Re: [QUOTE=Aia;725513]It didn't take very long for my words to be proved. ;)[/QUOTE]You won, congratulations! | |
| |
Re: Merry Christmas and a Happy New Year from the Great White Midwest! | |
Re: Take a stare at: C:\Python30\Tools\Scripts\2to3.py and use something like: 2to3 -w example.py | |
Re: A real sick place! However, in my place someone attempted to karate kick (as seen in some movie) my front door in two days before xmas to steal my meager xmas presents. One way to get presents for your loved ones! | |
Re: There is a small introduction at: [url]http://www.daniweb.com/forums/post764519-155.html[/url] | |
Re: If the word you enter is 'xp11' then it will do that. BTW you don't have to subtract one from wordsize, randrange() work like range(). Give it a test: [code=python]import random #word = raw_input("Enter a word: ") word = "consumer" wordsize = len(word) for k in range(10): randomnumber = random.randrange(0, … | |
Re: Instead of a listbox, use a 2 column listcontrol, where the second column is for the value. | |
Re: Do they celebrate by throwing their shoes at foreigners? | |
![]() | Re: [QUOTE=mn_kthompson;763291]What I mean by code blocks are specific to this board. When you post code on the board you should enclose the code in code tags so that it is more readable. You are correct that in the Python language code is grouped together by indentation only. The difference between … |
Re: You can do it this way ... [code=python]house= ["computer", "laptop", "tv", "nintendo DS", "table", "Empty"] print "items in my house are:" print house menu = """\ Pick an item to fill in the empty space: 1 - Lamp 2 - bed 3 - NDS q - to quit """ print … | |
Re: Take a look at Python module [B]struct[/B] in the Python manual. | |
Re: Take a look at: [url]http://www.daniweb.com/forums/thread98241.html[/url] | |
Re: [QUOTE=rebekkajoost;761649]Sorry if I am post in "/forums/forum152.html" category, but I am think it's the most suitable. Stay not long time before christmas and happy new years holidays. I am have big famaly and now I am even not know what kind of gifts make to my friends and famaly. So … | |
Re: What is your price range? If yo have XP now, prepare to get used to Vista, but then Linux would be even a steeper learning experience. Why not Dell? I am happy with my hand-me-down Sony Multimedia machine. | |
Re: Murtan's code is the cleaner code. In paulthom12345's code range(len(w1)) changes as w1 gets shorter, always a dangerous thing to do in a for loop. If you want to use one more random option, here it is: [code=python]import random w1 = ["abacus", "biology", "chemistry", "dog", "elf", "ghost"] # make a … | |
Re: One way to do this: [code=python]# creates variables qq1 - qq4 and initializes to 77 for i in range(1, 4): exec "%s = %d" % ('qq' + str(i), 77) print qq1 # 77 [/code] | |
Re: Here the Python module struct will come to the rescue, check the Python manual. | |
Re: [QUOTE=Rejinacm;759268]what is the reason why Python doesn't have switch statement ?[/QUOTE]Even in C the switch/case is not as efficient as multiple if/else and the cases are rather limited. Actually, a dictionary makes an excellent replacement for a switch/case and is very high speed on the lookups: [code=python]# a dictionary switch/case … | |
Re: p = re.compile(r'(href="(.*?)")') will do the trick | |
Re: ******() is not allowed as a function name. A function name has to start with a letter or an underscore and can contain numbers. | |
Re: You could also use: [code=python]def fuzzy_equals(a, b, delta=0.0001): """ returns true if (b-delta) < a < (b+delta) used for comparison of floating point numbers a and b """ return abs(a-b) < delta [/code]Adjust your delta to suit you. | |
Re: Just a note, don't use function names like list as variable names. [code=python]mylist = ["very", "hot", "day"] print "".join(mylist) # veryhotday # or use this, might be more descriptive for a beginner # empty string s = "" for word in mylist: # concatenate words s += word print s … | |
Re: [QUOTE=paulthom12345;725842]Is there anywhere to download pysonic for python 2.5? Because i cant find it on the sourceforge page..[/QUOTE]Find file pysonic.pyd installed on Python24 and copy it to Python25 pysonic will work with python25 if you hexedit pysonic.pyd --> find the python24.dll ref. and change it to python25.dll you can use … | |
Since anyone of us main street beings knows more about the real economy than 400 Wall Street kissing economy professors combined, here is a look how to present the state of the economy: [url]http://www.thedailyshow.com/video/index.jhtml?videoId=186052&title=clusterf#@k-to-the-poor-house[/url] | |
Re: Since I don't have any of the many versions of Linux, I can not test wx.Clipboard. I think it would be easier to store your text in a file for use across programs. If you use a wx.TextCtrl, can you highlight, rightclick and copy/cut and paste from the popup menu? … | |
Re: Please use code tags around your code. Something like this will do the summation: [code=python]sum = 0 n = 1 while n < 101 : sum += n print n, sum n = n+1 [/code]Note that sum += n is the same as sum = sum + n Proper code … | |
Re: San Diego California has the nicest weather in the USA. When the big one comes, it will fall into the ocean, so what! | |
Re: If John McCain starts smiling a lot at times when he really isn't supposed to, a Ron Paul (M.D.) and Bob Barr ticket might be the alternative for the GOP. | |
Re: We need a big government program to find the missing cold, so we can fight global warming. |
The End.