The "Chinese New Year" starts some day after January 20th and before February 20th, when the moon is at its lowest intensity. Write a Python program to show the intensity of the moon in its monthly cycle for a given monthly period.

Age calculator can be a small but good project...
Input date of birth from user : 04/22/1983
It program will output age (till today) as "25 Years 8 Months 15 Days".

Please make sure you test all case like for age < 1 Year or in month too :)... njoy

In case you are looking for a project that you can apply your newly learned OOP concepts to, here is one suggestion:

Take a group of people and keep track of their personal information like first name, last name, gender, age, and let's say bowling score. You want to know who is the youngest bowler, who has the highest score, and is there an age-score relation.

Crete a simple folder synchronization tool. It's not that difficult. I am still a beginner and I did it for my first project.
Hints
{the os module is very useful for stuff like this}

{use a list to compare all the objects in the folder. Use the os.listdir(pathname) method for this purpose. If you use windows you can use the os.system command to pass commands to the command line and then copy file usin it}

{for two way synchronization simply swap the path for the source folder and destination folder. }

Good luck

Write a slide show program that goes through image files in a given subdirectory with a set delay time.

Write a module, it can be whatever you like, then fill it with lots of useful function and stuff that will be able to make you codeing quicker later!

Exploring the Natural Language Toolkit (NLTK) for Python sounds like a very interesting project!

Work on the N-Queens chess board problem, where you have to place N number of queens on the board so none of them can attack each other. Solve for an increasing number of queens.

I have list of friends of type "firstname lastname", something like this:

``````name_list = [
"Erich Meitinger",
"Udo Baus",
"Jens Klein",
"Bjorn Bork",
"Heidrun Lovelace",
"Klaus Abraham",
"Ulla Jorgens",
"Volger Jenkings",
"Helmut Schmidt",
"Freja Larse",
"Larry Orkan",
"Andreas Mauser",
"Harry Heimlich"
]``````

Your mission in Python is to sort these items by last name.

Write a program that lists all the fonts available on your computer, and apply the selected font to a sample text.

Write a function that groups a large number into thousands. For instance
123456789 --> 123,456,789
or
1234567.89 --> 1,234,567.89

I did some detective work to find the stock trading value for a given ticker symbol. See if you can use the fruits of my labor and turn this into a more general portfolio tracker:

``````# find the stock trading value for a given ticker symbol
# tested with Python25

import urllib2

def extract(text, sub1, sub2):
"""
extract a substring from text between first
occurances of substrings sub1 and sub2
"""
return text.split(sub1, 1)[-1].split(sub2, 1)[0]

ticker = 'GE'
url = 'http://finance.yahoo.com/q?s='+ticker
fh = urllib2.urlopen(url)

#print(ticker_html)

for line in ticker_html.split('><'):
if 'id="yfs_' in line:
print(line)

print('-'*70)

# narrow it down
for line in ticker_html.split('><'):
if 'id="yfs_l' in line:
print(line)

print('-'*70)

# narrow it down even more
for line in ticker_html.split('><'):
if 'id="yfs_l10_' in line:
print(line)
print(extract(line, '>', '<'))
break``````

Here is the start of a Phone or Address Book:

``````# create a dictionary of class instance values
# can be expanded to an address book
# note: email is a Python module, so use e_mail
# snee

class DataBook(object):
def __init__(self, home, mobile, e_mail):
self.home = home
self.mobile = mobile
self.e_mail = e_mail
self.get_info()

def get_info(self):
sf = \
"""Home Phone = %s
Mobile Phone = %s
Email = %s
"""
return sf % (self.home, self.mobile, self.e_mail)

name_dic = {}

# first set of data
name = 'frank millato'
home = '123-456-7890'
mobile = '456-789-0123'
e_mail = 'frank23@gmail.com'

# the name string is the key and has to be unique
name_dic[name] = DataBook(home, mobile, e_mail)

# second set of data
name = 'bob dork'
home = '234-567-8901'
mobile = '567-690-1234'
e_mail = 'bob.dork@hotmail.com'

name_dic[name] = DataBook(home, mobile, e_mail)

# get bob's email
name = 'bob dork'
print( name_dic[name].e_mail )

print('-'*40)

# get the info for all names added so far
for key in name_dic:
print( "Name = %s" % key )
print( name_dic[key].get_info() )

print('-'*40)

# search for part of a name and find the mobile
search = 'dork'
for key in name_dic:
if search in key:
print( "%s has mobile = %s" % (key, name_dic[key].mobile) )

# to save the data, you can simply save it as a text file
# where each line is name, home, mobile, e_mail
filename = "Names1.txt"
fout = open(filename, "w")
for key in name_dic:
k = name_dic[key]
s = "%s,%s,%s,%s\n" % (key, k.home, k.mobile, k.e_mail)
fout.write(s)
fout.close()

