#
CMU 15-112: Fundamentals of Programming and Computer Science

Extra Practice for Day 1 (Due never)

- These problems will help you prepare for hw1 and test1. They are optional and you are encouraged to collaborate when working on them.
- You may also wish to see extra-practice1-ct-and-roc.html.
- To start:
- Create a folder named 'week1'
- Download both extra_practice1.py and cs112_m20_week1_linter.py to that folder
- Edit extra_practice1.py using VSCode

- Do not use string indexing, loops, lists, list indexing, or recursion this week.
- Do not hardcode the test cases in your solutions.
**Hint**: Look at the test functions in the starter file to get a better idea of what each question is asking.

**fabricYards(inches)**

Fabric must be purchased in whole yards, so purchasing just 1 inch of fabric requires purchasing 1 entire yard. With this in mind, write the function fabricYards(inches) that takes the number of inches of fabric desired, and returns the smallest number of whole yards of fabric that must be purchased. Note: 36 inches equals 1 yard.**fabricExcess(inches)**

Write the function fabricExcess(inches) that takes the number of inches of fabric desired and returns the minimum number of inches of excess fabric that must be purchased (as purchases must be in whole yards).**Hint:**you may want to use fabricYards, which you just wrote!**isMultiple(m,n)**

Write the function isMultiple that takes two int values m and n and returns True if m is a multiple of n and False otherwise. Note that 0 is a multiple of every integer including itself.**eggCartons(eggs)**

Write the function eggCartons(eggs) that takes a non-negative integer number of eggs, and returns the smallest integer number of cartons required to hold that many eggs, where a carton may hold up to 12 eggs.**isLegalTriangle(s1, s2, s3)**

Write the function isLegalTriangle(s1, s2, s3) that takes three int or float values representing the lengths of the sides of a triangle, and returns True if such a triangle exists and False otherwise. Note from the triangle inequality that the sum of each two sides must be greater than the third side, and further note that all sides of a legal triangle must be positive. Hint: how can you determine the longest side, and how might that help?**isRightTriangle(x1, y1, x2, y2, x3, y3)**

Write the function isRightTriangle(x1, y1, x2, y2, x3, y3) that takes 6 int or float values that represent the vertices (x1,y1), (x2,y2), and (x3,y3) of a triangle, and returns True if that is a right triangle and False otherwise. You may wish to write a helper function, distance(x1, y1, x2, y2), which you might call several times. Also, remember to use almostEqual (instead of ==) when comparing floats.