User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 397,765 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,498 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser:
Contribute Code
Converting a decimal integer (denary, base 10) to a binary string (base 2) is amazingly simple. An exception is raised for negative numbers and zero is a special case. To test the result, the binary string is converted back to the decimal value, easily done with the int(bStr, 2) function. (View Snippet)
Let's imagine you are taking a lot of pictures and modify them with one of those fancy image editors. You burned the image files to a CD, and decided to purge some of the outdated files because your hard drive is getting full. This Python code allows you to set an expiration date. Any image in... (View Snippet)
Here we apply the module difflib to compare two texts line by line and show the lines of the first text that are different from the second text. (View Snippet)
The map() function applies a function to every member of a list. Here a list of numbers 32 to 255 is changed to a list of the corresponding ASCII characters. Then map() is used in a more complex application to combine the two lists to form a dictionary containing number:character pairs. (View Snippet)
A common way to represent an inventory is with a list of tuples. Each tuple represents the item name and the item count. You can sort this inventory list by item name or item count. Here is an example to pick a sort key. It's your summer job to run a fruit stand along the road. You also have... (View Snippet)
A simple program to count the words, lines and sentences contained in a text file. The assumptions are made that words are separated by whitespaces, and sentences end with a period, question mark or exclamation mark. (View Snippet)
The module datetime allows you to call several functions that can do computation with dates and times. How many days since my birth? How many days till Xmas? What's the date 77 days from now? The code snippet should give you a flavor, enough to explore on your own. (View Snippet)
The wxPython library allows Python to create Windows GUI programs. Here is a look at the listbox component. Click a button to load the listbox with names, select the name by clicking on it on the list, and display it in the title bar of the window frame. Another button clears the listbox. (View Snippet)
The set is an unordered collection of unique hashable elements. All the elements/items in a set are treated as keys. There are several functions that compare two sets. Right now, I will just give you a taste ... (View Snippet)
We take a look at the various functions of module time, counting seconds and milliseconds, measuring the time a simple for-loop takes, inspect a list of time data and ways to display it in a useful manner. An attempt is made to find the day of the week, given a date a few years old. Like, what... (View Snippet)
Contribute Code
All times are GMT -4. The time now is 4:05 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC