Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

HIT137 Assignment 2, 2023

How to submit this assignment

Your submission should be written in a single PY file.

•    Save the py file using your Group_Number.py.  (for example Group_ 1.py)

•     First line of your file will  be:

o    Student Name Student ID

•     Put  all  the  solutions  in   one   single   PY  file  and  then  you   can   use  the   Case-Switch statement  (the Case-Switch has been done in the "Copy your solutions here.py" file) to allow the user to select which program should run first. I will show you how to use the Case-Switch statement in the coming class. It is easy to use and gives you the flexibility to put your all solutions in one PY file.

•     Clearly label each question and any sub-sections.

•    Provide maximum possible comments so the code becomes easier to read.

•     If your submission is difficult to understand, you will lose marks.

•     Only one of your team members should submit the assignment.

Question 1                   4 Marks

A website requires the users to input username and password to register. Write a program to check the validity of password input by users.

Following are the criteria for checking the password:

•    At least 2 letters between  [a-z]

•    At least 3 numbers between  [0-9]

•    At least 4 letters between  [A-Z]

•    At least 2 characters from  [$#@!&;*()-_^]

•    Maximum length of password:  18

Your program should accept a sequence of comma-separated passwords and will check them according to the above criteria. Passwords that match the criteria are to be printed, each separated by a “|| ” .

Example

If the following passwords are given as input to the program:

aABd12DE34@!1, aFb1#Gg2wL3E6f*, 2We3345

Then, the output of the program should be:

aABd12DE34@!1  || aFb1#Gg2wL3E6f*

Question 2              4 Marks

Shaina wants to add a word encryption technique in the game she has been working. Her friend provided the following information for her to implement.

1.    Only use the capital letters

2.   The input must be a plaintext and a keyword are used to encrypt that text.

3.   The count starts from 0 and ends at 25 for all the capital letters.  (26 alphabets) 4.   The character is shifted by the position of the key character.

Example:

Plaintext = “HELLO”

Keyword = “KEY”

Encrypted text = “RIJVS”

Note: The position of K is  10 and  ‘H’ is shifted by  10 to reach  ‘R’ .

Similarly, the decryption works the opposite of the encryption using the same Key.  Your task is to help Shaina to complete this encryption and decryption, so that she can add it in her game.

Question 3              4 Marks

A self-driving car is training to find its home on its own. It started from an original point (0). The car can only move toward UP, DOWN, LEFT, and RIGHT. Unfortunately, the

car has lost contact with the servers. The server log files show the following route:

UP 5

DOWN 3

LEFT 3

RIGHT 2

The number after the direction is the distance travelled in that direction  (in Kilometres) .

Please write a program that can compute the distance of the car from the original point. If the distance is a float, then just print the nearest integer.

Someone worked on the half-cooked code below. You can use this code or write a new one.

 

Question 4                          8 Marks

 

Sai was writing a python program which reads the file  ‘input_text.txt’ to distinguish

the numbers and alphabets. The program needs to add each individual numbers in the text and sum it to check if the sum is a prime number. Finally, he needs to find

the list of palindrome words from the series of the alphabets. Sai left the company   without notifying. Zhang is trying to fix the code that Sai have written. He asked HIT-

137 Students at CDU to fix his code. Fix the above code and submit it as part of your assignment. You are free to add as many functions as you want and write the fix.

Zhang has provided following information which could be helpful to fix the code above.

•    The input file is  ‘input_text.txt’ .

•   A palindrome is a word, phrase, number, or other sequence of characters

that reads the same forward and backward  (ignoring spaces, punctuation,    and capitalization). In simpler terms, a palindrome remains unchanged when its letters or digits are reversed.

Example, “radar’, “level”, “madam”,  “1221”, “34843” etc.

•    Palindrome words greater than 4 characters needs to be displayed.

In summary:

The program needs to add each individual numbers in the text and sum it to check if the sum is a prime number. Your program should list all the sum which is a prime

number.

Finally, the program needs to find the list of palindrome words  (words >4 characters) from the series of the alphabets discarding all the digits.