Week #4 Challenge: Python

  • (8 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

108 Replies - 19483 Views - Last Post: 06 September 2011 - 12:05 PM

#1 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Week #4 Challenge: Python

Post icon  Posted 25 January 2010 - 05:57 AM

Posted Image Week #4: Python

Posted Image


Challenge: Write a simple program using Python.


What is Python?

Python is a remarkably powerful dynamic programming language that is used in a wide variety of application domains. Python is often compared to Tcl, Perl, Ruby, Scheme or Java. Some of its key distinguishing features include:
  • very clear, readable syntax
  • strong introspection capabilities
  • intuitive object orientation
  • natural expression of procedural code
  • full modularity, supporting hierarchical packages
  • exception-based error handling
  • very high level dynamic data types
  • extensive standard libraries and third party modules for virtually every task
  • extensions and modules easily written in C, C++ (or Java for Jython, or .NET languages for IronPython)
  • embeddable within applications as a scripting interface

This is a simple script I wrote to calculate the first 16 powers of 2 including 0.
a = 0
b = 1
while a < 17:
	print b,
	a, b = a + 1, b * 2



In the print statement having the comma after b causes the next item printed to be on the same line. This line of code a, b = a + 1, b * 2 is a multiple assignment that assigns a + 1 to a and b * 2 to b.

This code snippet form KYA will sort a list.
# Bubble Sort 
# KYA
# 7-20-08
def bubbleSort(theList, max):
	for n in range(0,max): #upper limit varies based on size of the list
		temp = 0
		for i in range(1, max): #keep this for bounds purposes
			temp = theList[i]
			if theList[i] < theList[i-1]:
				theList[i] = theList[i-1]
				theList[i-1] = temp



Ideas:
For those of you who don't know what to do with Python, here's some ideas:
  • A number guessing game
  • Printing out the roll of dice
  • Create a random password generator that generates a password with a certain number of letters and numbers
  • A file handler that does something useful (such as remove executable properties on all files in the parent directory and below)
  • Advanced - Create a Twitter application using python-twitter or Python Twitter Tools
  • Advanced - Create a simple game demo using pygame

Resources:
We also have a Perl & Python forum and Snippets area as well as a couple Python Tutorials if you're interested.

How To Get Started:
Installing python on windows is no harder than installing any other piece of software, go to http://python.org/download/ and get the appropriate package. On linux it's likely already included, but python3 will need to be installed explicitly, most distros have a package named "python3", so go ahead and grab that (source is always available if you run an odd-ball distro). If you need help, just ask google.

For more information on installing Python you can visit this link.

Submit Your Challenge:
When you've completed the challenge, reply to this thread with a .zip/link/code/etc. of what you did.

Getting Help:
Post questions in our Perl & Python Forum.

Is This A Good Question/Topic? 0
  • +

Replies To: Week #4 Challenge: Python

#2 carltech  Icon User is offline

  • What did you call me?
  • member icon

Reputation: 28
  • View blog
  • Posts: 997
  • Joined: 19-October 07

Re: Week #4 Challenge: Python

Posted 25 January 2010 - 06:04 AM

maybe I'll put my python skills to the test on this one and make a game...I think I still have pygame on my desktop.
It has been a while since I used python though.
Was This Post Helpful? 0
  • +
  • -

#3 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Week #4 Challenge: Python

Posted 25 January 2010 - 06:06 AM

Then this is a great reason to try it again carltech. I look forward to seeing something from you.
Was This Post Helpful? 0
  • +
  • -

#4 Skaggles  Icon User is offline

  • THE PEN IS MIGHTIER
  • member icon





Reputation: 251
  • View blog
  • Posts: 640
  • Joined: 01-March 09

Re: Week #4 Challenge: Python

Posted 25 January 2010 - 06:27 AM

I know nothing about Python, so this would be a nice chance to check it out.
Was This Post Helpful? 0
  • +
  • -

#5 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Week #4 Challenge: Python

Posted 25 January 2010 - 06:30 AM

That's the spirit Skaggles! We are hoping for people to try things they have never worked with before. Until last week I had never tried Python either. So far I like it.
Was This Post Helpful? 0
  • +
  • -

#6 baavgai  Icon User is online

  • Dreaming Coder
  • member icon

Reputation: 5846
  • View blog
  • Posts: 12,705
  • Joined: 16-October 07

Re: Week #4 Challenge: Python

Posted 25 January 2010 - 06:51 AM

Hmm... I never got around to the twitter one. Can I combine the two? :P
Was This Post Helpful? 0
  • +
  • -

#7 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1876
  • View blog
  • Posts: 20,284
  • Joined: 17-March 01

Re: Week #4 Challenge: Python

Posted 25 January 2010 - 07:04 AM

Absolutely :) If you can figure out how to combine python, jquery, and twitter you can do all 3 ;)
Was This Post Helpful? 0
  • +
  • -

