加分題

(1)   Please write a Python program to print a diamond. [hint: use str.center() ]

      *

    ***

  *****

*******

 *****

   ***

     *

(2)    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

 

(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) [factors] Please write a Python program that allows the user to input a positive integer and then finds all its factors. For example: input 24, then output 1, 2, 3, 4, 6, 8, 12, 24.

 

(5) 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.

 

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工具或抄襲他人而撰寫程式,除不予加分外,將倒扣分數,請同學慎思!)