Question

In: Computer Science

Objective: Work with basic input commands. Work with decision making commands. Assignment This will be done...

Objective: Work with basic input commands. Work with decision making commands. Assignment This will be done using Python. Part 1 Create a program that asks the user to input a number between 20 and 99. The program must then print out the number in English words. If the user does not enter a value between 20 and 99 display an error message stating that the input is not within a valid range. No credit will be given for programs that have a separate print statement for each value. Example: Please enter a value: 42 The number is forty two. (running the program again) Please enter a value: 30 The number is thirty. (running the program again) Please enter a value: 10 The number is not within a valid range.

Solutions

Expert Solution

Below is the required program. It is well explained inside the code using comments.

# read number
num = int(input('Please enter a value: '))

# check if number is invalid
# and display the error message
if num < 20 or num > 99:
    print('The number is not within a valid range.')
else:
    # declare list having english words of ones place digits
    onesName = ['','one','two','three','four','five','six','seven','eight','nine']

    # declare list having english words of tens place digits
    tensName = ['','','twenty','thirty','forty','fify','sixty','seventy','eighty','ninety']
  
    # extract both digits
    tens = int(num / 10)
    ones = int(num % 10)

    # get the corresponding words from the list, and print
    print('The number is', tensName[tens], onesName[ones])

Below is the screenshot of the program for indentation:

Below is the sample output:

This completes the requirement. Let me know if you have any questions.

Thanks!


Related Solutions

Basic Unix Commands Objective: The objective of this lab is to work with files of UNIX...
Basic Unix Commands Objective: The objective of this lab is to work with files of UNIX file system. Procedure: 1. OpenyourUnixshellandtrythesecommands: Ø Create a new file and add some text in it vcat > filename Ø View a file vcat /etc/passwd vmore /etc/passwd vmore filename Ø Copy file, making file2 vcp file1 file2 Ø Move/rename file1 as file2 vmv file1 file2 Ø Delete file1 as file2 vrm file //Deletefile //Double-checkfirst vrm -i file Ø Counts the lines, words, characters in...
Objective: The objective of this assignment is to allow students to understand the basic principles of...
Objective: The objective of this assignment is to allow students to understand the basic principles of arrays Program Requirements: The assignment will require the students use arrays to perform mathematical calculations. Program Setup: Functions to include in the program The program will have three functions Function 1: Responsible for setting values in the arrays Function 2: Responsible for printing values in arrays Function 3: Responsible for doing calculations to arrays Function 1 Details: Setting array values Parameters: 3 Array of...
The Six basic steps in decision making: 1-Define the Problem 2- Determine the Objective 3- Explore...
The Six basic steps in decision making: 1-Define the Problem 2- Determine the Objective 3- Explore the Alternatives 4- Predict the Consequences 5- Make a Choice 6- Perform Sensitivity Analysis Write 300 to 400 words on “Determine the Objective.” Describe your own motives and what your short or long term plans are (please explain short term and long term plans separately) after completing your MBA? Knowing you “can’t always get what you want” what can you get? What can you...
The six basic steps in decision making: 1-Define the Problem 2- Determine the Objective 3- Explore...
The six basic steps in decision making: 1-Define the Problem 2- Determine the Objective 3- Explore the Alternatives 4- Predict the Consequences 5- Make a Choice 6- Perform Sensitivity Analysis Write 3 to 4 page analyzing problem at work can be used in the final paper, the purpose of this paper is to utilize Step One of the Six Step Decision Making Model and identify a problem. The First assignment is just an identification of a problem, explain the problem...
What is the primary objective for a service or retail organization when making a location decision?...
What is the primary objective for a service or retail organization when making a location decision? A. Minimize cost B. Maximize revenue C. Minimize customer-drawing area D. Maximize size of the labor pool
This week, you will complete the "Decision Making Dilemma" assignment. This assignment asks you to imagine...
This week, you will complete the "Decision Making Dilemma" assignment. This assignment asks you to imagine that you are a captain of a ship that is sinking. All but one of your passengers can escape on the lifeboat. You and one other passenger will sink with the ship. You have to decide which passenger will die with you on the ship. Note that this decision does not need to be based on the perceived value of a life, but could...
1.What is a good decision?2. What are the basic rules for good decision making?explain...
1. What is a good decision?2. What are the basic rules for good decision making? explain3. What are ways in which information is gathered when making a good decision?4. What are ways in which the information is used once it is gathered?
Decision-making, sustainability, values & ethics 1. How does each of the following models of decision-making work,...
Decision-making, sustainability, values & ethics 1. How does each of the following models of decision-making work, and when should it be used? Management science Carnegie model Incremental model Garbage can model
QUESTION 16 A basic assumption of the bounded rationality model of decision making is ____. A....
QUESTION 16 A basic assumption of the bounded rationality model of decision making is ____. A. decision alternatives can be completely evaluated in terms of their potential value B. decision alternatives can be objectively rank ordered in terms of appropriateness C. preferences for alternatives seldom change as new information is acquired D. people do not evaluate all possible decision alternatives 2 points    QUESTION 17 Transformational leaders are likely to ____. A. have a relatively high tolerance for mistakes made...
When enacting the strategy of ______ nurses are able to have input into the decision-making process...
When enacting the strategy of ______ nurses are able to have input into the decision-making process like equals, but in a way that doctors are unaware of their contributions, thus maintaining the perception of the nurse’s role as subordinates. A. direct forms of communication B. indirect forms of communication C. authority D. hierarchy A concern on social media is A. access. B. privacy. C. the EHR. D. the proliferation of apps. 6.25 points    QUESTION 15 Social networking may be...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT