Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Section I - Aspects of Computational Thinking 1. (15 pts) The flowchart given below is an incomplete solution for following This study source was

imageimageimageimageimage

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:

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_2

Step: 3

blur-text-image_3

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

Financial Accounting

Authors: Jerry J. Weygandt, Paul D. Kimmel, Donald E. Kieso

IFRS 3rd edition

1118978080, 978-1119153726, 1119153727, 978-1119153702, 978-1118978085

More Books

Students also viewed these Programming questions