Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***** IN PYTHON ***** You will be given a list of numbers. Each number is assigned a score. Its score is determined as follows: A

***** IN PYTHON *****

You will be given a list of numbers. Each number is assigned a score. Its score is determined as follows:

A numbers base score is the value of the number itself. If the number is a palindrome it scores is doubled. If the number is a near prime its score is doubled. If the number is a nice number its score is tripled.

Consider how to determine the score of a number 89. It is not a palindrome and but it is nice and near prime:

Base score: 89 Score after palindrome check: 89 (remains same as not a palindrome) Score after near prime check: 188 (doubled as 89 is near prime) Score after nice check: 534 (tripled as 89 is nice)

Consider the number 101:

It is a palindrome, it is prime but it is not a nice number: Base score: 101 Score after palindrome check: 202 (doubled as its a palindrome) Score after near prime check: 404 (doubled as 101 a near prime) Score after nice check: 404 (not tripled as 101 is not nice)

Given a list of numbers entered by the user output the list of numbers in sorted order (ascending) of their scores. Also include the score achieved with each number separated by a comma after the number. For example if the user enters 89 101 You have to output 101,404 89, 534

***** Does anyone have a working code for this? I need it as a reference for an exam. Thanks. *****

NEAR PRIME: We call a number near prime if it is divisible by 1, itself and at most 2 other numbers. To illustrate: 49 is near prime as only 1,7 and 49 divide it.

"NICE": We call a number an up number if the digits of the number increase (or stay the same) as we read the number. To illustrate: 123 is an up number Similarly, in a down number the digits of the number decrease (or stay the same). To illustrate 321 is a down number 775. Finally combining the two we define an updown number. In an updown number the digits initially increase (or stay the same) and then they decrease (or stay the same). Once they have started to decrease they can not increase again. To illustrate 123431 is an updown number 4577852 is an updown number 123758 is not an updown number (because it the digits increased and then decreased but then increased again) 4789089 is not an updown number. We consider a number nice if its either an up, a down or an updown number.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

Students also viewed these Databases questions

Question

What is dividend payout ratio ?

Answered: 1 week ago

Question

Explain the factors affecting dividend policy in detail.

Answered: 1 week ago

Question

6. The cost of the training creates a need to show that it works.

Answered: 1 week ago