- 2nd Jul 2024
- 17:14 pm
In this assignment task, we will revise Python concepts by experimenting with string manipulations and dictionary operations. Our experts will guide you through the process, ensuring you understand each step and how to apply these techniques effectively.
Task 1 – Concept Revision in the Python Shell
Let’s revise the concepts from this module by typing some simple statements into the Python Shell. Feel free to deviate from the workshop and experiment!
- pun = 'Eating a clock is very time consuming!!!'
- pun[23:]
- pun = pun.rstrip('!')
- pun.count('i')
- punWords = pun.lower().split() These statements manipulate a string in various ways.
- scores = {'Mary': [22, 23, 36], 'Fred': [20, 21, 29]} This creates a dictionary with two items. The items have keys of “Mary” and “Fred”, and the values are both lists containing three integers (test scores out of 25, 25 and 50).
- scores['Mary'] 8. scores['Fred'][1]
These statements demonstrate how to refer to an item in a dictionary via its key. Since the value is a list, you can then refer to an item in the list via its index.
Task 2 – Password Checker
Below is a copy of the password rules from ECU’s password changing page:
- A maximum of 16 characters
- A minimum of 8 characters
- A minimum of 1 upper case character
- A minimum of 1 lower case character
- A minimum of 1 number
- A minimum of 1 special character: '~!#$%^*()_+-={}|[]\:<>?,./
Write the code to implement this pseudocode in the “checkPassword()” function.
Strings, Dictionaries and Sets - CSP5110 - Get Assignment Solution
Please note that this is a sample Strings, Dictionaries and Sets - CSP5110 assignment solved by our Python Programmers. These solutions are intended to be used for research and reference purposes only. If you can learn any concepts by going through the reports and code, then our Python Tutors would be very happy.
- Option 1 - To download the complete solution along with Code, Report and screenshots - Please visit our Python Assignment Sample Solution page
- Option 2 - Reach out to our Python Tutors to get online tutoring related to this assignment and get your doubts cleared
- Option 3 - You can check the partial solution for this assignment in this blog below
Free Assignment Solution - Strings, Dictionaries and Sets - CSP5110
Task 1 Solution:
pun = 'Eating a clock is very time consuming!!!'
print(pun[23:])
pun = pun.rstrip('!')
print(pun)
print(pun.count('i'))
punWords = pun.lower().split()
print(punWords)
scores = {'Mary': [22, 23, 36], 'Fred': [20, 21, 29]}
print(scores)
print(scores['Mary'])
print(scores['Fred'][1])
scoreKeys = scores.keys()
print(scoreKeys)
scores['Jane'] = [21, 24, 30]
scores['Fred'][2] = 39
print(scores)
#HDs = [name for name in scores if sum(scores[name]) >= 80]
#print(HDs)
set1 = {4, 2, 6, 3, 6, 2, 7}
set2 = set([9, 1, 0, 2, 4, 1, 4, 6])
print(set1)
print(set2)
print(set1 | set2)
print(set1 & set2)
Task 2 Solution:
def checkPassword(pword):
shortEnough = False
longEnough = False
hasUpper = False
hasLower = False
hasNumber = False
hasSpecial = False
specialChars = '\'~!#$%^*()_+-={}|[]\\:<>?,./'
if len(pword) <= 16:
shortEnough = True
if len(pword) >= 8:
longEnough = True
for i in pword:
if i.isupper():
hasUpper = True
if i.islower():
hasLower = True
if i.isdigit():
hasNumber = True
if i in specialChars:
hasSpecial = True
if shortEnough == True and longEnough == True and hasUpper ==True and hasLower ==True and hasNumber == True and hasSpecial==True:
return True
return False
password = input('Enter your password: ')
if checkPassword(password):
print('Your password is valid.')
else:
print('Your password is not valid.')
Get the best Strings, Dictionaries and Sets - CSP5110 assignment help and tutoring services from our experts now!
About The Author - John Smith
John Smith is a seasoned Python developer with over a decade of experience in software development and teaching programming concepts. He specializes in Python scripting and data manipulation, focusing on practical applications and problem-solving techniques. John has a passion for making complex topics accessible and enjoyable for learners at all levels.