# Welcome to CS

## Exercises25.10Chapter Exercises

### 1.

The following program segment should ask whether the user wants to terminate the program and print out the appropriate statement based on the user’s response. The blocks have been mixed up and include extra blocks that aren’t needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right.

### 2.

The following program segment should ask the user for three numbers and say whether they are in order. The numbers can be either ascending (going up) or descending (going down).
For example, if the inputs are 10 15 20, the answer should be “yes, in order”. Same if the inputs were 6 5 1. But if the inputs were 3 5 4, the answer would be “no, not in order”.
The blocks have been mixed up and include extra blocks that aren’t needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right.

### 3.

The program below is supposed to calculate the final bill for a meal at a fast-food restaurant in a state where meals that are taken to go are not taxed, but meals eaten in the restaurant are.
Your job is to write the getTotalCost function. It should use the initial meal price and the location it is being eaten to calculate the final cost. If location has the string "to go" anywhere in it, the total cost should be just the meal price. Otherwise, it should be the price + 8% (1.08 times the meal price).
Remember that you can use in to check if one string appears inside another.
Note that when you run it, you can enter whatever values you want. The tests for your program will automatically try a collection of different inputs and don’t depend on what you type in.

### 4.

The program below is supposed to figure out the cost of a ticket for a customer to a museum. Anyone who is over 65 or younger than 12 gets in free. Anyone who is 12 to 17 gets in for $8. Everyone else is$15.
Your job is to write the getTicketCost function. It should use the age parameter to decide on the right cost and then return that value. (Just return a number like 0, 8, or 15, don’t include \$).

### 5.

To graduate from a particular high school, a student needs 22 or more total credits and at least 3 math credits. (They also need some other specific subjects, but we will ignore them.)
Finish the canGraduate function. It accepts the number of totalCredits earned and the number of mathCredits. It should return True (without any quotes!!!) if someone with that number of credits is ready to graduate. Otherwise, return False.
You can modify the code in the main part of the program to test out different numbers of credits. The tests will not use what you do there, they will just test your function.
You have attempted of activities on this page.