10.4 - Challenges
Create a sub-program for each challenge below. It must match the provided dataflow.
You should test each sub-program fully to ensure it works as expected.
1 - Capital first letter
Write a function that will ask the user to enter their name. If the name is missing a capital letter then it should be updated to include one.
Jane = Accepted
jane = Update to Jane
Data flow
OUT: name
2 - Remove non letters
Write a function that will remove all non letter characters from a string.
Jack and Jill went up the hill. -> JackandJillwentupthehill
Data flow
IN: sentence
OUT: new_sentence
3 - Count capital letters
Write a procedure that will count and display the number of capital letters in a string.
Data flow
IN: string
4 - Check alphabetical order
Write a procedure that will check if a word is in alphabetical order.
The procedure should assume the word will only contain lower case.
cat = Not alphabetical
fox = Alphabetical
Data flow
IN: word
5- Password validation
Write a function that will ask the user to create a password. The password must have at least one
- capital letter
- lowercase letter
- number
- punctuation
Data flow
OUT: password
6 - Convert last word
Write a function that will change the last word in a sentence to uppercase.
The cat sat on the mat -> The cat sat on the MAT
Data flow
IN: date
7 - Placeholder text
Write a function that will generate a paragraph of placeholder text based on the parameter para_size.
5 = jdkls
10 = kfehikeicj
Data flow
IN: para_size
OUT: paragraph
8 - Password guesser
Write a procedure that will accept a password as a parameter. It should then attempt to guess that password by trying every possible combination.
It should stop guessing when it guesses correctly.
Assume the password is all lowercase letters.
Guesses should look like.
- aaaa
- aaab
- aaac
- …
Data flow
IN: password