techPowerUp! Forums

Go Back   techPowerUp! Forums > Software > Programming & Webmastering

Reply
 
Thread Tools
Old Jan 27, 2010, 05:16 AM   #1
exodusprime1337
1000 Posts
 
exodusprime1337's Avatar
 
Join Date: Nov 2007
Location: Rhode Island, U.S.A
Posts: 1,818 (0.91/day)
Thanks: 138
Thanked 332 Times in 264 Posts
Send a message via AIM to exodusprime1337 Send a message via Skype™ to exodusprime1337

System Specs

python: what can i do with it

My girlfriends brother is a software engineer and i asked him about learning a programming language and he said that python was a pretty good place to start... i found some guides online that seem easy enough to follow but the problem i'm having is... what is it good for??

can anybody post some code they found or wrote for python 2 so i can see some examples of written code??
exodusprime1337 is offline  
Reply With Quote
Old Jan 27, 2010, 05:29 AM   #2
Yukikaze
2000 Posts
 
Yukikaze's Avatar
 
Join Date: Sep 2008
Location: Jerusalem, Israel
Posts: 2,121 (1.25/day)
Thanks: 213
Thanked 481 Times in 347 Posts

System Specs

Quote:
Originally Posted by exodusprime1337 View Post
My girlfriends brother is a software engineer and i asked him about learning a programming language and he said that python was a pretty good place to start... i found some guides online that seem easy enough to follow but the problem i'm having is... what is it good for??

can anybody post some code they found or wrote for python 2 so i can see some examples of written code??
I am currently running an experiment on Planetlab which is doing measurements of some things over the internet, and the code is written entirely in Python. I started coding in the language a very short while ago and it is indeed very simple and very easy to learn and comes with a very powerful library of tools (You have built-in code to do things like MD5 checksum calculations, working with ZIP archive files, and so on).

It can do just about anything you throw at it, including even things like basic 3D graphics by using Python libraries which interact with OpenGL.

I cannot provide examples of my code, for obvious reasons, and I gotta run to work, so I cannot find you anything very interesting as code examples off the web.

In general - Just about any shell (non-GUI) application you can think of, or can find on the web, written in any other language, can most likely be written in Python. As a scripting language, it is especially comfortable to use for file and text manipulation, or for the creation of small but helpful applications, such as this little bit of code generating random passwords for admins.
__________________
Cameron: Core i7 2600K 4.5Ghz, MCR220, 2xMCR120, MCP655, ASRock P67 Extreme4, 4GB DDR3, 2xOCZ Vertex 30GB RAID0, GTX470, 2xHD5670, Modu82+ 625W, TT Xaser VI.
Neuromancer: Core i7 975, DFI DK X58-T3eH6, 12GB DDR3 1333Mhz CL6-6-6-15-1T, 3x9600GSO 384MB, Hiper 880W, TT Xaser VI.
Administrator of a 40 core Hadoop cluster.
Yukikaze is offline  
Reply With Quote
Old Jan 27, 2010, 04:32 PM   #3
unibrow1990
75 Posts
 
unibrow1990's Avatar
 
Join Date: Mar 2009
Location: Detroit, Michigan
Posts: 193 (0.13/day)
Thanks: 36
Thanked 31 Times in 31 Posts
Send a message via AIM to unibrow1990

System Specs

Python is a great programming language to start learning in. It is the first language I learned to program in and while I have now found other languages I like better for everyday programming I think python is the best place to start.

Python is a general purpose programming language, so it is good for really anything, The only area where it struggles is in some computationally intense programs, because it is an interpreted rather than a com piled language and there fore slower to execute. This slowness is indistinguishable in everyday applications though.

I will post some python programs that I have written in a little bit(I have to change the code from 3.x to 2.x)
__________________
Backup Rig: Compaq prebuilt with AMD Athlon 64 3800+ Single Core and NVIDIA Geforce 7300GT 256MB
Laptop: HP DV2845SE
unibrow1990 is offline  
Reply With Quote
Old Jan 27, 2010, 05:50 PM   #4
unibrow1990
75 Posts
 
unibrow1990's Avatar
 
Join Date: Mar 2009
Location: Detroit, Michigan
Posts: 193 (0.13/day)
Thanks: 36
Thanked 31 Times in 31 Posts
Send a message via AIM to unibrow1990

System Specs

As promised here are some things I've written in python at various dates, I tried to confine it to more well written things that do some different actions.

Included:

GUI apps - A couple GUI apps I wrote that run scripted events out a parallel port, my friend used them with a circuit he built to make fireworks shows.

Quiz game - A simple Quiz game I wrote, includes an app that makes a default quiz and one that lets you write new quizzes.

Simple number game - A good one to look at to start,i its a simple Higher.lower number guessing game.

Working with files - An addition I wrote for a friends WoW module that demonstrates working with files and widows commands.

Hopes these help.
Attached Files
File Type: zip sample.zip (14.6 KB, 79 views)
__________________
Backup Rig: Compaq prebuilt with AMD Athlon 64 3800+ Single Core and NVIDIA Geforce 7300GT 256MB
Laptop: HP DV2845SE
unibrow1990 is offline  
Reply With Quote
The Following User Says Thank You to unibrow1990 For This Useful Post:
Old Feb 1, 2010, 11:10 PM   #5
regexorcist
75 Posts
 
regexorcist's Avatar
 
Join Date: Feb 2010
Location: ~/
Posts: 157 (0.13/day)
Thanks: 66
Thanked 46 Times in 38 Posts

