Professional Documents
Culture Documents
Data Analysis and Visualisation
Data Analysis and Visualisation
Assignment 02
General Instruction:
1. Write a detailed logic/algorithm for solving each of the questions on A4 sheets.
2. Use unruled A4 sheets, and don’t use the ruled papers from notebooks.
3. The source code of all the programs should be submitted as py files with names
Q1.py, Q2.py, etc for quick reference. Put all files in a folder and submit them as a
single zip file.
4. Scan the A4 sheets and submit them as a PDF file, and handover the hardcopy.
5. Do not plagiarise or copy the source code from the internet or from others.
6. Stick to the assignment deadlines. Total: 35 Marks
Q1. Generate a list of positive integers within a specific range of values. Find the numbers from this
list which are divisible by 7 and 8 and store them in a separate list using List Comprehension. Print
the new list which contains the numbers divisible by 7 and 8.
[5 Marks]
Q2. Write a program to insert a given string before every number present in a list using List
Comprehension. Assume the list and string is hardcoded into the program.
Q3. Read an integer from the user and check whether the number is a palindrome. Write both
iterative and recursive versions to solve this problem.
[5 Marks]
Q4. Read a string and check if the first character is occurring more than once in the string. If yes,
replace the occurrence by ‘$’ from the second instance.
1. If the password entered does not satisfy the above conditions, then throw out the
appropriate message.
2. If the password entered contains four occurrences of conditions a) to d), then print that the
password strength is strong.
3. If the password entered contains two or three occurrences of conditions a) to d), then print
that the password strength is medium.
4. If the password entered contains only one occurrence of d), then print that the password
strength is poor.
[15 Marks]
Note:
● Refer to the documentation for string methods and use relevant methods in your programs
which require string operations.
● Here is the recommended reference:
https://python-reference.readthedocs.io/en/latest/docs/str/
● You can also use other references.