[加分題]

1.     Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error message. If the score is between 0.0 and 1.0, print a grade using the following table:

score

Grade

>=0.9

A

>=0.8

B

>=0.7

C

>=0.6

D

< 0.6

F

 

2.     The article (But soft what light through yonder window breaks. It is the east and Juliet is the sun. Arise fair sun and kill the envious moon. Who is already sick and pale with grief.) was written by Shakespeare. Let’s use Python to achieve that instead. List all unique words, sorted in alphabetical order, stored in a list.
a.      Print the list
b.     Count and print all unique words
c.  Compute and print sentiment index (=the number of total sentimental words/the number of all words). These words (fair, envious, pale, grief) are defined as sentimental words.
 

3.     Write the program that prompts the user for a list of numbers and prints out the maximum and minimum of the numbers at the end when the user enters “done”. Write the program to store the numbers the user enters in a list and use the max() and min() functions to compute the maximum and minimum numbers after the loop completes.

Example:

Enter a number: 6

Enter a number: 2

Enter a number: 9

Enter a number: 3

Enter a number: 5

Enter a number: done

Maximum: 9.0

Minimum: 2.0

 

4.     (a) Write a program to prompt the user for hours and rate per hour to compute gross pay. Create a function called computepay which takes the two parameters (hours and rate).

Example:

Enter Hours: 35

Enter Rate: 2.75

Pay: 96.25

We won’t worry about making sure our pay has exactly two digits after the decimal place for now. If you want, you can play with the built-in Python round function to properly round the resulting pay to two decimal places.

   (b) Rewrite your pay computation to give the employee 1.5 times the hourly rate for hours worked above 40 hours.

    Example:

Enter Hours: 45

Enter Rate: 10

Pay: 475.0

   (c) Rewrite your pay program using try and except so that your program handles non-numeric input gracefully by printing a message and exiting the program. The following shows two executions of the programs:

  Example:

Enter Hours: 20

Enter Rate: nine

Error, please enter numeric input

Enter Hours: forty

Error, please enter numeric input

 

Students write these questions by themselves. If anyone uses AI tools or plagiarizes from others, no extra points will be awarded. I will deduct some points from your original points. Please think carefully!

(請寫這些題目的同學務必自行撰寫,若有透過AI工具或抄襲他人而撰寫程式,除不予加分外,將倒扣分數,請同學慎思!)