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

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.

commented: nice approach +14

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.

commented: +1 for PySide +14

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

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.

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
'''

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.

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

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

A good Project for the mid-way between beginner and intermediate is blackjack. It will get you used to most functions, list, objects, and depending on how serious you want it to be, GUI.

Assume you have filed all your code snippets into one directory. Write a Python program that searches this directory for keywords and brings up the names of the files that contain these keywords.

Control a turtle graphics canvas (module turtle) from an external Tkinter window with buttons.

Assume you have a list of unique integers, write a program that will show the closest pair or pairs.

You can use the Python third party module SimpleCV from:
http://www.simplecv.org/
To do Computer Vision experiments leading to rather interesting projects.

Create a function that shifts elements of a list in circular order.
For instance [1,2,3,4,5] --> [5,1,2,3,4] etc.

Using a Python GUI tookit like Tkinter write a numeric seven segment LED display like the ones on your alarm clock.

Write a Python program that finds the smallest number that can be divided by each of the numbers from 1 to 10 without leaving a remainder.

Compare texts and see which ones are a close match.
Work out a degree/percentage of match.

If you have a room with 16 people, how many times can they shake hands once with each other?

How about you try to make a calculator to find the chances of landing somewhere on monopoly from you location. What are the chances of getting from Mayfair to Liverpool Street Station in one turn?

In Tkinter programme a periodic table where if you click an element it gives you more info.

commented: Not so bad idea! +12
commented: Great idea, I'll definitely try this. +0

Use Tkinter to make a game similar to Pokemon with attacks and items.

Have a look at pygame

Work up to an final goal

You have two strings that look much alike:
waterkraftownermanuals
wadercraftownersmanual

Write Python program that will highlight the differences by capitalizing the characters that don't match:
waTerKraftownermanualS
waDerCraftownerSmanual

Generate 2 lists with 25 random numbers, where each list’s numbers are not within 20 digits of each other or others list. Numbers for list X must be less than 1024 and numbers in list Y must be less than 768. For example:

ListX = [80, 140, 1, 1014, etc…
ListY = [ 56, 25, 110, 612, etc…

Make a password generator where the user can enter how many characters they won't it to be and if the want symbols or not. Then it will generate passwords with Caps, Lowercase and numbers 0-9.

Hint- Use random number generator in python.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.