Question: 1 . Write, test and debug a function called isPrime that takes a positive whole number, ( boldsymbol { n } )

1. Write, test and debug a function called isPrime that takes a positive whole number, \(\boldsymbol{n}\), as its single parameter and returns True if \(\boldsymbol{n}\) is a prime number and returns False if it is not.
A prime number is a whole number that is divisible by no numbers other than 1 and itself Note that 1 is not a prime number.
Try implementing this with a while loop and with a for loop.
2. Write, test and debug a function without parameters called longestOfAll which collects a series of strings from a user and prints out the string that is the longest. If two or more strings are of the longest length the function should print the one that the user typed in first.
3. Write a function findAll that asks the user to type in a character string and a letter to search for, then searches for all instances of the letter specified by the user, and prints the indexes of the positions in which it is to be found and how many times the letter appears in the string
4. Write a function isValidPassword that takes a string, pwd as its single parameter and checks pwd to determine whether or not it is a valid password. The function should return True if pwd is a valid password and False if it is not.
A valid password has the following features
- At least 1 lowercase letter from the range 'a'..'z' and 1 uppercase letter from the range '\( A \)'..'Z'
- At least 1 digit from the range '0'..'9'
- At least 1 character from the set \{'\$','\#','@'\}
- No other characters
- Minimum length 6 characters.
- Maximum length 16 characters.
20 marks
20 marks
30 marks
30 marks
Compile all your codes in 4 separate files and submit the source code files in BlackBoard along with the report.
1 . Write, test and debug a function called

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!