Section I - Aspects of Computational Thinking 1. (15 pts) The flowchart given below is an...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Section I - Aspects of Computational Thinking 1. (15 pts) The flowchart given below is an incomplete solution for following This study source was downloaded by 100000874659524 from Course Hero.com on 11-09-2023 06:46:32 GMT -06:00 https://www.coursehero.com/file/210445669/Midterm-1-Fall2223-Questionsdocx/ the 1 question: Draw the flowchart of an algorithm that calculates the factorial of a given number, n. You may assume that n will always be a positive integer. Complete this flowchart by adding the arrows in between the boxes that specify the steps of the algorithm to show their ordering. START Get n from user set factorial to 1 Print factorial n>1 update factorial by multiplying it with n decrease the value of n by 1 STOP Name & Surname: 2. (15 pts) Write the pseudocode of an algorithm that gets an integer as the current month value as its only input, and displays the next month as result. Your program should also check whether the input is between 1 and 12 (both inclusive), and should display an appropriate error message if it is not. For instance, if the input is 10, then the result should be 11, and if the input is 12, then the result should be 1. On the other hand, if the input is anything other than the numbers between and including 1 and 12, then the should input considered as invalid. 3. (15 pts) Following is a sorting network intended to design for sorting 4 (four) numbers in ascending order. 1 The network works correctly with the provided example ordering of inputs, as given below. However, can it sort every combination of 4 (four) different numbers in ascending order? 2 3 be 4 ID: If yes, prove your hypothesis and show that the network properly sorts any given 4 (four) numbers. 2 If not, O discuss your reasoning or provide a counterexample, O and show how 1 3 to m2 + fix 1 2 3 4 it. Section II- Programming with Python 4. (15 pts) Write a Python program that takes the name of the user as the first input and then asks for the following inputs, while referring to the user with their name (check the sample case given below). The following inputs are the price of a single private piano lesson and the number of lessons the user wants to take. Your program should then calculate the total cost that This study source was downloaded by 100000874659524 from CourseHero.com on 11-09-2023 06:46:32 GMT -06:00 ttps://www.coursehero.com/file/210445669/Midterm-1-Fall2223-Questionsdocx/ the user needs to pay and display it it as its only output. sample: Here is Please enter your name: Duygu Duygu, enter cost of a private piano lesson: 199.99 Duygu, enter number of lessons to take: 5 Total cost would be 999.95 3 a 5. (20 pts) When a patient visits the Health Center, doctors initially measure the body temperature and ask if they feel any pain. If the patient has only fever (i.e. if the body temperature is strictly greater than 37.5 C) and no pain, then the doctors prescribe medicine A; if there is pain but no fever, then they prescribe medicine B; and if there is both fever and pain, then they request a blood test to check for the CRP value. In that case, if the CRP value is lower than 5, then the doctor prescribes medicine C, and otherwise s/he prescribes medicine D. This is the applied procedure since the blood test is expensive; doctors request it only when it is necessary. On the other hand, if the patient neither has fever nor pain, then the doctor sends him/her without prescription. any Write a Python program that gets the relevant inputs from the user, and then decides and displays the medicine to be prescribed. You may assume that the second input (whether the patient feels pain or not) will be entered as either "Y" for yes or "N" no. Here are What's the body temperature? 37.2 Any pain (Y or N)? N No medicine What's the body temperature? 37.5 Any pain (Y or N)? Y CRP result? 4.5 Medicine C What's the body temperature? 38 Any pain (Y or N)? N Medicine A some samples: 6. (20 pts) There are a number of different espresso based drinks that include milk also, all having their own characteristics. In the table given below, you may see two of them shown with their milky ingredients. Steamed Milk Milk Foam Latte yes yes Flat White are yes no Macchiato Write a Python program that gets the preference of the user on which ingredients their coffee would be having as a single unified input from the user, in the format of first_preference-second_preference, where the first preference refers to steamed milk while the second one refers to milk foam. Here, the values first_preference and second_preference can only be yes or no, case insensitively. That is, yes, yEs, YES and any combination of those 3 (three) letters would be considered as the same by your program. And the same idea also holds for the "no" input as well. You may assume that there will be exactly one dash character ("-") in the given input. Here few sample What's your preference (yes/no-yes/no)?: yes-YES Latte no If both of the preferences are "no" (case insensitive), then your program should print "Invalid combination", since there is no such option in the table given above. If at least one of the preferences is a value except for "yes" or "no" (case insensitive), then your program should print "Invalid input". If both preferences are valid, then your program should print the coffee type served. correct to be yes What's your preference (yes/no-yes/no)?: no-yes Macchiato What's your preference (yes/no-yes/no)?: izmir-yes Invalid input examples: Section I - Aspects of Computational Thinking 1. (15 pts) The flowchart given below is an incomplete solution for following This study source was downloaded by 100000874659524 from Course Hero.com on 11-09-2023 06:46:32 GMT -06:00 https://www.coursehero.com/file/210445669/Midterm-1-Fall2223-Questionsdocx/ the 1 question: Draw the flowchart of an algorithm that calculates the factorial of a given number, n. You may assume that n will always be a positive integer. Complete this flowchart by adding the arrows in between the boxes that specify the steps of the algorithm to show their ordering. START Get n from user set factorial to 1 Print factorial n>1 update factorial by multiplying it with n decrease the value of n by 1 STOP Name & Surname: 2. (15 pts) Write the pseudocode of an algorithm that gets an integer as the current month value as its only input, and displays the next month as result. Your program should also check whether the input is between 1 and 12 (both inclusive), and should display an appropriate error message if it is not. For instance, if the input is 10, then the result should be 11, and if the input is 12, then the result should be 1. On the other hand, if the input is anything other than the numbers between and including 1 and 12, then the should input considered as invalid. 3. (15 pts) Following is a sorting network intended to design for sorting 4 (four) numbers in ascending order. 1 The network works correctly with the provided example ordering of inputs, as given below. However, can it sort every combination of 4 (four) different numbers in ascending order? 2 3 be 4 ID: If yes, prove your hypothesis and show that the network properly sorts any given 4 (four) numbers. 2 If not, O discuss your reasoning or provide a counterexample, O and show how 1 3 to m2 + fix 1 2 3 4 it. Section II- Programming with Python 4. (15 pts) Write a Python program that takes the name of the user as the first input and then asks for the following inputs, while referring to the user with their name (check the sample case given below). The following inputs are the price of a single private piano lesson and the number of lessons the user wants to take. Your program should then calculate the total cost that This study source was downloaded by 100000874659524 from CourseHero.com on 11-09-2023 06:46:32 GMT -06:00 ttps://www.coursehero.com/file/210445669/Midterm-1-Fall2223-Questionsdocx/ the user needs to pay and display it it as its only output. sample: Here is Please enter your name: Duygu Duygu, enter cost of a private piano lesson: 199.99 Duygu, enter number of lessons to take: 5 Total cost would be 999.95 3 a 5. (20 pts) When a patient visits the Health Center, doctors initially measure the body temperature and ask if they feel any pain. If the patient has only fever (i.e. if the body temperature is strictly greater than 37.5 C) and no pain, then the doctors prescribe medicine A; if there is pain but no fever, then they prescribe medicine B; and if there is both fever and pain, then they request a blood test to check for the CRP value. In that case, if the CRP value is lower than 5, then the doctor prescribes medicine C, and otherwise s/he prescribes medicine D. This is the applied procedure since the blood test is expensive; doctors request it only when it is necessary. On the other hand, if the patient neither has fever nor pain, then the doctor sends him/her without prescription. any Write a Python program that gets the relevant inputs from the user, and then decides and displays the medicine to be prescribed. You may assume that the second input (whether the patient feels pain or not) will be entered as either "Y" for yes or "N" no. Here are What's the body temperature? 37.2 Any pain (Y or N)? N No medicine What's the body temperature? 37.5 Any pain (Y or N)? Y CRP result? 4.5 Medicine C What's the body temperature? 38 Any pain (Y or N)? N Medicine A some samples: 6. (20 pts) There are a number of different espresso based drinks that include milk also, all having their own characteristics. In the table given below, you may see two of them shown with their milky ingredients. Steamed Milk Milk Foam Latte yes yes Flat White are yes no Macchiato Write a Python program that gets the preference of the user on which ingredients their coffee would be having as a single unified input from the user, in the format of first_preference-second_preference, where the first preference refers to steamed milk while the second one refers to milk foam. Here, the values first_preference and second_preference can only be yes or no, case insensitively. That is, yes, yEs, YES and any combination of those 3 (three) letters would be considered as the same by your program. And the same idea also holds for the "no" input as well. You may assume that there will be exactly one dash character ("-") in the given input. Here few sample What's your preference (yes/no-yes/no)?: yes-YES Latte no If both of the preferences are "no" (case insensitive), then your program should print "Invalid combination", since there is no such option in the table given above. If at least one of the preferences is a value except for "yes" or "no" (case insensitive), then your program should print "Invalid input". If both preferences are valid, then your program should print the coffee type served. correct to be yes What's your preference (yes/no-yes/no)?: no-yes Macchiato What's your preference (yes/no-yes/no)?: izmir-yes Invalid input examples:
Expert Answer:
Related Book For
Financial Accounting
ISBN: 978-1118978085
IFRS 3rd edition
Authors: Jerry J. Weygandt, Paul D. Kimmel, Donald E. Kieso
Posted Date:
Students also viewed these programming questions
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Shreya commutes in a CNG fitted van to school every day along with many other students. She told the van driver to get the CNG connection certified and timely checked it for any leakage or loose...
-
Lemon Quench manufactures a soft drink. The company is organized into two divisions: glass and filling. The glass division makes bottles and sells them to the filling division. Each division manager...
-
Consider the data set of programming errors given in DS 6.6.3. Construct a point estimate of the average number of errors per month. What is the standard error of your point estimate?
-
What principle is used in the Ritz-Galerkin method?
-
The following diagram depicts the relationships among Mary Company, John Company, and Joan Company on December 31, 2014: Mary Company purchases its interest in John Company on January 1, 2012, for...
-
Your firm, BrainFreeze and Go, is an ice cream seller, one of many small firms in a monopolistically competitive environment. You are currently operating in the short-run when your assistant brings...
-
Blossoms, Inc. has provided you with the following financial information: Budgeted Actual Sales Quantity 7,200 7,400 Sales price per unit $6.50 $6.25 Variable product cost per unit 3.00 3.25 Selling...
-
There are FIVE (5) characteristics that influencing an innovation's rate of adoption. Explain how each of these characteristics would affect your adoption of an electric car that travels up to 40...
-
Prepare a multiple-step income statement. (Round answers to O decimal places, e.g. 15,222.) The Clorox Company Income Statement For the Year Ended June 30, 2025 (amounts in millions) Sales Sales...
-
Create a simple "web-app" that we created using client-side HTML form, come up with our very own (custom-built) JS calculator. One possible "look and feel" is shown below in attached screen-shot (CSS...
-
Which formula is appropriate to solve for the beginning-of-the-month payment required for a car loan if you know the interest rate, length of the loan, and the borrowed amount?
-
A carpenter uses roughly 15,000 sanding pads in one year. The set-up costs are $15.00 and carrying costs are estimated at 2%. Each pad costs $4.50. What is the economic order quantity? (Round decimal...
-
Given that SS=2400 H. SP=8631 H, and AX=4FA6H H, and DX=8C3FH H, What is the physical address of the memory location pointed by the stack pointer, SP after the execution of the following lines of...
-
Identify the most stable compound:
-
Dan Fineman, the president of King Company, is pleased. King substantially increased its net income in 2017 while keeping its unit inventory relatively the same. Howard Gross, chief accountant,...
-
Fields Enterprises has 70,000 ordinary shares outstanding. It declares a 1.5 per share cash dividend on November 1 to shareholders of record on December 1. The dividend is paid on December 31....
-
Data for Asquith Company SA are presented in P13-3B. Instructions Prepare the operating activities section of the statement of cash flows using the direct method. ASQUITH COMPANY SA Income Statement...
-
Find each probability using the standard normal distribution. (a) \(P(z>-1.68)\) (b) \(P(z <2.23)\) (c) \(P(-0.47
-
Are you more likely to randomly select one person with an IQ score greater than 105 or are you more likely to randomly select a sample of 15 people with a mean IQ score greater than 105? Explain. In...
-
What is the lowest score that would still place a person in the top \(5 \%\) of the scores? In a standardized IQ test, scores are normally distributed, with a mean score of 100 and a standardized...
Study smarter with the SolutionInn App