"""
my output -->
bob.dork@hotmail.com
----------------------------------------
Name = frank millato
Home Phone = 123-456-7890
Mobile Phone = 456-789-0123
Email = frank23@gmail.com

Name = bob dork
Home Phone = 234-567-8901
Mobile Phone = 567-690-1234
Email = bob.dork@hotmail.com

----------------------------------------
bob dork has mobile = 567-690-1234
"""``````

Expand the data with the home address of the person.
How would you read the data file back into the program?
Also, query for data input and allow for editing of data.

Write a program that goes through a folder of source/text files and lists all the file names that contain a given search word (or combination of search words).

Here is a short code that allows you to list all the files in a given directory and its subdirectories:

``````#!/usr/bin/env python2.5

# list all files in a directory tree using recursion
# shows full file paths of all files in subdirectories too
# works with Python2 and Python3

import os

def mylister(currdir, mylist=[]):
"""default mylist becomes static"""
#print( "looking at %s" % currdir )  # test
for file in os.listdir(currdir):
# add directory to filename
path = os.path.join(currdir, file)
if not os.path.isdir(path):
#print(path)  # test
mylist.append(path)
else:
# recurse into subdirectories
mylister(path)
return mylist

# this allows the module mylister to be tested
if __name__ == '__main__':
# pick a folder/directory
# for Windows use something like this
#folder = r"C:\Temp"
# for Linux use something like this
folder = "/home/dell/Documents"
path_list = mylister(folder)
for path in path_list:
print(path)

"""my partial result -->
/home/dell/Documents/_sources/user/basics.rec.txt
/home/dell/Documents/_sources/user/performance.txt
/home/dell/Documents/_sources/user/basics.indexing.txt
/home/dell/Documents/_sources/user/basics.txt
/home/dell/Documents/_sources/user/basics.creation.txt
/home/dell/Documents/_sources/user/misc.txt
/home/dell/Documents/_sources/user/index.txt
...
"""``````

Change the code in such a manner that, for instance, only image files are listed. Image files would have extensions like .jpg .png .gif .bmp an so on.

The module turtle that comes with Python makes for interesting projects. Here is a function that draws a hexagon:

``````# explore module turtle (uses the Tkinter GUI toolkit)
# usually included in the Python2 and Python3  installation
# a function to draw 6 turtle lines to form a hexagon
# snee

import turtle as tu

tu.title('hexagon function')

def t_hexagon(x, y, side, color):
"""
draw an equilateral hexagon, each side has length=side
starting at coordinates x, y (upper side, right corner)
"""
tu.up()  # pen up
tu.goto(x, y)
tu.down()  # pen down
tu.color(color)
for k in range(6):
tu.right(360/6)
tu.forward(side)

# optional ('normal' is default) ...
# values for speed are 'fastest' (no delay), 'fast', (delay 5ms),
# 'normal' (delay 10ms), 'slow' (delay 15ms), 'slowest' (delay 20ms)
#tu.speed('fastest')

# optional pen width (default is 1)
tu.width(2)

# turtle by default starts at x=0, y=0
# wich is the center of a (ca. 450x550) window
# pick +x units to the right, +y units up,
# -x units to the left, -y units down
x = 50
y = 100
side = 100
color = 'red'
t_hexagon(x, y, side, color)

# keep showing until window corner x is clicked
tu.done()``````

If you run this code, you will see that the hexagon rests on its side. Your challenge will be to rewrite the function so it will draw the hexagon resting on its tip.

I don't know if this is appropriate for a beginner but I suggest designing a simple TicTacToe game for 1on1 mode because vs the computer is way harder to program. Try to create the 3x3 play field and check whether a player wins or loses. :)

Write a function that returns the longer of two strings or the first string if equal in length.

Write a program that calculates the day of the week for a date from 1900 onward having in mind that 1 January 1900 fell on a Monday
The program should be able to calculate any day for a year >= 1900
:)
Perhaps a GUI for it aswell....:)

Make sure you check for leap years...

maybe a simple program to take a string and print it out backwards
Then extend the program to check whether a word is a palindrome, i.e can be read the same way in either direction.
Further extension is to configure the program to determine whether a whole sentence is a palindrome.
Hint: remove all non-letter characters from the string first, including whitespaces :)

write a program to find the factorial of a number.
Hint: the program can be written in two ways - using a proper algorithm, or using recursion algorithm

P.S sorry in this is already posted in the forum...i didn't read all previous posts :)

