Computer Science Canada

Test yourself

Author:  QuantumPhysics [ Mon Oct 15, 2012 10:08 pm ]
Post subject:  Test yourself

After you got the basics of Python under your belt, the best way to get a good knowledge of the language and practice your coding "skills" is to test yourself by creating applications and projects in languages, I thought to start this post so i could update it over time and give you some project ideas, here are some:

Make a program that can generate random passwords
For example:
#1
password length is fixed (or the user could enter a length)
number of characters in password is random (or again the user could specify)
number of digits in password is random (or user specified)
location of numbers/characters in password is random OR you could ask the user for a word then you could use that as a base and perhaps stick things on the end or begining or perhaps replace certain letters with numbers.

#2
If you don't know what a ceaser cypher is then read this: http://library.thinkquest.org/C0126342/ceaser.htm

Make a simple program that encrypts and decrypts a simple sring into a ciphertext (my terminology is terrible, so bear with me)
example:

let's encrypt the string: 'ceaser'
using a ceaser shift of lets say...11
so to start with, the 'c' in ceaser would be shifted 11 places down the alphabet and end up as 'n':

a b (c) d e f g h i j k l m (n) o p q r s t u v w x y z
^ --------- 11 -------- ^
so basically you do that untill all the letters in the plaintext 'ceaser'
have been shifted 11 places along the alphabet:
'ceaser' == 'npldpc'

Note: if you reach the end of the alphabet and the count (11) is still not finished just go back to the start, ('s' and 'r' had to do that)

So once you've got that nailed, let the user input the string they want to convert and perhaps let them change the shift (number of places the letter is moved)
then simple enough if you want to decode/decrypt (whatever it's called) just stick a minus in front of the shift number (11 would = -11) so that it shifts backwards

#3 - (Python project)
Let's assume you are working for the NSA and wanted to use Python to profile large amounts of e-mail that you are intercepting.
Write three fictitious e-mails, one a business e-mail, one a love/romance e-mail and one e-mail from "whatever name here" to an accomplice that threatens your country.
Now use Python's text handling prowess to profile the three letters, so the threatening letter can be identified. Check if fragments of words can do this

Author:  Aange10 [ Tue Oct 16, 2012 7:59 am ]
Post subject:  RE:Test yourself

#3 sounds pretty cool, and slightly illegal Smile

Author:  QuantumPhysics [ Tue Oct 16, 2012 9:42 pm ]
Post subject:  RE:Test yourself

#4 -

Print a 9x9 diamond shaped pattern like this

*
***
*****
*******
*********
*******
*****
***
*
using loops.

#5 -

You have the following data statements:

data = """
Bobby likes David and Jean, but hates Kim.
Bob loves Jean, and likes David and Kim.
Jean loves Bob, likes Bobby, but hates Kim.
Kim hates Bobby, likes David and Bob.
David loves Martin, and hates Karl and Jean.
"""
Write a program that lists each person and whom they love, like and hate.

Author:  DemonWasp [ Wed Oct 17, 2012 9:48 am ]
Post subject:  RE:Test yourself

The difficulty of these seems to vary wildly.

#1, 2, and 4 are all easily at the high school level.

Depending on the requirements for #5, it could be either trivial (repeat the input) or extremely difficult and unsolved (natural language processing).

#3 definitely involves natural language processing, which almost certainly requires at least a 4th-year course in AI (to be done correctly. You might get some success looking for "hot" keywords ("bomb", "hate", etc), but you'll get a lot of false positives: "I may hate Bob, but his party was the bomb!" is an innocent message, but "I hate America, and soon they will suffer the bomb!" is not. Worse, you have to account for spelling errors, code phrases, etc.

Plus, it may be illegal for private citizens, but that's actually something that the NSA (among other organizations) does regularly: the US government "reads" nearly all email correspondence, in addition to monitoring social networks and most other unencrypted communication channels (and presumably at least some of the encrypted ones).

Edit: see also http://en.wikipedia.org/wiki/ECHELON

Author:  QuantumPhysics [ Thu Oct 18, 2012 10:51 am ]
Post subject:  RE:Test yourself

Yea but, this is a forums for people of many capability. #3 is very easy. You just gotta know what you are doing. I'm on my final year of high school and I can do it with my hands behind my back. Depends on the language you are using too.


: