Posts
 
Reputation
Joined
Last Seen
Ranked #26
Strength to Increase Rep
+17
Strength to Decrease Rep
-4
93% Quality Score
Upvotes Received
3K
Posts with Upvotes
2K
Upvoting Members
477
Downvotes Received
104
Posts with Downvotes
79
Downvoting Members
75
364 Commented Posts
~5.86M People Reached
About Me

Scientist

Interests
Astrophysics Sailing Hiking
PC Specs
Dell Inspiron 15 Windows81, Raspberry Pi Linux, MacOSX
Favorite Tags

4,305 Posted Topics

Member Avatar for Steph102

Just mildly more modern ... ''' coinflip102.py flip a coin 100 times and count heads and tails ''' import random # create a 100 count list of random 'head' or 'tail' mylist = [random.choice(['head', 'tail']) for k in range(100)] print("The Number of heads was {}".format(mylist.count('head'))) print("The Number of tails was …

Member Avatar for Dani
0
16K
Member Avatar for vegaseat
Member Avatar for Reverend Jim
15
13K
Member Avatar for kamaksha1

Are you trying to store your data in the file path? Please read the Windows manual on file path limitations.

Member Avatar for Reverend Jim
1
8K
Member Avatar for Freaky_Chris

[QUOTE=Freaky_Chris;609478]Its probably including the path in that case then, since the whole path C:\\..............\\whatever including the file is 305 characters long. Chris[/QUOTE]You could use os.chdir(path) to establish the working directory and then use the filename only.

Member Avatar for rory jackson
2
4K
Member Avatar for Reverend Jim
Member Avatar for Reverend Jim
10
3K
Member Avatar for Duki

Just finished a grilled salmon steak with a fresh garden salad and buttermilk dressing. Right now I am working on dessert, vanilla ice cream with a Kahlua chaser.

Member Avatar for Dani
22
17K
Member Avatar for Lardmeister
Member Avatar for Dani
0
121
Member Avatar for vegaseat

Using PySide's QAbstractTableModel allows you to easily customize a widget like QTableView and make it more generic in its application. Here we use it to present solvent data in tabular form and sort each column content by simply clicking on the header. You can feed it any data as long …

Member Avatar for Mark_94
5
6K
Member Avatar for vegaseat

Things don't have to be black and white all the time. Use a Windows API call to add some color to your text output.

Member Avatar for Dani
2
75K
Member Avatar for vegaseat

The Tkinter module comes with the normal Python installation. It allows you to create Python GUI programs for Windows, Linux or Unix on the Mac. In this snippet we put a GIF image (.gif) onto a form's canvas with just a few lines of code. Most of the lines are …

Member Avatar for CodeWorked
1
22K
Member Avatar for linux