Design a simple text-based calculator program that does all the simple calculations like addition, subtraction, multiplication and division. The program should have a menu and should prompt the user to enter an operation and print the result from that operation. Simple interaction would look like this:

``````>>>Available operations:
2. Subtraction
3. Multiplication
4. Division

Choose an operation: 1
Enter first number: 2
Enter second number: 3
2 + 3 = 5

Available operations:
....
....``````

Hint: divide the program into separate functions for each operation and for the menu as well :)

add the option conversion from binary to decimal and vice-versa :)

Here is a simple number project:

Prime numbers are positive integer numbers that are only divisible by itself or one. For example 2, 3, 5, 7, 11, 13, 17, are prime numbers, by convention 1 is not a prime number.

Palindrome numbers are numbers in which the decimal digits are the same read left to right as they are read right to left. For example 77, 131, 1441.

Your mission is to write a script that determines and prints all palindrome prime numbers less than 100000. Exclude the simple stuff like one digit numbers.

commented: interesting +14

Write a python program which will take DNA map of parents and childs as input and determine whether the child belong to the parent or not :D

Editor: Does anybody notice disgruntled C++ sarcasm?

This Tinter GUI toolkit program draws a rather ugly stick man ...

``````# exploring Tkinter's canvas drawing surface
# draw lines and ovals to form a stick man
# info at http://effbot.org/tkinterbook/canvas.htm

try:
# Python2
import Tkinter as tk
except ImportError:
# Python3
import tkinter as tk

def body(w, h):
"""draw the oval for the body"""
# an oval is drawn within a given rectangle
# (x1, y1, x2, y2) upper left and lower right corner coordinates
# of the rectangle the ellipse is bound by
# calculate coordinates relative to width w and height h
rect = (w//2-80, h//2-150, w//2+80, h//2+80)
canvas.create_oval(rect, fill='red')

"""draw the oval/circle for the head"""
# if the bounding rectangle is a square a circle is drawn
rect = (w//2-40, h//2-230, w//2+40, h//2-150)
canvas.create_oval(rect, fill='red')

def arms(w, h):
"""draw lines for right and left arm"""
# draw line from coordinate points x1, y1 to x, y2
# left arm
canvas.create_line(w//2-66, h//2-100, w//2-166, h//2-50)
# right arm
canvas.create_line(w//2+66, h//2-100, w//2+166, h//2-50)

def legs(w, h):
"""draw lines for right and left legs"""
# draw line from coordinate points x1, y1 to x, y2
# left leg
canvas.create_line(w//2-55, h//2+50, w//2-76, h//2+190)
# right leg
canvas.create_line(w//2+55, h//2+50, w//2+76, h//2+190)

# create the main window
root = tk.Tk()
root.title("Fred Stickman")

# create the drawing canvas
w = 400
h = 500
canvas = tk.Canvas(root, width=w, height=h, bg='white')
canvas.pack()

body(w, h)
arms(w, h)
legs(w, h)

# start the GUI event loop
root.mainloop()``````

Should you be interested, experiment with the drawing and make Fred Stickman look more like a movie star.

Create a test directory on your hard drive, copy some files and other directories into it. Now explore Python's file management functions and do the following:
1) list all the files in a given directory
2) list all the files in a given directory and its sub directories
3) list all the files with a given extension
4) copy files from one directory into another directory
5) total up all the file sizes in a given directory
6) find the largest or smallest file in a directory
7) find all the files past a certain cutoff date
8) search all the text files for a given word or sentence
9) change file names and creation dates

1) Write a handy tool like a notes program (you must learn to handle files, strings and GUI)

2) Write a 'program in need' like an automated Gentoo portage updater (I'm making my own, and it's not quite easy, since I support mailing reports, and other portage related tools upgrading like layman, eix or similar)

3) Get an already made program and try to do your own implementation without watching the source code (this is a bit advanced) for example ¿anyone remembers the "Blade: The Edge of Darkness" game? It was done on python.

If you feel confidence enough, write Eliza program

A morse code translator program.
Design the program so that it can translate words or sentences to morse-code. Then extend it so it is able to translate from morse-code. Just google "morse code" to find all the symbols and syntax :)

Did you know you could do that with the module os?

``````# using Python module os to create random values

import os

n = 35
# returns a string of n random bytes
random_bytes = os.urandom(n)
# some bytes may not be printable
# so create a string of all the printable bytes
random_str = ""
for byt in random_bytes:
# select ascii printable bytes/characters
if 32 < ord(byt) < 127:
random_str += byt
print(random_str)

for k in range(10):
# random integer from 0 to 255
random_integer = ord(os.urandom(1))
print(random_integer)``````

Go through all the Python module os functions and write an example code for each.

Be a part of the DaniWeb community

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