1. Homepage
  2. Programming
  3. Python Application Development - Assignment 1: Rational Numbers

Python Application Development - Assignment 1: Rational Numbers

Engage in a Conversation
Hong KongThe Hong Kong Polytechnic UniversityPython Application DevelopmentRational NumbersPython

Python Application Development Assignment – 1 Rational Numbers

Practical Work

Using Jupyter Notebook, develop an object-oriented application that will perform calculations on rational numbers. While you are responsible for the application's final design, your application is expected to contain a class called ratNum representing a rational number (a/b), where a and b are both integers. You may assume that b is positive for simplicity, and the application does not need to check this. However, if the value of b is zero, an error message should be displayed to alert the user that it is not allowed. Within the class, you must write public member function(s) to realize one of the following five tasks. The task to do should be determined by the remainder obtained from dividing your team number by 5. For example, if your team number is SEVEN, 7 % 5 = 2, and you should do Task 2) of this assignment. CourseNana.COM

Task:

0) The member function performs the addition with another rational number and returns the result as a rational number. The result need NOT be in its simplest form (e.g., 4/10 need not be expressed as 2/5), but its value of b must be the least common multiple (LCM) of the two rational numbers' denominators. For example, if this rational number has a = 12 and b = 48, the rational number to be added has a = 2 and b = 16, the function should return 12/48 + 2/16 = 12/48 + 6/48 = 18/48, i.e. a rational number of a = 18 and b = 48 because 48 is the LCM of 48 and 16. 1) The member function performs the subtraction with another rational number and returns the result as a rational number. The result need NOT be in its simplest form (e.g., 4/10 need not be expressed as 2/5), but its value of b must be the least common multiple (LCM) of the two rational numbers' denominators. For example, if this rational number has a = 12 and b = 48, the rational number to be subtracted has a = 2 and b = 16, the function should return 12/48 − 2/16 = 12/48 − 6/48 = 6/48, i.e. a rational number of a = 6 and b = 48 because 48 is the LCM of 48 and 16. 2) The member function performs the multiplication with another rational number and returns the result as a rational number. The result has to be in its simplest form, i.e., any common factors between the numerator and the denominator should be canceled out. For example, if this rational number has a = 12 and b = 48, the rational number to be multiplied has a = 2 and b = 16, the function should return 12/48 2/16 = 1/32, i.e. a rational number of a = 1 and b = 32 in its simplest form. 3) The member function performs the division with another rational number and returns the result as a rational number. The result has to be in its simplest form, i.e., any common factors between the numerator and the denominator should be canceled out. For example, if this rational number has a = 12 and b = 48, the rational number to be divided has a = 2 and b = 16, the function should return 12/48 2/16 = 2/1, i.e. a rational number of a = 2 and b = 1 in its simplest form. (Note: the function should display an error message but not do the division if the divisor is zero.) 4) The member function performs the comparison with another rational number. It returns the integer value 0 if the other rational number is the same in value. It returns the integer value −1 if the other rational number is bigger. It returns the integer value 1 if the other rational number is smaller. The comparison must be made by first finding the least common multiple (LCM) of the two rational numbers' denominators. For example, if this rational number has a = 12 and b = 48, the other rational number has a = 2 and b = 16, the function should return 1 as 2/16=6/48, and 6 is smaller than 12, while 48 is the LCM of 48 and 16. CourseNana.COM

References:

https://en.wikipedia.org/wiki/Rational_number CourseNana.COM

It is required that the class and the implementation of its member functions should be built as a separate module to be imported by the application. CourseNana.COM

Your application is expected to provide a text menu as a user interface. Through the interface, the user can repeatedly enter rational numbers (by providing the values of a and b) and do calculations of your task for different rational numbers. The user can also choose to end the application through the interface. Should you want to get a credit grade, you should design the application such that when a user wants to start it, he needs to login with a username first, which will be checked with a file that stores username-password pairs. If the username is new, the application will ask for a password from the user and store it into that file. If the username can be found in that file, the application will ask for a password from the user, and the program will start only when the password is correct. The application will end if the user fails to provide the correct password in three consecutive trials. CourseNana.COM

Should you want to get a distinction grade, you should add a function to the class that can compute a non-zero rational number to the power of n, where n is a positive integer, zero, or negative integer. (If the rational number is zero, the function should show an error message and do nothing.) The result must be a rational number in its simplest form. For example, if the rational number has a=12 and b=48, and n = −2, 12 −2 the function should return a rational number of a=16 and b=1 because ( ) CourseNana.COM

Report

Your report should include: Abstract: Summarise the objectives and achievements of your assignment in less than 100 words. CourseNana.COM

  1. Introduction: Describe the assignment's objectives and requirements in detail and give a brief account of the methodology.
  2. Methodology: It contains
    • how your team divides the work among the team members. It will be used as a reference for assessment.
    • the schedule and steps of developing the project,
    • the detail of the developed application, including
    • the specifications of the classes defined, and the member functions/variables inside - explain as far as possible why your group makes such choices for the class members
    • The flow of execution. (It is good to include a flow chart to help illustration.)
    • what problems your group encounters, and how your group solves the problems,
    • how you validate your application, i.e., confirm that the solution is correct.
  3. Results • Include the results of executing your application captured from the screen.
  4. Conclusion and further development
    • Summarize the experience gained in the assignment
    • Indicate how your application can be extended and improved if more time is allowed.

The report should be in PDF format with your class number, team number, student names, student IDs, and task number on the front page. It is NOT required to include the complete source code in the report. Instead, you should zip the folder(s) containing all your project folders and files (including your report file) into a zipped file for submission. (See the General Description below.) CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
Hong Kong代写,The Hong Kong Polytechnic University代写,Python Application Development代写,Rational Numbers代写,Python代写,Hong Kong代编,The Hong Kong Polytechnic University代编,Python Application Development代编,Rational Numbers代编,Python代编,Hong Kong代考,The Hong Kong Polytechnic University代考,Python Application Development代考,Rational Numbers代考,Python代考,Hong Konghelp,The Hong Kong Polytechnic Universityhelp,Python Application Developmenthelp,Rational Numbershelp,Pythonhelp,Hong Kong作业代写,The Hong Kong Polytechnic University作业代写,Python Application Development作业代写,Rational Numbers作业代写,Python作业代写,Hong Kong编程代写,The Hong Kong Polytechnic University编程代写,Python Application Development编程代写,Rational Numbers编程代写,Python编程代写,Hong Kongprogramming help,The Hong Kong Polytechnic Universityprogramming help,Python Application Developmentprogramming help,Rational Numbersprogramming help,Pythonprogramming help,Hong Kongassignment help,The Hong Kong Polytechnic Universityassignment help,Python Application Developmentassignment help,Rational Numbersassignment help,Pythonassignment help,Hong Kongsolution,The Hong Kong Polytechnic Universitysolution,Python Application Developmentsolution,Rational Numberssolution,Pythonsolution,