Test 1 Preparation CSCI 152

Problem 1:

Write a function: validPassword that has one parameter - string of characters. The function returns True if the string is a valid password, and False otherwise.

The rules for the valid password are:

  1. Length between 8 and 12 chars
  2. Must be combination of letters, numbers, and special characters, except '%' and '$'

For example:

yana123 - NOT VALID (too short and no special char)

Ya12{} - not valid (too short)

M3_lo*#@ - VALID

yana123Kortsarts123(! - not valid (too long)

M3_lo*$& - not valid ($ is not permitted)

Write main to test your function. In my examples I indicated the reason for validity/not validity. That was done for explanation purposes only. Your program doesn't need to explain the reason for validity/not validity.

Problem 2:

Write a function changeString that has one parameter - string of characters.

The function returns new string built using the following rules: all digits are replaced with '*', letter 'a' is replaced with '%' and the rest of the chars remains without change.

Write main to test your program

For example:
input: Yana123
output: Y%n%***