- Write a Python program to input the length of three sides a, b,
and c of a triangle, and calculate its area and perimeter. For example,
your program may run as follows:
a, b, c =? 3, 4, 5
Area = 6.0
Perimeter = 12
or
a, b, c =? 2, 2, 2
Area = 1.7320508075688772
Perimeter = 6
- Write a Python program to input an integer N, and print out an
inverted triangle. Your program may run as follows:
N=? 5
*****
****
***
**
*
or
N=? 3
***
**
*
- Write a Python program to read a string of digits, and print out a
few number of stars according to the digits. Your program may run as
follows:
1212321
*
**
*
**
***
**
*
or
13075
*
***
*******
*****
- Adjusting Grades
- In Taiwan, normally a student receives a grade between 0 and 100
points. For an undergraduate student, if the grade is less than 60
points, that implies this student fails and must take the course again.
- Sometimes the instructor may decide to adjust the grades of all
students so that more students can pass. A popular formula is to
calculate and square root of the original grade and multiply by 10.
That is,
- new = sqrt(original) * 10
- Write a Python program which input the grade of a student, and
calculate the adjusted new grade according to the above formula.
The program may run as follows:
Input the original grade -- 36
The adjusted grade is 60.
or
Input the original grade -- 50
The adjusted grade is 71.
- Write a Python program which input an integer and print a diamond.
Your program may run as follows:
N=? 3
*
***
*****
***
*
or
N=? 5
*
***
*****
*******
*********
*******
*****
***
*