Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part B For this part, use the updated ( no syntax errors ) Python functions from Part A , and at the bottom ( where

Part B
For this part, use the updated (no syntax errors) Python functions from Part A, and at the bottom
(where it says Start your script here), generate a Python script that will:
Ask the user to enter a whole number N.
Call the Python functions from Part A to identify and record into a single list, all numbers
n (1<= n <= N) that are perfect, narcissistic, or happy using a repetition structure (for or while
loop) and Pythons append built-in function
For each number in the list, create a different list that identifies the type of number found,
i.e. if the number if happy (h), or narcissistic (n), or perfect (p), or a combination of two or
more types (hn, hp, pn or hnp).
Output to the Python Shell (using a print statement) the list of numbers found, and the
corresponding list of number types in the format shown below. One way to do this format
is to add another loop that goes through and prints the first entry in the numbers found list
and the number type list, and continues to the second entry, third entry, etc., such that each
number is matched with its number type.
Test case:
enter a large whole number N 10
1 is hn
2 is n
3 is n
4 is n
5 is n
6 is np
7 is hn
8 is n
9 is n
10 is h
Files to be submitted on your Canvas Section Site
HW2p1_Task1_UCusername.py
HW2p1_Task2_UCusername.py

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

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions