We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,605 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion
Page 14 of Article: Projects for the Beginner
After you got the basics of Python under your belt, the best way to get a good knowledge of the language and improve your coding skills is to start on a project you are interested in. Maybe an image viewer, a slide show, computer generated random or fractal art, a…

Most of us remember September 11, 2001.
Write a Python program that shows how many days ago that event was, and on what day of the week.

vegaseat
DaniWeb's Hypocrite
Moderator
6,499 posts since Oct 2004
Reputation Points: 1,451
Solved Threads: 1,618
Skill Endorsements: 39

For some mild practice projects see:
http://codingbat.com/python

vegaseat
DaniWeb's Hypocrite
Moderator
6,499 posts since Oct 2004
Reputation Points: 1,451
Solved Threads: 1,618
Skill Endorsements: 39

Is it possible a PC app? for example an inventory system.... or POS (point of sales)?
I am curious about the language right now all I can do is just connecting to MySQL and displaying query results in DOS COMMAND

php_noob
Junior Poster
103 posts since Jul 2007
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0

what about making a simple classical bouncing ball game as indicated in the book entitled "how to think like a computer scientist pyhton 2, chapter 8?

melake
Newbie Poster
2 posts since Jun 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
  1. Use the SRCDS python library to make a console or GUI based RCON tool for Source and Half-Life game servers.

  2. Similarly, take an example code snippet (example: HTTP server) and write a GUI frontend for it. Some things to include for the given example: data tickboxes for IP:port which disable when the server is running and perhaps data logging (log start time, end time, any errors in a text file). Final addition: add command line tools to make it fully automated.

Remember though, don't take credit for code that isn't yours if you use it!

SgtMe
Nearly a Posting Virtuoso
1,211 posts since Oct 2009
Reputation Points: 68
Solved Threads: 85
Skill Endorsements: 0

What do you expect the results to be?

tuple_list = [(1, 2, 3), (4, 5, 6), (7, 8, 9)]
for first, second, third in tuple_list:
    print(second)
vegaseat
DaniWeb's Hypocrite
Moderator
6,499 posts since Oct 2004
Reputation Points: 1,451
Solved Threads: 1,618
Skill Endorsements: 39

Using a GUI toolkit like Tkinter construct a 7 segment numeric display.

vegaseat
DaniWeb's Hypocrite
Moderator
6,499 posts since Oct 2004
Reputation Points: 1,451
Solved Threads: 1,618
Skill Endorsements: 39

Given the length of three sides, write a function that checks if it is possible to create a triangle.

ZZucker
Master Poster
784 posts since Jan 2008
Reputation Points: 342
Solved Threads: 60
Skill Endorsements: 1

You go to the store to buy a pound of Tshibo Java, your favorite coffee beans. There you are confronted with a dilema, the usual pound container costs $10. But the store offers you a choice, a new container with 33% more beans for $10 or the one pound container for a 33% discount.

Write a Python program to figure out which deal is the best, or are they the same?

ZZucker
Master Poster
784 posts since Jan 2008
Reputation Points: 342
Solved Threads: 60
Skill Endorsements: 1

Write a program that lists the files that are in one directory but not in another directory.

HiHe
Posting Whiz
332 posts since Oct 2008
Reputation Points: 177
Solved Threads: 35
Skill Endorsements: 4

try creating a TIC TAC TOE game (or a X and 0 game).

extr3mex
Junior Poster in Training
70 posts since Jul 2009
Reputation Points: 7
Solved Threads: 4
Skill Endorsements: 6

Starting with the following card game code:

'''CardGame_draw_five1.py
create a deck of cards, shuffle and draw a hand of five cards
suit: club=C, diamond=D, heart=H spade=S
rank: ace=A, 10=T, jack=J, queen=Q, king=K, numbers=2..9
ace of spade would be AS, 8 of heart would be 8H and so on ...
'''

import random

def create_deck():
    """
    create a full deck of cards as a list of codes
    """
    ranks = "A23456789TJQK"
    suits = "CDHS"
    cards = [rank + suit for rank in ranks for suit in suits]
    return cards

def shuffle_deck(cards):
    random.shuffle(cards)
    return cards

def draw_5cards(cards):
    """
    pop five cards of the end of the cards list
    return a list of cards shorten by those cards
    and a list of the 5 cards
    """
    hand5 = cards[len(cards)-5:]
    # shorten the deck by these 5 cards
    del cards[len(cards)-5:]
    cards_left = len(cards)
    if cards_left < 5:
        cards = create_deck()
        cards = shuffle_cards(cards)
        print "A new deck of cards has been shuffled!"
    return cards, hand5


cards = create_deck()
cards = shuffle_deck(cards)
print("Cards in deck = %d" % len(cards))  # test
cards, hand5 = draw_5cards(cards)
print("Cards in deck = %d" % len(cards))  # test
print("Five cards drawn:")
print(hand5)
print("Five cards sorted by rank:")
hand5rank = sorted(hand5, key=lambda x: x[0])
print(hand5rank)
print("Five cards sorted by suit:")
hand5suit = sorted(hand5, key=lambda x: x[1])
print(hand5suit)

'''possible result -->
Cards in deck = 52
Cards in deck = 47
Five cards drawn:
['AH', '4C', 'TS', '6H', '7C']
Five cards sorted by rank:
['4C', '6H', '7C', 'AH', 'TS']
Five cards sorted by suit:
['4C', '7C', 'AH', '6H', 'TS']
'''

Write code to evaluate if you have a valid poker hand.

HiHe
Posting Whiz
332 posts since Oct 2008
Reputation Points: 177
Solved Threads: 35
Skill Endorsements: 4

This is a simple text editor using the Python GUI toolkt PySide:

'''ps_TextEdit_simple_editor1.py
use PySide's QTextEdit and QFileDialog to form a simple
text editor

click right mouse button in edit area for popup menu
for undo, cut, copy. paste, select All, etc.

PySide is the official LGPL-licensed version of PyQT
PySide is available for Windows and UNIX machines
downloaded the free Windows self-extracting installer
for Python27: PySide-1.1.0qt474.win32-py2.7.exe
for Python32: PySide-1.1.0qt474.win32-py3.2.exe
from:
http://developer.qt.nokia.com/wiki/PySide_Binaries_Windows
'''

from PySide.QtCore import *
from PySide.QtGui import *

class MyFrame(QWidget):
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        # setGeometry(x_pos, y_pos, width, height)
        self.setGeometry(100, 50, 600, 350)
        self.setWindowTitle('A simple editor using PySide')

        self.edit = QTextEdit(self)
        self.load_button = QPushButton(self)
        self.load_button.setText('Load text file')
        self.save_button = QPushButton(self)
        self.save_button.setText('Save text file')
        self.info_label = QLabel(self)
        s = "click right mouse button in edit area for popup menu"
        self.info_label.setText(s)

        # use grid layout manager
        grid = QGridLayout(self)
        # addWidget(QWidget, row, column, rowSpan, columnSpan)
        grid.addWidget(self.load_button, 0, 0, 1, 1)
        grid.addWidget(self.save_button, 0, 2, 1, 1)
        grid.addWidget(self.edit, 1, 0, 1, 3)
        grid.addWidget(self.info_label, 2, 0, 1, 1)
        self.setLayout(grid)

        # bind the button clicked to action
        # newer connect style used with version 4.5 or higher
        self.load_button.clicked.connect(self.load_file)
        self.save_button.clicked.connect(self.save_file)

    def load_file(self):
        """
        load the selected filename and display in QTextEdit
        get the file name via QFileDialog.getOpenFileName()
        """
        caption = 'Open file'
        # use current/working directory
        directory = './'
        filter_mask = "Python/Text files (*.py *.pyw *.txt)"
        filename = QFileDialog.getOpenFileName(self,
            caption, directory, filter_mask)[0]
        print(filename)  # test
        with open(filename) as fin:
            text = fin.read()
        self.edit.setPlainText(text)
        self.setWindowTitle(filename)

    def save_file(self):
        """
        save text in QTextEdit to a file
        """
        caption = 'Save file'
        # use current/working directory
        directory = './'
        filter_mask = "Python/Text files (*.py *.pyw *.txt)"
        filename = QFileDialog.getSaveFileName(self,
            caption, directory, filter_mask)[0]
        print(filename)  # test
        with open(filename, "w") as fout:
            text = self.edit.toPlainText()
            fout.write(text)
        self.setWindowTitle(filename)


app = QApplication([])
frame = MyFrame()
frame.show()
app.exec_()

See if you can embelish this code by introducing a find/replace text function.

HiHe
Posting Whiz
332 posts since Oct 2008
Reputation Points: 177
Solved Threads: 35
Skill Endorsements: 4

Write a Python program the finds the longest word in a given text string.

vegaseat
DaniWeb's Hypocrite
Moderator
6,499 posts since Oct 2004
Reputation Points: 1,451
Solved Threads: 1,618
Skill Endorsements: 39

