Question: Create a module and name it Lastname_Firstname_hw1.py. In the module, add the following functions: 1. Write a function named problem1 that accepts a list

Create a module and name it Lastname_Firstname_hw1.py. In the module, add the following functions: 1. Write a   5. Write a function named problem5 that accepts a string and a positive integer k. Find and return a list Call the function with the test case and display the result. Test case: if the two strings are 'dagc' and   first. Implement the following special methods so that student objects should be able to be compared by their

Create a module and name it Lastname_Firstname_hw1.py. In the module, add the following functions: 1. Write a function named problem1 that accepts a list of integers as the argument. Then your function should remove all the odd numbers from the list and sort the remaining non-odd numbers in descending order. Return the list. Call the function and display the return result. Test your function with the test case: if the input list is [1, 6, 4, 3, 7, 2, 5], then your function should return [6, 4, 2] (10 pts) 2. Write a function named problem2 that accepts a string. Assume the string contains a lot of numbers that are separated by commas. Remove all the duplicates from the list, then calculate and return the sum of remaining elements. Call the function and display the return result. Test your function with this test case: if input string is "1,2,3,3,4,4,5", then your method should return 15. (10 pts) 3. Write a function named problem3 that prompts the user for a sequence of integers and appends them to a list. Each integer can appear only once in the list. You need to ask the user to re-enter a different integer if the entered integer already exists in the list. Calculate and return the sum of the list. Call the function and display the return result. You may test it with the test case: if input sequence 1, 2,3, 4, 5, then your function should return 15. (10 pts) 4. Write a function named problem4 that accepts a string as the argument. Find and return the most frequent digit. You cannot use the collections module to solve this problem. Call the function with the test case and display the return result. Test case: if the given string is 'abc123 cda 345cc3456', your function should return 3 (only digits are considered). (10 pts) Acti Go to 5. Write a function named problem5 that accepts a string and a positive integer k. Find and return a list with any k distinct characters. If k is greater than the length of the given string, return all the distinct characters. You cannot use the collections module to solve this problem. Call the function with the test case and display the return result. Test case: if the given string is 'aaabbbcccdddeeefffggg' and k = 5, your function should return any five distinct characters, e.g., ['a', 'b', 'c', 'd', 'e']. (10 pts) 6. Write a function named problem6 that accepts a string and a tag as the arguments. Assume this string contains a sequence of words that are separated by spaces. Add the tag around each word. Call the function with the test case and display the return result. Test case: if the given string is 'hello world python break' and the tag is '#', your function should return '#hello# #world# #python# #break#'. (10 pts) 7. Write a function named problem7 to merge two strings. This function should accept two strings as the arguments. Assume both strings contain lower case letters only. Merge the two strings and order the letters alphabetically, then return the result. Call the function with the test case and display the result. Test case: if the two strings are 'dagc' and 'fbhe', your function should return 'abcdefgh'. (10 pts) 8. Create a class named Student. The Student class should have a static variable, numStudent, and five instance variables. (30 pts) Write the following variables: Static variable Instance variables name: the student's full name, string, e.g., "John Doe", must be specified when instantiated. id: the student's id, string, created based on num_student, e.g., the first student object's id should be "1", the second student object's id should be "2". major: the student's major, string, its default value is "Undeclared", can also be specified when instantiated. gpa: the student's current gpa, float, initial value = 0.0. username: string, each student is assigned an automatically generated username following the rules below: Get the first letter of the student's first name. Get the first five letters of the student's last name. If student's last name is less than the required number of letters in length, then use the entire name. Get the student's id. I num_student: the number of the student objects that have been created, static, int, initial value = 0. I I Concatenate the three sets of letters then convert to lower case to generate the login name. Write a method called create_password() to create the password for the student. password: string, the default password is "ABC123abc!", each student can create their own password by following the rules below: A password must Be at least 8 characters long. I Contain at least one uppercase letter and at least one lower case letter. Contain at least one number. Contain at least one special symbol: ! @ # % &. Write a static method called verify_password(password) to verify if the given password is valid. Return True if yes, return False otherwise. The user must re-enter a different password if the specified password is not valid. Write the additional methods: get_name() get_id() get_major() get_gpa() I get_username() Page 2 of 3 first. Implement the following special methods so that student objects should be able to be compared by their gpa. I I I get_password() set_name(name): update a student's name set_major(major): update a student's major set_password(password): update a student's password. The new password needs to be verified I _It____(self, other) _le__(self, other) _eq___(self, other) _ne___(self, other) _ge_(self, other) _gt__(self, other) To get called on comparison using < operator. To get called on comparison using = operator. To get called on comparison using > operator. Test cases: student1 = Student ("John Doe", "Computer Science", "Password1%") ## id is 1, username is jdoe1, password is Password1% student2 = Student("Emily Johnson", "Cybersecurity") ## id is 2, username is ejohns2, password is "ABC123abc!" print(student1 student2, student1 > student2, student1

Step by Step Solution

3.34 Rating (145 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

It looks like you want to create a Python module with specific functions Here is an example of how y... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!