Question: please explain. Python only , user defined modules are not allowed A programmer's wife tells him, While you're at the grocery store, buy some eggs.

please explain. Python only , user defined modules are not allowed

please explain. Python only , user defined modules are not allowed Aprogrammer's wife tells him, "While you're at the grocery store, buy some

A programmer's wife tells him, "While you're at the grocery store, buy some eggs." He never comes back. (:) (-) (-) Now, imagine a situation in which such a programmer does shopping in a grocery owned by a nerdy! Things can even get more complicated, right? Joking aside, in this part of the assignment, you as a programmer are supposed to help a nerdy owner of a grocery by writing a program called NerdyGrocery as follows. The grocery store owner designed a very strange pricing regulation for their products, in which the price of a product only depends on its weight. - If the weight of a product is a prime number, the price of the product is equal to the number of prime numbers less than the weight of the product. For example, if the weight of a product is 7 , the price would be $3, because there are three prime numbers less than 7 , which are 2,3,5. - If the weight of a product is not a prime number, the price is equal to the number of prime divisors of the weight. For example, if the weight of a product is 6 , the price would be $2, because 6 has two prime divisors, which are 2 and 3 . Moreover, the grocery offers a discount based on the total price of a customer's shopping: - If the total price of shopping is a prime number, the grocery offers a discount equal to the number of prime numbers less than the total price. - If the total price of shopping is not a prime number, the grocery offers a discount equal to the number of prime divisors of the total price. NerdyGrocery helps the grocery and its customers to facilitate the payment process as follows: - NerdyGrocery first, receives the number of products in the customer's shopping basket. Let's call this number n. NerdyGrocery assumes the user only enters positive integers (greater than 0 ). - Subsequently, NerdyGrocery receives the weight of each product in n separate lines. NerdyGrocery assumes the user only enters positive integers (greater than 0 ). - NerdyGrocery calculates the total price of the customer's shopping considering the above-mentioned regulation and after applying the corresponding discount. Two examples are shown in table 4 . In example 1 , the customer had 5 products in their basket. The weight of the first product is one. 1 is not a prime number and doesn't have any prime divisors, so its price is $0. The weight of the next product is 7 , and as explained earlier, its cost is $3. The next product weighs 6 , and it costs $2, as explained above. The next item's weight is 12 , which is not a prime number. The number of prime divisors of 12 is 2 , so its price is $2. Finally, the last product weight is 2 , and it is a prime number. There isn't any prime number less than 2 , so it costs $0. Therefore, the total price is $7. Since the total price is a prime number, the total discount is equal to the number of prime numbers less than 7 , which is 3 . Consequently, the total price after applying the discount will be $7$3=$4 as printed in the last line as the expected output of NerdyGrocery for this example. You are not allowed to use any user-defined modules in developing NerdyGrocery. The same logic is applied to the inputs provided in example 2. Note that your program input and output format should be exactly the same as the format of the examples shown in Table 4. Table 4: The NerdyGrocery Sample Inputs and Outputs

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!