Write Code Questions 20. Write code that reads in 3 words one at a time, then...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write Code Questions 20. Write code that reads in 3 words one at a time, then creates a list containing all 3 words. 21. Write a program that reads in an integer from the user and then outputs whether that value is odd or even. 22. Rewrite the following code fragment without a nested if-else statement. The new code should not have a nested if statement, but should only include one if-else statement using logical and relational operators. Your new code should be shorter, clearer, and easier to read but functionally perform the same as the original code. 1a #some value 2 b #some value 3 4 if a 0: print ("Error, both a and b must be non-negative") 6 else: 34567890 10 if b < 0: print ("Error, both a and b must be non-negative") else: print("Please proceed.") 23. Write a program that takes 3 floating point values from the user and creates a list. After the list creation, this program should then ask the user whether they wish to add or delete a value. Based on the response from the user, implement the appropriate code to add or delete a specific value provided by the user. Finally before the program terminates, output the list to the user. 24. Write a program that takes 3 floating point values from the user. Without creating a list or otherwise grouped data type, output the 3 values in descending order. Write Code Questions 20. Write code that reads in 3 words one at a time, then creates a list containing all 3 words. 21. Write a program that reads in an integer from the user and then outputs whether that value is odd or even. 22. Rewrite the following code fragment without a nested if-else statement. The new code should not have a nested if statement, but should only include one if-else statement using logical and relational operators. Your new code should be shorter, clearer, and easier to read but functionally perform the same as the original code. 1a #some value 2 b #some value 3 4 if a 0: print ("Error, both a and b must be non-negative") 6 else: 34567890 10 if b < 0: print ("Error, both a and b must be non-negative") else: print("Please proceed.") 23. Write a program that takes 3 floating point values from the user and creates a list. After the list creation, this program should then ask the user whether they wish to add or delete a value. Based on the response from the user, implement the appropriate code to add or delete a specific value provided by the user. Finally before the program terminates, output the list to the user. 24. Write a program that takes 3 floating point values from the user. Without creating a list or otherwise grouped data type, output the 3 values in descending order.
Expert Answer:
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these programming questions
-
Briefly describe ASCII and Unicode and draw attention to any relationship between them. [3 marks] (b) Briefly explain what a Reader is in the context of reading characters from data. [3 marks] A...
-
re Regular Languages and Finite Automata (a) Let L be the set of all strings over the alphabet {a, b} that end in a and do not contain the substring bb. Describe a deterministic finite automaton...
-
Energy of the emitted photon when an L-electron drops into the k-state in copper (z = 29) is -1 use R=109737 cm, cm =1.23910eV] 7994.6 eV 1094.6 eV 1293.6 eV 1097.3 eV
-
Show that the function y = e2x(A cos 3x + B sin 3x) satisfies the differential equation y" - 4y' + 13y = 0.
-
The MPL in the coffee industry in China is 5 and in the rice industry is 10. The MPL in the coffee industry in Italy is 3 and in the rice industry is 9. China has 1,000 workers while Italy has 1,500...
-
If a valve in a pipe is suddenly closed, a large pressure surge may develop. For example, when the electrically operated shutoff valve in a dishwasher closes quickly, the pipes supplying the...
-
On its acquisition-date consolidated balance sheet, what amount should TruData report as goodwill? a. 0. b. $15,000. c. $35,000. d. $100,000. On July 1, TruData Company issues 10,000 shares of its...
-
Explain how high-pressure distillation systems influence the volatility of compounds and discuss the engineering challenges associated with operating at elevated pressures .
-
Metal Fabricators uses stainless steel as an input to its manufacturing processes. Stainless steel is approximately 10% chromium and 90% iron and other alloys. The price of stainless steel varies...
-
1. Owl Company has the following transactions during March: March 3: Purchases inventory on account for $3,300, terms 3/10, n/30. March 5: Pays freight costs of $280 on inventory purchased on March...
-
Two banks (Nationwide Bank and Hometown Bank) are contemplating the idea of merging. The following table lists the sales of the banks in the area. Bank Name Sales (in millions of US dollars) Urban...
-
Consider the program below, concurrent program with multiple threads: volatile int counter = 50; void *worker (void*arg) { counter--; return NULL; } int main(int argc, char*argv[]) { pthread_t p1,...
-
As psychology majors, it is vital that you begin thinking of ways in which you can direct your knowledge of intergroup dynamics to bring attention and/or resolve to real-world issues. Within your...
-
Lamar has the following data: Selling price Variable manufacturing cost Fixed manufacturing cost $40 $22 $ 159,000 per month Variable selling & administrative costs $ 6 Fixed selling & administrative...
-
Write a paper in which you respond to the following questions: 1. What is the role of socialization in women's and men's "choice" of occupations and how do these relationships affect sex segregation...
-
Refer to the information from Exercise 22-19. Use the information to determine the (1) Weighted average contribution margin , (2) Break-even point in units, and (3) Number of units of each product...
-
For an unbounded fluid, the speed of sound is a thermodynamic property. What is its definition?
-
What is the change of the speed of sound with frequency called?
-
For tidal waves in a channel, what is the mathematical relationship between the speed of the wave and the depth of the channel?
Study smarter with the SolutionInn App