Problem 7
Explain why it is more difficult to compare floating-point numbers than integers. Write Python code to test whether an integer n equals 10 and whether a floatingpoint number \(x\) is approximately equal to 10 .
Problem 7
Write a program that reads in three integers and prints "in order" if they are sorted in ascending or descending order, or "not in order" otherwise. For example, \(\begin{array}{llll}1 & 2 & 5 & \text { in order } \\ 1 & 5 & 2 & \text { not in order } \\ 5 & 2 & 1 & \text { in order } \\ 1 & 2 & 2 & \text { in order }\end{array}\)
Problem 8
Write a program that reads four integers and prints "two pairs" if the input consists of two matching pairs (in some order) and "not two pairs" otherwise. For example, \(\begin{array}{lllll}1 & 2 & 2 & 1 & \text { two pairs } \\ 1 & 2 & 2 & 3 & \text { not two pairs } \\ 2 & 2 & 2 & 2 & \text { tuo pairs }\end{array}\)
Problem 9
Write a program that reads a temperature value and the letter \(C\) for Celsius or \(F\) for Fahrenheit. Print whether water is liquid, solid, or gaseous at the given temperature at sea level.
Problem 11
In a scheduling program, we want to check whether two appointments overlap. For simplicity, appointments start at a full hour, and we use military time (with hours 0-24). The following pseudocode describes an algorithm that determines whether the appointment with start time startl and end time end 1 overlaps with the appointment with start time start2 and end time end2. H start1 s start2 \(s=\) start 1 the \(s=\) start2 If end \(1<\) end2 \(e\) * end 1 The \(e=\cos 2\) If see The appointionents overlap. Flue The appointwents don't overlap. 'Trace this algorithm with an appointment from 10-12 and one from 11-13, then with an appointment from 10-11 and one from 12-13.
Problem 12
Write a program that translares a letter grade into a number grade. Letter grades are \(A, B, C, D\), and \(F\), possibly followed by \(+\) or \(-.\) Their numeric values are \(4,3,2,1\), and 0. There is no \(\mathrm{F}+\) or \(\mathrm{F}-. \mathrm{A}+\) increases the numeric value by \(0.3\), a \(-\) decreases it by \(0.3 .\) However, an A+ has value \(4.0\). Enter a Tetter grade: \(\mathbb{B}\) - The nuneric value is \(2.7\).
Problem 15
Write a program that reads in three floating-point numbers and prints the largest of the three inputs without using the nax function. For example: Enter a number: 4 Enter a nuirber: 9 Enter a number: \(2.5\) The largest number is 9,0
Problem 16
Write a program that reads in three strings and sorts them lexicographically. Enter a string: Charlie Enter a string: Able Enter a string: Baker Able Baker Charlie
Problem 17
Write pseudocode for a program that prompts the user for a month and day and prints out whether it is one of the following four holidays: \- New Year's Day (January 1) \- Independence Day (July 4) \- Veterans Day (November 11) \- Christmas Day (December 25)
Problem 17
Write a program that reads in a string and prints whether it \- contains only letters. \- contains only uppercase letters. \- contains only lowercase letters. \- contains only digits. \- contains only letters and digits. \- starts with an uppercase letter. \- ends with a period.