~*~Monika~*~ (sfubc) wrote in littlescripts,
~*~Monika~*~
sfubc
littlescripts

  • Mood:

Python Hates Me

Hello :) My name is Monika and I *thought/hoped* that I could be a "computer geek", but I am failing miserably. I am taking a course on web programming and we just started python and already I am totally lost. I have a project due on April 4th and an exercise due tonight and I need some serious help. Here is the problem:




***I guess my main problem is that I don't really understand CGI or getting it to the webpage. Logically I guess I just haven't really caught onto that. Any tips?***

Functions
Write a function called isnotspace that takes a character as its argument. If that character is a space, it should return False. If it's not a space, it should return True.

True and False are values built into Python to represent the result of boolean expressions. So, in your function when you decide the character isn't a space, you give back a true result with this line (with no quotes around the True):

return True
Test this function and make sure it works as it should. If you define the function and then enter this code:

print isnotspace("Q")
print isnotspace(" ")
print isnotspace(".")
...the program should output:

True
False
True
Write another function called isnotvowel that takes a character as its argument. If that character is a vowel (A, E, I, O, U), it should return False. If it's not a vowel, it should return True. You should return False for both uppercase and lowercase vowels:

print isnotvowel("A")
print isnotvowel("R")
print isnotvowel("i")
The output should be:

False
True
False
You will need these functions in the next part of the assignment.

Name Game
Create a web page with a form that asks the user for their name. When they submit the page, they should see their name, modified in the following ways:

Their name unchanged, as they typed it on the form.
Their name in all uppercase letters. You can use the string.upper function from the string module for this.
Their name will all of the spaces removed. You can use the built-in filter function and the isnotspace function that you wrote for this.
Their name will all of the vowels removed. You can use the built-in filter function and the isnotvowel function that you wrote for this.
The filter function is used to select only the characters from a string that make a particular function true. For example, if the isnotspace function is defined as above,

>>> print filter(isnotspace, "a b cdeF")
abcdeF
You can experiment with an example of a working name game. You can copy HTML code from this example if you wish.
  • Post a new comment

    Error

    default userpic
  • 5 comments