# sum up the ascii values of the characters in a word
word = "arguments"
ascii_sum = 0
for c in word:
    ascii_value = ord(c)
    ascii_sum += ascii_value

print(ascii_sum)  # --> 982

Find three words that have an ascii sum of 1000.

This could be an interesting historical project. From
http://en.wikipedia.org/wiki/State_of_the_Union
pick a number of "State of the Union" speeches. Then write a Python program that counts the 50 most common words sorted by frequency in each speech.

Hint:
take a look at module collections.Counter
you may need to preprocess the text, remove punctuation marks and convert to all lower case words

It's getting close to Christmas, write a Python program that uses the current date to calculate the shopping days to Christmas. Be careful, some wise guy might run your program just before New Years day.

Create a calculator using a dictionary ...

''' dict_calculator101.py
create a simple reverse polish calculator using a dictionary
'''

import math

def do_op(op, a=1, b=1):
    """use of a dictionary similar to C's switch/case"""
    return {
    '+': lambda: a + b,
    '-': lambda: a - b,
    '*': lambda: a * b,
    '/': lambda: a / b,
    '//': lambda: a // b,   # floor
    '**': lambda: a ** b,   # power
    'sin': lambda: math.sin(a),
    'cos': lambda: math.cos(a),
    'asin': lambda: math.asin(a),
    'acos': lambda: math.acos(a)
    }[op]()

# testing ...
# 355/113.0 pi approx.
print(do_op('/', 355, 113.0))  # 3.1415929203539825
# sqroot(25)
print(do_op('**', 25, 0.5))    # 5.0
# asin(sin(0.5))
print(do_op('asin', do_op('sin', 0.5)))  # 0.5

Your mission is to expand the dictionary.

Write a password manager. You get in it with one password and enter account name, user name and password for that account. The data is safely encrypted and stored in a file. You can tell the manager a particular account name and it will show the user name and password which you can copy and paste when the need arises.

Use Python to show that factorial(0.5) = sqrt(pi)/2

Explore Collatz numbers (the 3n+1 problem, L. Collatz in 1937)
http://mathworld.wolfram.com/CollatzProblem.html

Take any number, if even divide it by 2, if odd multiply it by 3 and add one,
should converge to 2 (ultimately to 1).

For instance starting with 7 ...
7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2

Write a function to merge a list of lists like
[[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]
into a single list like
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

# a Python code riddle, can you figure it out?

print(chr(98) + ''.join (['natural fruit'[:2][int(i==0) : 2+int(i==2)] for i in range(3)]))

Can you come up with some of your own code riddles?

Integer 197 is called a circular prime because all rotations of the digits 197, 971, and 719, are themselves prime numbers. Create a list of 3 digit primes and find all the circular primes.

I don't know if this has been said but a good one may be a bit hard is creating a Personal Assistant.

Write a Python program that checks a given directory for any file changes over a given period.

If you go to:
http://en.wikipedia.org/wiki/List_of_countries_by_inflation_rate
you can extract the 10 countries with the highest inflatuion rate.

You end up with this tab delimited data string:

data = '''\
Uruguay 8.11    2014 November
Turkey  8.9 2014 November
Egypt   10.61   2014 June
Argentina   24.2    2014 November
Ukraine 13  2014 December
Syria   13.6    2014 February
Iran    14.6    2014 June
Belarus 32.8    2014 December
Sudan   46.8    2014 July
Venezuela   60.9    2014 May'''

Now write a Python program to produce this string/text:

Country          Inflation (%)
Venezuela        60.9
Sudan            46.8
Belarus          32.8
Argentina        24.2
Iran             14.6
Syria            13.6
Ukraine          13.0
Egypt            10.61
Turkey           8.9
Uruguay          8.11

Explain the output of this code:

# generator expression
g = lambda: ((yield x) for x in range(5))

z = g()
for k in range(5):
    print(next(z))
commented: Not for beginners! Hint: search yield expressions +0

A mildly more advanced project. Write a Python program that lists and connects the functions, responsibilities and interactions of the branches and agencies of the federal government.
The program should help answer some questions like:
What is the path of a new law from inception to final approval?
What is the procedure to start a new war?
What is the procedure to aid victims of a natural disaster?
At what level is the abuse of power or corruption most dangerous?
Who governs the banking system?
How is a supreme court judge selected and what are the basic requirements of the position?
How is the president elected?

Write a program that scrambles each word in a sentence preserving the spaces.

For fun unscamble this sentence ...
scramble = "yaplgoo eeltrt mrfo het ondomc ocarfty"

Sort the characters in a word. eg. combine --> bceimno

Swap every two words in a text.
For instance
"is the zebra considered black or white"
would turn into
"the is considered zebra or black white"

Important, make it work for text with an odd number of words as shown above.

Enter a phrase and scramble the word order.
For instance
"advice is easier to give than to receive"
could turn into
"to give to than advice is easier receive"

Ask your friends to come up with the right phrase from the scrambled phrase.

Good stuff, and ideas. Thanks.

I am not a "spammer," but I do eat Spam. Does that make me a spammee?

Create an example of a nested list comprehension.

What has helped me a lot is researching in areas of Python that I do not currently need. I didn't need to use generators, but I pushed to learn how to create and use them, and now I do use them. Also, while learning generators, I began to learn comprehensions (still haven't mastered them).

Then of course one should always be learning how to manipulate and present strings. Much of what I learned from learning string manipulation and presentation has helped me with Regular Expressions.

Learn Regular Expressions now, as it is painful to have to learn them under pressure when you are trying to complete a project.

A hiker weighing 100 kg is going on a mountain hike. From the starting point to the top of the mountain are 1000 meters. How many calories has the hiker spent on the potential energy?

Write a program that gives you a specified amount of money with a minimum amount of bills and coins of the currency of your choice.

Create a list of consecutive prime numbers and check the difference between each of the numbers. Can you discover a pattern?

Simple Algebra ...
let
a = b
add a to each side
a + a = a + b
simplify left side since a + a is equal to 2a
2a = a + b
now subtract 2b from each side
2a - 2b = a + b - 2b
simplify left side since 2a - 2b is equal to 2(a - b)
2(a - b) = a + b - 2b
simplify right side since a + b - 2b is equal to a - b
2(a - b) = a - b
now divied both sides by (a - b), wowie zowie ...
2 = 1

Use Python to show that this cannot be right!

I wrote something pretty cool that didn't require a lot of python experience:

AI Rock Paper Scissors

I made a simple AI rock paper scissors program. It just looked at the most common chains of n moves, called a Markov chain, and predicted the next move like that.

# a cook has a list of ingredients from a recipe
ingredients = ["flour", "lard", "almonds", "sugar", "cinnamon"]

# items in the kitchen's pantry, spice drawer and cooler
pantry = ["flour", "sugar", "almonds", "peanuts", "olive oil"]
drawer = ["cinnamon", "salt", "pepper", "garlic"]
cooler = ["milk", "butter", "beef", "chicken", "fish"]
kitchen = pantry + drawer + cooler

# check if all ingredients are in the kitchen
# if not, show the missing ingredient(s)

Examine the Golden Ratio and how it relates to the Fibonacci numbers.

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.