#8 Shane Hudson  Icon User is offline

  • D.I.C Technophile
  • member icon

Reputation: 343
  • View blog
  • Posts: 1,286
  • Joined: 06-December 09

Re: Week #4 Challenge: Python

Posted 25 January 2010 - 07:32 AM

Python? I remember using that when I was like.. 8 or something! I expect it has completely changed since then though, like all of the other languages have.

Downloading Python!
Was This Post Helpful? 0
  • +
  • -

#9 Chris Coneybeer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 30-October 07

Re: Week #4 Challenge: Python

Posted 25 January 2010 - 08:31 AM

So no never used python. Going to give the quick dice thing a go tonight. Been playing farkle lately and maybe create a quick game.
Was This Post Helpful? 0
  • +
  • -

#10 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Week #4 Challenge: Python

Posted 25 January 2010 - 08:34 AM

Sounds good Shane and Chris. I look forward to seeing something from you.
Was This Post Helpful? 0
  • +
  • -

#11 TheStuff  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 48
  • Joined: 16-April 09

Re: Week #4 Challenge: Python

Posted 25 January 2010 - 08:38 AM

OOOH. Nice. I've never actually done anything in Python, yet I have been very interested in it for a while. It was my alternative choice to C++ when I began, but I stuck with C++. Definitely giving this a shot.

2:30 AM here and school is starting soon so I guess I will start tomorrow.

This post has been edited by TheStuff: 25 January 2010 - 08:38 AM

Was This Post Helpful? 0
  • +
  • -

#12 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Week #4 Challenge: Python

Posted 25 January 2010 - 08:46 AM

Good to hear TheStuff. Look forward to seeing something from you. :)
Was This Post Helpful? 0
  • +
  • -

#13 brianarn  Icon User is offline

  • New D.I.C Head

Reputation: 11
  • View blog
  • Posts: 27
  • Joined: 02-October 09

Re: Week #4 Challenge: Python

Posted 25 January 2010 - 09:24 AM

I've been meaning to learn a little Python - I even have Dive Into Python 3 by Mark Pilgrim (an amazing author) and was planning on reading through the book this week, so, this lines up nicely.

Suggestion in general: If you want to learn a language but don't really have a specific project, picking something off of http://projecteuler.net/ is a great way to learn. Project Euler is neat. :)
Was This Post Helpful? 0
  • +
  • -

#14 tashe  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 107
  • Joined: 10-March 09

Re: Week #4 Challenge: Python

Posted 25 January 2010 - 09:39 AM

I like that it doesn't use curly braces like in Java or C++. It improves the readability so much.
Will definitely post something until the end of the week.
Was This Post Helpful? 0
  • +
  • -

#15 UrbanTwitch  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 233
  • Joined: 27-September 09

Re: Week #4 Challenge: Python

Posted 25 January 2010 - 10:43 AM

Hm. I barely know Python so this is going to be a good read. I may post something this week. :P

Thanks!!
Was This Post Helpful? 0
  • +
  • -

  • (8 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »