Background: In numerical number theory, the Armstrong number definition is the number in any given number...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Background: In numerical number theory, the Armstrong number definition is the number in any given number base, which forms the total of the same number, when each of its digits is raised to the power of the number of digits in the number. If the number obtained totals to or equals the original number when each of the digits is raised to the power of the number of digits in the number and added to obtain a number, in any given number system, such a number is called an Armstrong number. Assignment #2 - Armstrong Number Using a simple number 153 and the decimal system, we see there are 3 digits in it. If we do a simple mathematical operation of raising each of its digits to the power of 3, and then totalling the sum obtained, we get 153. To understand the logic of Armstrong nos, one needs to remember that the Armstrong number property is true in any number system. Objectives: This assignment will assess your mastery of the following objectives: Write conditionals, loops, variables, keyboard input, and console output. Write functions to provide structure to the code and eliminate redundancy. Write and call functions to manage the flow of control in a program. Apply skills to systematically test and debug applications. 0 Follow prescribed conventions for spacing, indentation, naming methods, and header comments. Rules and Explanations: Method n AA2A3 ... A = A = A + a + a + + A t=0 Create a python file name armstrong.py that includes that includes the methods as following: print_menu() is_armstrong_number(number) main() Description The method prints the menu of operations to the console. (part 2) The method accepts one parameter as an integer and return if the number is an armstrong number, otherwise false. (part 1) The method runs the application. (part 2) 1. The first part is to write a function (is_armstrong_number) that accepts a parameter which is an integer. The function will return true if the given number is an armstrong number, otherwise false. Here is a list of examples: is_armstrong_number is_armstrong_number (-1) = False (0) = True is_armstrong_number (1) = True is_armstrong_number (2) = True is_armstrong_number (3) = True is_armstrong_number is_armstrong_number is_armstrong_number is (4) = True (5) = True (6) = True is_armstrong_number (7) = True is_armstrong_number (8) = True is_armstrong_number (9) = True is_armstrong_number (10) = False (135) = False (153) = True (370) = True is_armstrong_number is_armstrong_number s_armstrong_number is_armstrong_number is_armstrong_number is_armstrong_number (8208) = True is_armstrong_number (9474) = True (371) = True (372) = False 2. The second part is to write a text-base program to print out a menu of operations. The program prompts user to enter an option to operate: Option 0: to exit the program (do not forget to give a thank you message) Option 1: to check if the input number is an armstrong number Option 2: to list all armstrong number from a given range Here is an example of the output: (Your output must be exact same as expected output below such number of spaces, lower/upper cases, new line, etc.) -> 0. Exit -> 1. Armstrong Number Checker ->2. Armstrong Number List Please enter your option: -1 Could not perform option -1 -> 0. Exit -> 1. Armstrong Number Checker ->2. Armstrong Number List Please enter your option: 3 Could not perform option 3 -> 0. Exit -> 1. Armstrong Number Checker ->2. Armstrong Number List Please enter your option: 1 Please enter a number: 372 372 is NOT an armstrong number -> 0. Exit -> 1. Armstrong Number Checker -> 2. Armstrong Number List Please enter your option: 1 Please enter a number: 371 371 is an armstrong number ***** -> 0. Exit -> 1. Armstrong Number Checker ->2. Armstrong Number List Please enter your option: 2 Please enter the lower bound: 153 Please enter the upper bound: 8208 List of armstrong numbers from 153 to 8208: 153 370 371 407 1634 8208 **** -> 0. Exit -> 1. Armstrong Number Checker ->2. Armstrong Number List Please enter your option: 2 Please enter the lower bound: 8208 Please enter the upper bound: 153 List of armstrong numbers from 8208 to 153: -> 0. Exit -> 1. Armstrong Number Checker -> 2. Armstrong Number List Please enter your option: 0 Thank you for using the program Extra Credit: (0.5% TGS or 0.1 LGS to the final grade) Extra credit is only considered if the assignment submit (and complete) on-time according to original due date on syllabus. The due date is extended will not count. 1. Ensure the number entered by the user is an integer. Anything that is not an integer (string or float) should generate an error message and you should re-prompt for input continually until integer input in the proper range is entered. 2. Indicate the time complexity (Big O) of the solution is_armstrong_number(number). The answer must be clearly justified. Implementation Guidelines: The program does not compile will receive grade of zero. Place your code in a file named armstrong.py. (Please do not print anything from this file - use armstrong_main.py to test your program) Each function should do the following 1. For the is_armstrong_number function: a. Count the number of digits of the given number. b. Take off each digit of the number from the right to the left (let's call it current digit) c. Calculate the exponent value of the current digit to the i-th power, where i is the length of given number. d. Add the exponent value to the accumulator variable (sum) e. Return true if the number is equal to the exponent sum value, otherwise false. 2. For the print_menu function: a. Simply print the information of operations to the console exact same as expected output. 3. For the main function: class: a. Run the program in a loop. The program will not stop until the option 0 is selected. Be sure your code follows the naming and coding conventions for the class: 1. Replace first name, last name, and school email in the header of the class. 2. Each static method should have comments (they usually call Javadoc). 3. You will lose points for each of these things on every assignment if you do not adhere to the rules. 4. See this document for specifics (as well as an example): https://peps.python.org/pep-0008/ Background: In numerical number theory, the Armstrong number definition is the number in any given number base, which forms the total of the same number, when each of its digits is raised to the power of the number of digits in the number. If the number obtained totals to or equals the original number when each of the digits is raised to the power of the number of digits in the number and added to obtain a number, in any given number system, such a number is called an Armstrong number. Assignment #2 - Armstrong Number Using a simple number 153 and the decimal system, we see there are 3 digits in it. If we do a simple mathematical operation of raising each of its digits to the power of 3, and then totalling the sum obtained, we get 153. To understand the logic of Armstrong nos, one needs to remember that the Armstrong number property is true in any number system. Objectives: This assignment will assess your mastery of the following objectives: Write conditionals, loops, variables, keyboard input, and console output. Write functions to provide structure to the code and eliminate redundancy. Write and call functions to manage the flow of control in a program. Apply skills to systematically test and debug applications. 0 Follow prescribed conventions for spacing, indentation, naming methods, and header comments. Rules and Explanations: Method n AA2A3 ... A = A = A + a + a + + A t=0 Create a python file name armstrong.py that includes that includes the methods as following: print_menu() is_armstrong_number(number) main() Description The method prints the menu of operations to the console. (part 2) The method accepts one parameter as an integer and return if the number is an armstrong number, otherwise false. (part 1) The method runs the application. (part 2) 1. The first part is to write a function (is_armstrong_number) that accepts a parameter which is an integer. The function will return true if the given number is an armstrong number, otherwise false. Here is a list of examples: is_armstrong_number is_armstrong_number (-1) = False (0) = True is_armstrong_number (1) = True is_armstrong_number (2) = True is_armstrong_number (3) = True is_armstrong_number is_armstrong_number is_armstrong_number is (4) = True (5) = True (6) = True is_armstrong_number (7) = True is_armstrong_number (8) = True is_armstrong_number (9) = True is_armstrong_number (10) = False (135) = False (153) = True (370) = True is_armstrong_number is_armstrong_number s_armstrong_number is_armstrong_number is_armstrong_number is_armstrong_number (8208) = True is_armstrong_number (9474) = True (371) = True (372) = False 2. The second part is to write a text-base program to print out a menu of operations. The program prompts user to enter an option to operate: Option 0: to exit the program (do not forget to give a thank you message) Option 1: to check if the input number is an armstrong number Option 2: to list all armstrong number from a given range Here is an example of the output: (Your output must be exact same as expected output below such number of spaces, lower/upper cases, new line, etc.) -> 0. Exit -> 1. Armstrong Number Checker ->2. Armstrong Number List Please enter your option: -1 Could not perform option -1 -> 0. Exit -> 1. Armstrong Number Checker ->2. Armstrong Number List Please enter your option: 3 Could not perform option 3 -> 0. Exit -> 1. Armstrong Number Checker ->2. Armstrong Number List Please enter your option: 1 Please enter a number: 372 372 is NOT an armstrong number -> 0. Exit -> 1. Armstrong Number Checker -> 2. Armstrong Number List Please enter your option: 1 Please enter a number: 371 371 is an armstrong number ***** -> 0. Exit -> 1. Armstrong Number Checker ->2. Armstrong Number List Please enter your option: 2 Please enter the lower bound: 153 Please enter the upper bound: 8208 List of armstrong numbers from 153 to 8208: 153 370 371 407 1634 8208 **** -> 0. Exit -> 1. Armstrong Number Checker ->2. Armstrong Number List Please enter your option: 2 Please enter the lower bound: 8208 Please enter the upper bound: 153 List of armstrong numbers from 8208 to 153: -> 0. Exit -> 1. Armstrong Number Checker -> 2. Armstrong Number List Please enter your option: 0 Thank you for using the program Extra Credit: (0.5% TGS or 0.1 LGS to the final grade) Extra credit is only considered if the assignment submit (and complete) on-time according to original due date on syllabus. The due date is extended will not count. 1. Ensure the number entered by the user is an integer. Anything that is not an integer (string or float) should generate an error message and you should re-prompt for input continually until integer input in the proper range is entered. 2. Indicate the time complexity (Big O) of the solution is_armstrong_number(number). The answer must be clearly justified. Implementation Guidelines: The program does not compile will receive grade of zero. Place your code in a file named armstrong.py. (Please do not print anything from this file - use armstrong_main.py to test your program) Each function should do the following 1. For the is_armstrong_number function: a. Count the number of digits of the given number. b. Take off each digit of the number from the right to the left (let's call it current digit) c. Calculate the exponent value of the current digit to the i-th power, where i is the length of given number. d. Add the exponent value to the accumulator variable (sum) e. Return true if the number is equal to the exponent sum value, otherwise false. 2. For the print_menu function: a. Simply print the information of operations to the console exact same as expected output. 3. For the main function: class: a. Run the program in a loop. The program will not stop until the option 0 is selected. Be sure your code follows the naming and coding conventions for the class: 1. Replace first name, last name, and school email in the header of the class. 2. Each static method should have comments (they usually call Javadoc). 3. You will lose points for each of these things on every assignment if you do not adhere to the rules. 4. See this document for specifics (as well as an example): https://peps.python.org/pep-0008/
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
Compose a detailed paper on the Emotions of employees and its impact on the organization
-
From a consumer point of view, what are some of the downsides to the developments in Big Data?
-
Fill in the blanks with an appropriate word, phrase, or symbol(s). The system of numeration that we presently use is the _______ system.
-
Describe briefly the 'stocksheet system' which may be used for a client's stocktaking.
-
Crandell Industries has gathered the following information about the actual sales revenues and expenses for its pharmaceuticals segment for the most recent year. Sales $ 1,436,400 Variable Cost of...
-
5 points eBook Print References PEM, Incorporated, is experiencing financial difficulty due to erratic sales of its only product, a high-capacity battery for laptop computers. The company's...
-
Using data from NHANES, we looked at the pulse rate for nearly 800 people to see whether it is plausible that men and women have the same population mean. NHANES data are random and independent....
-
The following are some accounting items from ABC, Inc. (in Smillions) Administration expenses $300 Depreciation expenses = 100 Interest expenses = 150 Cost of goods sold - 200 Sales=1,200 Corporate...
-
Discuss the five Rules of Sale of Goods Act with examples. It should not be copy and paste. it should be in own words. Discuss acoording to canadian law.
-
6. Advances to Contractors (P105,000) AR Account Code Advances to Contractors 19902010 Cash MDS, Regular 10104040 P105,000 15% mobilization fees to contractors to be recouped from progress billings....
-
What is the public policy for negligence? If someone does not intentionally cause damage or harm to another, why should they still be held liable under negligence?
-
What is the process and procedures that should happen for a nonprofit 501c3 board member meeting in NJ? Meaning, how often should the members meet, who are the members, and what do they discuss...
-
Samuel has a longstanding interest in cryptocurrency. Can the company raise funds via bitcoins?
-
Amold and Betty have identical marginal benefit formulas for a public good. The MBs are given by: MB, = a(Y, +q,)- BQ* MB, = a(Y, +q.)- BQ* where, Q* = 9,+9, a and are constant positive numbers, a...
-
Draw the major product for each of the following reactions: (a) (b) (c) 1) 9-BBN 2) H2O2, NaOH 1) Disiamylborane 2) H20, NaOH
-
Ken (age 31) and Amy (age 28) Booth have brought you the following information regarding their income, expenses, and withholding for the year. They are unsure which of these items must be used to...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-4. Ivan and Irene paid the following in 2012 (all by check or can otherwise be...
-
Matthew borrows $250,000 to invest in bonds. During 2012, his interest on the loan is $30,000. Matthew's interest income from the bonds is $10,000. This is Matthew's only investment income. a....
-
Isothermal compression efficiency can be achieved by running the compressor: (a) At a very high speed (b) At a very slow speed (c) At an average speed (d) At zero speed
-
Derive the expression of work done by the compressor in isothermal compression, adiabatic compression, and polytropic compression.
-
Maximum work is done in compressing air when the compression is: (a) Isothermal compression (b) Adiabatic compression (c) Polytropic compression (d) None of these
Study smarter with the SolutionInn App