程序代写代做代考 game Module Title:

Module Title:
Release Date & Time: Deadline:
Notes to Candidates:
Introduction to Computer Programming 06 Dec 2020 (Sun), 9:00 a.m.
11 Dec 2020 (Fri), 9:00 a.m.
1. This is a take-home assignment.
2. Students are required to work independently.
3. This paper consists of 2 sections. Section A is an individual project and Section B
contains two questions.
4. Submit your files to the corresponding submission box in the Moodle system. Submit
your files of section A to submission box named “Section A” and submit your files of section B to submission box named “Section B”.
Student Name
Programme
Student ID No.
Year
of Study
-1-

SECTION A (70 marks)
Please design an application based on the requirements below. This application can be a map, game or any other systems. Simply putting uncorrelated codes for each requirement together will get 0 marks.
Requirements
Descriptions
Marks
1: Can interact with users.
Ask user to input something and give some output to the user.
5
2: Must contain a nested conditional execution.
if condition1:
if condition2:
6
3: Must contain function definition.
def func(parameters): return **
6
4: Must use two loops, one for loop and one for while loop.
while condition: for * in list:
6
5: Must contain two data types from list, tuple and dictionary.
6
6: Must contain class definition. There are at least two methods in the class.
class myclass:
def method1():
def method2()
12
7: Must use file to store and retrieve data.
file.open() file.read() file.write() file.close()
4
8: Please write a report to explain your program.
8.1 Brief introduction of your application
8.2 Requirement analysis
8.3 System design
8.4 Execution
8.5 Discussion and conclusion
25
70
Submission:
What you should submit: 1. A written report
⚫ The report must be written in English.
⚫ You should use your class and your student ID (e.g. L01_s000000.doc) as the
-2-

filename.
⚫ The report must include the following sections:
(i). Requirement Analysis: Analyze the basic rules and show the major cases from the above descriptions.
(ii). System Design: Illustrate your system design (for requirements 1-7 (e.g., which lines for which requirement)), including:
(1). Major variables and data type
(2). Majorfunctions
(3). Theinvocationoffunctions
(4). Major classes
(5). Major operations (Loop, Conditional execution, Regular Expression)
(iii). Execution: Demonstrate your program. Illustrate the execution process and conclude the functions of your system.
(iv). Discussion and Conclusion: Is there any extension or advanced function you can implement in the future?
⚫ The written report must follow the format requirements below:
2. Program files (Source codes and data files)
END OF SECTION A
Paper Size
A4 size
Margin
1 inch each side
Line Spacing
Single
Font and Size
Times New Roman, 12 points
Maximum Length
10 pages
-3-

SECTION B (30 marks)
This section consists of 2 questions. Answer ALL questions.
Submission:
You are required to submit python files.
 Note that you should use your student ID and question number (e.g. s000000_1.py for question 1) as the file name of each question.
Question 1 (15 marks)
Write a Python program to sort a list of non-empty tuples, in order by the following 4 criteria successively. You can define a function which has a parameter (a list of tuples) and then call it or you can just write the codes in the main program.
Sample list: [(2, 6, 4, 5), (1, 7), (4, 3, 4), (2, 3, 8, 1), (4,)]
Criteria 1 Criteria 2 Criteria 3 Criteria 4
: sorted in descending order by the last element in each tuple.
: sorted in ascending order by the largest element in each tuple.
: sorted in ascending order by the average of elements in each tuple.
: sorted in descending order by the standard deviation of elements in each tuple.
The output should be:
Sorted in descending order by the last element: [(1, 7), (2, 6, 4, 5), (4, 3, 4), (4,), (2, 3, 8, 1)]
Sorted in ascending order by the largest element: [(4, 3, 4), (4,), (2, 6, 4, 5), (1, 7), (2, 3, 8, 1)] Sorted in ascending order by the average of elements: [(2, 3, 8, 1), (4, 3, 4), (4,), (1, 7), (2, 6, 4, 5)] Sorted in descending order by the standard deviation of elements: [(1, 7), (2, 3, 8, 1), (2, 6, 4, 5), (4, 3, 4), (4,)]
Hints: standard deviation = ( 𝑖=1
𝑙𝑒𝑛(𝑡𝑢𝑝𝑙𝑒)
)
∑𝑙𝑒𝑛(𝑡𝑢𝑝𝑙𝑒)(𝑡𝑢𝑝𝑙𝑒[𝑖]−𝑎𝑣𝑒𝑟𝑎𝑔𝑒)2 1/2
-4-

Question 2 (15 marks)
Write a Python program to help a website to impose certain rules on the complexity of username and passwords.
Requirements:
1. Ask user to input the username until the username starts with an uppercase letter and
all followed letters are in lowercase. If the username cannot fulfil the rule, display
“Invalid username”
2. Ask user to input the password.
3. Define the following 3 rules.
Rule 1: contains one upper case letter and one lower case letter. Rule 2: contains at least 2 digits.
Rule 3: contains one special character which is not a letter or a digit.
4. A password is valid only when it can fulfill at least two rules. Check whether the password fulfills the rules. If the password fulfills 1 or fewer rule, display “Invalid password” and ask user to input another password until the user inputs a valid password. If the password fulfils 2 rules, display “Valid but weak password”. Otherwise, display “Strong password”.
5. The sample output is: Sample output 1:
Please input your
Invalid username
Please input your
Invalid username
Please input your
Please input your
Invalid password
Please input your
Invalid password
Please input your
Invalid password
Please input your
Valid but weak password
username:yLyu username:LyuLu
username:Lyu password:Hk
password:H12 password:H1@ password:Hk1@
Sample output 2:
Please input your username:Lyu Please input your password:Hk12@ Strong password
-5-

END OF SECTION B END OF PAPER
-6-