Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***** IN PYTHON ***** NEAR PRIME (definition): We call a number near prime if it is divisible by 1, itself and at most 2 other

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

NEAR PRIME (definition): 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" (definition): 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. 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, 4789089 is not an updown number. We consider a number nice if its either an up, a down or an updown number.

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? If you do, a screenshot of correct indenting would be really helpful/needed. I need it as a reference for an exam. Thanks. *****

***** I need to be able to paste a list of numbers seperated by commas and have them ascending sort while also printing their "scores" next to them *****

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

Creating A Database In Filemaker Pro Visual QuickProject Guide

Authors: Steven A. Schwartz

1st Edition

0321321219, 978-0321321213

More Books

Students also viewed these Databases questions

Question

8. Design office space to facilitate interaction between employees.

Answered: 1 week ago