Professional Documents
Culture Documents
A1 Python Basics
A1 Python Basics
You are a cyber security manager, and your task is to identify if the
password entered by the user is strong or not. The basic rule to check
the password strength is it should have at least 8 characters, and
contain at least one each of uppercase letters, lowercase letters, digits,
and special characters (any character that is not a letter or digit).
Write a function checkpass(password) that takes a string argument
password and return True if it fits the criteria for a strong password
and False if not.
(a) Example 1:
• Argument: '12345678'
• Returns: False
(b) Example 2:
• Argument: 'Hello@123'
• Returns: True
(a) Example 1
• Argument: 'P P A A A P A P A A'
• Returns: ('suspended', 0.4)
(b) Example 2
• Argument: 'P P P A P P A P A P'
• Returns: ('not suspended', 0.7)
2
3. Ankit is always fascinated by the number 2. He always wants to know
who came second in a race, the second person to set foot on the moon
and so on. If Ankit is provided with a list of numbers and asked
to find the maximum, he reports the second highest number as the
maximum because according to him, 2 is higher than 1. Let us con-
sider Ankit becoming the instructor of a data science course. Write
a function ankit_max(marks_dict) for that returns the name of the
highest scorer in his class according to Ankit. It should take a dict of
the form {Name1: marks1, Name2: marks2, ...}, where the keys
Name1, Name2, ... identify students, and marks1, marks2, ...
are their respective marks as numbers. If there is no second high-
est, the function should return None.
(a) Example 1
• Argument: {'Alok': 10, 'Bikash': 24, 'Chandan': 26,
'Dali': 28, 'Eli': 30}
• Returns: 'Dali'
(b) Example 2
• Argument: {'Xavier': 25, 'Ibrahim': 25, 'Yatin': 25,
'Sami': 25, 'Takahashi': 25}
• Returns: None
(a) Example 1
• Argument: 123
• Returns: True
(b) Example 2
• Argument: 124
• Returns: False
(a) Example 1
3
• Argument: 'poonam'
• Returns: 'ponam'
(b) Example 2
• Argument: 'suruuuuuuuuuuuuuuuuuuuuuuuur'
• Returns: 'surur'
(c) Example 3
• Argument: 'blahblahblah'
• Returns: 'blahblahblah
6. Now ask a large language model (LLM, like ChatGPT, BARD, etc.)
for solution to each of these problems. At the bottom of your script file,
write a multiline docstring comparing its result with yours. Mention
which LLM you used.
Example:
"""
I queried ChatGPT for solution to these problems.
Problem 1:
...
...