This are the 100 most popular names given to baby girls in the US from 1900 to 1910:
Mary,Helen,Margaret,Anna,Ruth
Elizabeth,Dorothy,Marie,Florence,Mildred
Alice,Ethel,Lillian,Gladys,Edna
Frances,Rose,Annie,Grace,Bertha
Emma,Bessie,Clara,Hazel,Irene
Gertrude,Louise,Catherine,Martha,Mabel
Pearl,Edith,Esther,Minnie,Myrtle
Ida,Josephine,Evelyn,Elsie,Eva
Thelma,Ruby,Agnes,Sarah,Viola
Nellie,Beatrice,Julia,Laura,Lillie
Lucille,Ella,Virginia,Mattie,Pauline
Carrie,Alma,Jessie,Mae,Lena
Willie,Katherine,Blanche,Hattie,Marion
Lucy,Stella,Mamie,Vera,Cora
Fannie,Eleanor,Bernice,Jennie,Ann
Leona,Beulah,Lula,Rosa,Ada
Ellen,Kathryn,Maggie,Doris,Dora
Betty,Marguerite,Violet,Lois,Daisy
Anne,Sadie,Susie,Nora,Georgia
Maude,Marjorie,Opal,Hilda,Velma

... and these are the names for the years 2000 to 2010:
Emily,Madison,Emma,Hannah,Abigail
Olivia,Ashley,Samantha,Alexis,Sarah
Elizabeth,Isabella,Alyssa,Grace,Lauren
Taylor,Jessica,Brianna,Kayla,Sophia
Anna,Natalie,Victoria,Chloe,Sydney
Jasmine,Hailey,Megan,Rachel,Morgan
Julia,Destiny,Ava,Jennifer,Kaitlyn
Mia,Katherine,Alexandra,Haley,Savannah
Nicole,Maria,Allison,Mackenzie,Stephanie
Brooke,Amanda,Ella,Makayla,Faith
Kaylee,Jenna,Andrea,Katelyn,Mary
Jordan,Gabrielle,Rebecca,Paige,Madeline
Kimberly,Trinity,Zoe,Michelle,Sara
Lily,Kylie,Alexa,Caroline,Vanessa
Amber,Angelina,Gabriella,Lillian,Riley
Sierra,Danielle,Leah,Jada,Autumn
Erin,Maya,Ariana,Audrey,Isabel
Sofia,Marissa,Bailey,Jacqueline,Melissa
Claire,Evelyn,Shelby,Jocelyn,Mariah
Avery,Leslie,Melanie,Arianna,Aaliyah

Write a Python program that finds any names that are still popular over a hundred year span.

vegaseat
DaniWeb's Hypocrite
Moderator
6,499 posts since Oct 2004
Reputation Points: 1,451
Solved Threads: 1,618
Skill Endorsements: 39

Write a Python program that compares two text strings and gives a percent rating how well they match.

One hint ...

'''str_set_xor1.py
show the words that are in one text or the other
but not in both
'''

text1 = """\
Mary had a little lamb
its fleece was white as snow
and everywhere that Mary went
the lamb was sure to go"""

text2 = """\
Mary has a little lamp
his fleece as white as snow
and where ever that Mary went
the lamp is sure to go"""

# create a set of unique words for text1
set1 = set(text1.split())
# dito for text2
set2 = set(text2.split())

# create a new set with words in either
# set1 or set2 but not both (exclusive or)
set_xor = set1.symmetric_difference(set2)

# show result
print("%d words are different" % len(set_xor))
print('-'*22)
for word in set_xor:
    print(word)

'''result ...
11 words are different
----------------------
his
was
is
everywhere
its
lamb
where
had
lamp
has
ever
'''
vegaseat
DaniWeb's Hypocrite
Moderator
6,499 posts since Oct 2004
Reputation Points: 1,451
Solved Threads: 1,618
Skill Endorsements: 39

Given an amount of less than one Dollar/Euroes, write a Python program to represent this amount such that the least amount of common coins are used.

Lardmeister
Posting Virtuoso
1,940 posts since Mar 2007
Reputation Points: 465
Solved Threads: 73
Skill Endorsements: 5

Write a generator that produces the following sequence:
1,2,3,4,5,10,20,30,40,50,100,200,300,400,500

vegaseat
DaniWeb's Hypocrite
Moderator
6,499 posts since Oct 2004
Reputation Points: 1,451
Solved Threads: 1,618
Skill Endorsements: 39

Python 3.3 can communicate with a Bluetooth device and can be used to control one of those bluetooth remote controlled toys.
See:
http://bitsofpy.blogspot.co.uk/2012/09/bluetooth-with-python-33.html

The article uses the i-Racer ROB-11162, about $30 from
https://www.sparkfun.com/products/11162

Should be fun to explore!

Lardmeister
Posting Virtuoso
1,940 posts since Mar 2007
Reputation Points: 465
Solved Threads: 73
Skill Endorsements: 5

Write a custom wordwrap function for a text with long lines.

vegaseat
DaniWeb's Hypocrite
Moderator
6,499 posts since Oct 2004
Reputation Points: 1,451
Solved Threads: 1,618
Skill Endorsements: 39

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.1263 seconds using 2.89MB