This is a simple word jumble game, I actually adapted it from one I used from practice.
It's written in Python 3.1 using the pyscripter. NO modules needed.
Word Jumble Game
# Word Jumble
#
# The computer picks a random word and then "jumbles" it
# The player has to guess the original word
#
# Obasa Adegoke - 11/04/11(dd/mm/yy)
import random
#this function jumbles the word
def word_jumble(word):
"""takes a word as arguement and jumbles it"""
jumble=''
while word:
position=random.randrange(len(word))
jumble+=word[position]
word=word[:position] + word[position+1:]
return jumble
#this is a function that selects a sequence from a tuple
def picker(w):
"""selects a random word from a tuple"""
word=random.choice(w)
return word
#this are the tuples contaning the word
terms = ('designing', 'programming', 'development', 'analysis', 'coding')
company = ('microsoft', 'IBM', 'apple', 'intel', 'google')
languages = ('java', 'cold fusion', 'python', 'jython', 'javascript', 'perl', )
systems = ('software', 'hardware', )
name = ('gates', 'jobs', 'yang', 'trovalds', 'filo')
#the various tuples are stored as a sequences in another tuple
combine = (terms, company, languages, name, systems)
#this function will prompt fo action to the taken after program execution
def decision():
"""prompts user for decision after program execution"""
decide = input('Do you want to try again (Y/N)')
decide = decide.upper()
if decide == 'Y':
run()
elif decide == 'N':
quit()
else:
print('It\s either Y or N')
decision()
#this is the function that runs the program
def run():
"""this function runs the program"""
word = picker(picker(combine))
jumble = word_jumble(word)
print(jumble)
guess = (input('Your guess\n'))
while guess != word:
print('You\'re wrong, try again')
guess = (input('Your guess\n'))
print('You\'re right')
decision()
#contents are now being seen from here
print('-----------------------------------------------------------------------')
print('---------------------------Word Jumble Game----------------------------')
print('---------------------------by adegoke obasa----------------------------')
print('----------------------------Instructions-------------------------------')
print(' A certain word pertaning to computer science has been jumbled, \n\
You\'re are to guess the word that is jumbled')
print('-----------------------------------------------------------------------')
run()
e-papa 13 Posting Pro in Training
e-papa 13 Posting Pro in Training
woooee 814 Nearly a Posting Maven
e-papa 13 Posting Pro in Training
e-papa 13 Posting Pro in Training
e-papa 13 Posting Pro in Training
e-papa 13 Posting Pro in Training
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
woooee 814 Nearly a Posting Maven
nezachem 616 Practically a Posting Shark
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
e-papa 13 Posting Pro in Training
e-papa 13 Posting Pro in Training
e-papa 13 Posting Pro in Training
e-papa 13 Posting Pro in Training
e-papa 13 Posting Pro in Training
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
e-papa 13 Posting Pro in Training
e-papa 13 Posting Pro in Training
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.