Yes, there is a devlopment of a full featured GUI Operating System written in Python under the name Unununium (wouldn't be my choice), nicknamed after the 111th chemical element 'Roentgenium', whose temporary IUPAC name until November 2004 was 'Unununium'. See: [url]http://en.wikipedia.org/wiki/Unununium_(operating_system[/url])

Member Avatar for Thulan
2
2K
Member Avatar for LastMitch

Two movies I saw in the theater, and thought they were worth seeing again. So I bought the DVDs: "Crazy Stupid Love" with Steve Carell and Lulianne Moore. "Friends With Benefits" with Mila Kunis and Justin Timberlake.

Member Avatar for LoanHensley
6
6K
Member Avatar for mouigher

Seems to be too simple to be homework. You were almost there, you should only multply the overtime pay by 1.5. [code=python]""" output should be: Pay rate $10.00 Regular Hours 40 Overtime hours 20 Regular pay $400.00 Overtime pay $300.00 Total Pay $700.00 """ def hours(): hours = input("How many …

Member Avatar for Minasa
0
3K
Member Avatar for joe82

If you want to concatenate (join) every two lines in your file, then you can use something simple like this ... [code=python]names = """\ Valerie Vanessa Velvet Venice Venus Verena """ # create a test file filename = "mynames.txt" fout = open(filename, "w") fout.write(names) fout.close() mod_list = [] count = …

Member Avatar for vishakha_3
0
23K
Member Avatar for vegaseat

For those who are afraid of lycanthropes and full moons, here is a way to figure out the phase of the moon.

Member Avatar for Sichen
2
6K
Member Avatar for kingmu

Just a little quirk in Tkinter. Since the canvas has a default border of 2 pixels simply give it a [B]bd=-2[/B] to cancel it.

Member Avatar for Madnokof
0
11K
Member Avatar for vegaseat

What "Hello World" is to the console, the "Bouncing Ball" is to the Graphical User Interface. Nothing fancy, the ball is created via a call to the API function ellipse() and then bounced within the confines of the windows form. For the DEV C++ crowd: Let me know if you …

Member Avatar for laheg
2
25K
Member Avatar for vegaseat

The printer seems to be a much ignored computer peripheral when it comes to programming. This little code snippet explores one way to send text to the default printer. It actually draws the text into an imaginary box on the paper. You can specify the upper left and lower right …

Member Avatar for Djcordeiro
2
4K
Member Avatar for tony75

If you have pip installed, check with ... ''' modules_pip101.py list all the installed modules ''' import pip for item in pip.get_installed_distributions(): print(item)

Member Avatar for Andreas_7
0
22K
Member Avatar for sravan953

Something like Lardmeister's code would be a good start of an Equation Solver as set forth in: [url]http://www.daniweb.com/forums/post159522-7.html[/url] Just make sure you keep your units of measurement correct.

Member Avatar for Smartfitness33
1
14K
Member Avatar for Thanh Phong
Member Avatar for GooGooseGooey
0
36K
Member Avatar for macroasm

That particular software is very early alpha at best. At this point it is very clumsy and will frustrate you thoroughly!

Member Avatar for Titus_1
-4
2K
Member Avatar for ZZMike

From the Python manual that ships with every installation: str.strip([chars]) Return a copy of the string with the leading and trailing characters removed. The chars argument is a string specifying the set of characters to be removed. If omitted or None, the chars argument defaults to removing whitespace. ... Python …

Member Avatar for tinstaafl
0
13K
Member Avatar for Demetrius

I assume you are using Windows. With your knowledge in basic you should look into BCX. It programs in a modern basic and then translates to compile with a number of C or C++ compilers. I look at C is just a subset of C++, well let's say 99% of …

Member Avatar for k191376
0
15K
Member Avatar for miltocke

Rule of thumb is that it takes about ten good C++ programmers to do what 1 good Python program can accomplish in a given time span. So, yeah there are a lot more C++ jobs out there! On could imagine that with the help of AI future computers could do …

Member Avatar for Raunikkapoor
0
240
Member Avatar for Crazyscript77
Member Avatar for spam_1
0
4K
Member Avatar for Reverend Jim

A true Klingon Warrior uses only machine code, keyed in on the front panel switches in raw binary.

Member Avatar for John_smith
10
21K
Member Avatar for The Dude

Judging from what he does to the inside of my mouth, that could have been my own dentist. After all, a dentist lives from the pain of others.

Member Avatar for 1987davids
2
539
Member Avatar for piyush gandhi
Member Avatar for vegaseat
Member Avatar for paddy3118
1
2K
Member Avatar for dseto200

Take a look at ... http://www.daniweb.com/software-development/python/threads/466346/word-jumble#post2031135

Member Avatar for Akash_22
1
7K
Member Avatar for vegaseat

This simple isprime(number) function checks if the given integer number is a prime number and returns True or False. The function makes sure that the number is a positive integer, and that 1 is not considered a prime number. To find out if an integer n is odd one can …

Member Avatar for amir_19
3
24K
Member Avatar for vegaseat

If you press any key on your keyboard, this small Tkinter GUI program will tell you which key and what type of key has been pressed. Great for applications where a simple key stroke is required.

Member Avatar for Webtest
1
14K
Member Avatar for javi.crecenteespino

Play around with this, it might give you enough hints: http://www.developerfusion.com/tools/convert/csharp-to-python/ Good advice: http://stackoverflow.com/questions/683273/advice-for-c-sharp-programmer-writing-python There is also IronPython (MS endorsed) with a Python syntax that can be called from C# (4.0): http://blogs.msdn.com/b/charlie/archive/2009/10/25/hosting-ironpython-in-a-c-4-0-program.aspx

Member Avatar for happygeek
-2
11K
Member Avatar for vegaseat

An example showing how to use the wx.media.MediaCtrl() widget to play MIDI, MP3, WAV, AU, AVI and MPG audio and video files. I have only tested it with Windows. If you are very ambitious, you could use a random graphics display with the sound, or tie the slider position to …

Member Avatar for bunkus
2
4K
Member Avatar for Kim_11

This might be a hint: '''zg_triangle1.py using the Zelle graphics module (derived from Tkinter) http://mcsp.wartburg.edu/zelle/python/graphics.py ''' from graphics import * def drawTrianglePatch(win, colour): # polygon goes back to starting point (80, 20) triangle = Polygon(Point(80,20),Point(180,60),Point(60,220)) triangle.setFill(colour) triangle.draw(win) w = 250 h = 250 win = GraphWin("triangle stuff", w, h) colour …

Member Avatar for vegaseat
0
6K
Member Avatar for Harshali_1

Recursive functions have a neat look, but consume much stack space, Python sets a recursion limit of 1000. Recursive functions are rather slow, a while/for loop is much faster. Here are some typical examples: def get_factorial1(n): ''' would be poor choice because of the many function calls each call has …

Member Avatar for sritaa
0
477
Member Avatar for vegaseat

This short Python code gets the local time from the PC as a formatted string using time.strftime('%H:%M:%S'). The time string is displayed in a label using a larger font. A recursive function checks the time five times per second, and updates the time string, if it has changed. Five times …

Member Avatar for Vinay_17
2
26K
Member Avatar for Deepak.G
Member Avatar for vegaseat
0
5K
Member Avatar for vishesh_1

You might want to look at third party module **pandas** (it is a free download) http://pandas.pydata.org/pandas-docs/stable/tutorials.html#pandas-cookbook

Member Avatar for vegaseat
0
292
Member Avatar for Hicham_4

"The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing." Albert Einstein

Member Avatar for vegaseat
0
356
Member Avatar for vegaseat

Let's say you want to send a short private message to your friend, but don't want grandma to snoop around and find it. One way is to use the Python Image Library (PIL) and hide the message in a picture file's pixels. Just looking at the picture you will barely …

Member Avatar for JamesCherrill
5
10K
Member Avatar for Mike_63

The problem with the code in https://codegolf.stackexchange.com/questions/4707/outputting-ordinal-numbers-1st-2nd-3rd#answer-4712 is that the suffix for mumbers 11, 12, 13 is wrong.

Member Avatar for vegaseat
0
637
Member Avatar for HimaniBansal

Here is another example I wrote a while ago: ''' urlretrieve_image1.py retrieve and save an image from a web page using ... urlretrieve(url[, filename[, reporthook[, data]]]) tested with Python27 and Python36 by vegaseat ''' try: # Python2 from urllib import urlretrieve except ImportError: # Python3 from urllib.request import urlretrieve # …

Member Avatar for vegaseat
2
2K
Member Avatar for Isaiah_4

Try to get the sequence of numbers into a list using a for loop. Then you can sum up the elements of the list with sum()

Member Avatar for vegaseat
0
462
Member Avatar for HiHe

Nice approach! Here is another option to do this ... ''' tk_button_toggle2.py use a list default argument to create a Tkinter toggle button ''' try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk def toggle(tog=[0]): ''' a list default argument has a fixed address …

Member Avatar for martineau
1
21K
Member Avatar for HimaniBansal

I could think of valid functions that perform an action, like formated printing. No need to return anything.

Member Avatar for JamesCherrill
0
410
Member Avatar for pallavi_5

Python has a nice thing called sequence **slicing**: [starting-at-index : but-less-than-index [ : step]] 'start' defaults to 0, 'end' to len(sequence), 'step' to 1 for instance s = "123456789" then s[-1:] --> 9 s[-2:] --> 89 s[-3:] --> 789 and so on, do this with a for loop in range(1, …

Member Avatar for vegaseat
0
696
Member Avatar for Xavier_7

Give your function an argument, in this case just an empty one. **def exit(event):**

Member Avatar for vegaseat
0
224
Member Avatar for vegaseat

This code shows how to obtain and display a GIF image from an internet website using the Tkinter GUI toolkit that comes with the Python installation.

Member Avatar for woooee
4
25K

The End.