Problem 18
Write pseudocode for a program that assigns letter grades for a quiz, according to the following table: \(\begin{array}{lc}\text { Score } & \text { Grade } \\ 90-100 & \text { A } \\\ 80-89 & 8 \\ 70-79 & \text { C } \\ 60-69 & \text { D } \\ \text { < 60 } & \text { F }\end{array}\)
Problem 19
Explain how the lexicographic ordering of strings in Python differs from the ordering of words in a dictionary or telephone book. Hint: Consider strings such as 184 , wiley, con, Century 21 , and while-U-Wait.
Problem 19
Write a program that prompts the user to provide a single character from the alphabet. Print Vowel or Consonant, depending on the user input. If the user input is not a letter (between a and \(\mathrm{z}\) or \(\mathrm{A}\) and \(\mathrm{Z}\) ), or is a string of length \(>1\), print an crror message.
Problem 20
Of the following pairs of strings, which comes first in lexicographic order? a. "Tom", "Jerry" b. "Ton", "Tonato" c. "church", "Churchin" d. "car manufacturer", "carburetor" e. "Harry". "hairy" f. "Pythen", "Car" 9\. "Ton", "Ton" h. "Car", "Carl" i. "car", "bar"
Problem 20
The following algorithm yields the season (Spring, Summer, Fall, or Winter) for a given month and day. If moxth is 1,2, or 3, season \(=\) "Winter" Fle if month is 4,5, or 6 , season \(=\) "Spring" Flse if month is 7, 8 , or 9, season \(=\) "Summer" Flae if month is 10,11 , or 12 seascn - "Fall If wonth is divisale by 3 and day \(=21\) If season is "Winter", season = "Sprimg" floe if stason is "Sprimo", season " "Summer" Else if season is "Summer", stason " "Fall" Flae season - "Winter" Write a program that prompts the user for a month and day and then prints the season, as determined by this algorithm.
Problem 21
Explain the difference between an if/elif/else sequence and nested if statements. Give an example of each.
Problem 21
Writc a program that reads in two floating-point numbers and tests whether they are the same up to two decimal places. Here are two sample runs. Enter a floating-point nunber; \(2.0\) Enter a floating-point nurber; \(1.99998\) They are the sare up to two decimal places. Enter a floating-point nunber: \(2.0\) Enter a floating-point nunber: \(1.98999\) They are different.
Problem 22
Give an example of an if/elif/else sequence where the order of the tests does not matter. Give an example where the order of the tests matters.
Problem 22
Write a program that prompts for the day and month of the user's birthday and then prints a horoscope. Make up fortunes for programmers, like this: Flease enter your birthday. nonth: 6 day: 16 Cenini are experts at figuring out the behavior of conplicated prograns. You feel where bugs are coning from and then stay one step ahead. Tonight, your style wins approval fron a tough critic. Each fortune should contain the name of the astrological sign. (You will find the names and date ranges of the signs at a distressingly large number of sites on the Internct.)
Problem 23
The original U.S. income tax of 1913 was quite simple. The tax was \- 1 percent on the first \(\$ 50,000 .\) \- 2 percent on the amount over \(\$ 50,000\) up to \(\$ 75,000\). \- 3 percent on the amount over \(\$ 75,000\) up to \(\$ 100,000\). \- 4 percent on the amount over \(\$ 100,000\) up to \(\$ 250,000\). \- 5 percent on the amount over \(\$ 250,000\) up to \(\$ 500,000 .\) \- 6 percent on the amount over \(\$ 500,000 .\) There was no separate schedule for single or marricd taxpayers. Write a program that computes the income tax according to this schedule.