System Specs

Python is awesome and easy to learn.
An execllent choice for a first language.
Multi-platform
Object Oriented
Forced indenting (creates good habits)
Fairly high-level so you don't get frustrated with low level details

Best of all, it's named after Monty Python
Good Choice, you should thank him!!
regexorcist is offline  
Reply With Quote
Old Feb 2, 2010, 04:01 PM   #6
regexorcist
75 Posts
 
regexorcist's Avatar
 
Join Date: Feb 2010
Location: ~/
Posts: 157 (0.13/day)
Thanks: 66
Thanked 46 Times in 38 Posts

System Specs

What can Python do???

This simple python script shows how many times
certain numbers came up in the NJ Cash5 Lottery.

It goes online and compares against the historical archive of winning numbers.

Code:
#!/usr/bin/python

import re
import urllib

lotto_link = 'http://www.state.nj.us/lottery/games/1-3-2_jc5_history_pfv.shtml'
my_numbers = ('01','02','03','04','05')

draw_numbers = ''
my_matches = []

file_handle = urllib.urlopen(lotto_link)

print 'Drawing Date   Winning Numbers   Numbers I Matched'
print '------------   ---------------   -----------------'

for file_row in file_handle.readlines():

  if file_row.startswith('        <tr><td valign="top" align="center">') \
  or file_row.startswith('<tr><td valign="top" align="center">'):
    
    draw_date = file_row.strip(' ')[36:46]
    draw_numbers = file_row.strip(' ')[83:97]

    my_matches = []

    for loop_count in range(0,4):
      if re.search(my_numbers[loop_count], draw_numbers):
        my_matches.append(my_numbers[loop_count])
          
    print draw_date,'   ',draw_numbers,'  ', my_matches

file_handle.close()
What can Python do?

Python can help you win the lottery
__________________
regexorcist is offline  
Reply With Quote
The Following User Says Thank You to regexorcist For This Useful Post:
Old Feb 4, 2010, 02:27 AM   #7
regexorcist
75 Posts
 
regexorcist's Avatar
 
Join Date: Feb 2010
Location: ~/
Posts: 157 (0.13/day)
Thanks: 66
Thanked 46 Times in 38 Posts

System Specs

Quote:
Originally Posted by unibrow1990 View Post
As promised here are some things I've written in python at various dates, I tried to confine it to more well written things that do some different actions.

Included:

GUI apps - A couple GUI apps I wrote that run scripted events out a parallel port, my friend used them with a circuit he built to make fireworks shows.

Quiz game - A simple Quiz game I wrote, includes an app that makes a default quiz and one that lets you write new quizzes.

Simple number game - A good one to look at to start,i its a simple Higher.lower number guessing game.

Working with files - An addition I wrote for a friends WoW module that demonstrates working with files and widows commands.

Hopes these help.
Thanks for the apps, I finally got around to downloading "unzip" for linux
so I could get at them.

(had to tweak things a bit)
Good Stuff
THANKS!!

Have you played around w/ Python3 yet?
__________________
regexorcist is offline  
Reply With Quote
Old Feb 6, 2010, 05:58 PM   #8
parelem
200 Posts
 
Join Date: Jun 2009
Location: Chicago
Posts: 215 (0.15/day)
Thanks: 96
Thanked 49 Times in 39 Posts
Send a message via AIM to parelem Send a message via MSN to parelem Send a message via Yahoo to parelem

System Specs

here are some programs i wrote when learning python, mostly basic python but also some cython and c extensions with the python api. don't remember exactly what all the programs are, i do know there's a maze builder and solver using classes. i'm sure i can dig up more, i can also get some tutorials and snippets i've written for anyone interested.
Attached Files
File Type: zip python programs.zip (55.3 KB, 97 views)
parelem is offline  
Reply With Quote
The Following User Says Thank You to parelem For This Useful Post:
Old Feb 6, 2010, 07:48 PM   #9
regexorcist
75 Posts
 
regexorcist's Avatar
 
Join Date: Feb 2010
Location: ~/
Posts: 157 (0.13/day)
Thanks: 66
Thanked 46 Times in 38 Posts

System Specs

Hi parelem,
How unusual, tarballs inside of a pk/win zip file

I opened one of your tarballs and found the Golden Search.
I've never used that, but it reminds me of the Fibonacci search
which reminds me of school and now my head is hurting.

And now that I'm thinking of school, I'm going to have a BEER

I'll get around to opening the rest of the tarballs soon
Good Stuff parelem (maybe a little too advanced for me )
__________________
regexorcist is offline  
Reply With Quote
Old Feb 7, 2010, 01:02 AM   #10
parelem
200 Posts
 
Join Date: Jun 2009
Location: Chicago
Posts: 215 (0.15/day)
Thanks: 96
Thanked 49 Times in 39 Posts
Send a message via AIM to parelem Send a message via MSN to parelem Send a message via Yahoo to parelem

System Specs

yeah, that golden section search was "fun" to say the least. the "275" labeled programs are more complex than the "mp" ones, i'll see what else i can find. if you have any questions regarding my files or python in general, feel free to ask.
parelem is offline  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What can I mount a .xmf with? Casheti General Hardware 7 Dec 29, 2006 07:01 PM
what can i do with avivo? Seany1212 Graphics Cards 4 Oct 6, 2006 07:36 PM
What can I do with a 9700pro? mobius Overclocking & Cooling 7 Dec 24, 2004 06:31 AM


All times are GMT. The time now is 11:08 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
no new posts