Subscribe to Novice#        RSS Feed

Completed some more projects off the Mega Project List on DIC.

Icon 1 Comments
This morning I woke up and was in a great mood for some programming. Thanks to finding a Google tutorial, I finally gave Python a serious look over and I'm glad I did. It's a really powerful language.

Check it out if you haven't seen it yet!

So without further ado, here's what I managed to make today (I've also completed the exercises in Google's site).

Keep in mind, I'm learning Python here and these things will probably seem trivial to most. :P But I did say I was going to complete the Mega Project List or die trying. So here goes nothing:

1. Reverse A String

word = raw_input("Please enter your string to reverse: ")
print word[::-1]

2. Count The Vowels In A String

word = raw_input("Please enter your sentance: ")
counter = 0
for letter in word:
    if letter.lower() == "a" or letter.lower() == "e" or letter.lower() == "i" or letter.lower() == "o" or letter.lower() == "u":
        counter += 1

print "There were " + str(counter) + " vowels in your input."

3. Count The Words In A String

sentence = raw_input("Enter your string, and I'll count the words: ")

wordList = sentence.split(" ")
print "There are " + str(len(wordList)) + " words in your sentence."

4. Check If A Word Is A Palindrome

word = raw_input("Please write in the word you want to check for palindrome: ")
if word == word[::-1]:
    print "Yes, it's a palindrome."
    print "No, not a palindrome."

5. Translate A Sentence To Pig-latin.

sentenceToTranslate = raw_input("Please write in the sentence you want to translate: ")
words = sentenceToTranslate.split(" ")
pigWords = []
def isVowel(letter):
    return letter.lower() in ['a','e','i','o','u']
for word in words:
    if isVowel(word[0]):
        tempWord = word + "way"
        tempWord = word[1:] + "-" + word[0] + "ay"
    print tempWord,

That's it for today. Tomorrow I'll get crackin' on a few more, but those will probably take a bit more time as they are GUI applications. Thanks for checking this post out.

1 Comments On This Entry

Page 1 of 1

williamgeorgegardner Icon

26 March 2010 - 10:24 AM
Looks very interesting, is Python worth learning?
Page 1 of 1

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

January 2017

22 23 2425262728

Search My Blog

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)