Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Python converts percentiles into hierarchical output.
Python converts percentiles into hierarchical output.
1、def main():

Score = float (input ('Please enter score:'))

If the score & gt= 90:

Grade = 'A'

Elif score & gt= 80:

Grade = 'B'

Elif score & gt= 70:

Grade = 'C'

Elif score & gt= 60:

Grade = 'D'

Otherwise:

Grade = 'E'

Print ('corresponding grade:', grade)

if __name__ == '__main__ ':

Master ()

2. You can also construct a string "EEEEEDCBAA" from the quintuple, and realize this function in the following ways:

score = int(input())

degree = ' EEEEEEDCBAA '

if(score & gt; 100 or score & lt0):

Print ('data error!' )

Otherwise:

Print (degree [score/10])

Extended data:

1, print format of integer.

num0 1,num02=200,300

Print ("Octal output: 0o%o, 0o%o"%(num0 1, num02)).

Print ("Hexadecimal output: 0x%x, 0x%x"%(num0 1, num02)).

Print ("decimal output: %d, %d"%(num0 1, num02)).

Print ("binary output 200:", bin (num0 1), "binary output 300:", bin(num02)).

2、#? Floating point output

%f reserves six significant digits after the decimal point, while %.3f reserves three decimal places.

%e Keep six significant digits after the decimal point and output it in exponential form. %.3e Keep 3 decimal places and use scientific counting method.

%g On the premise of retaining six significant figures, use decimal method, otherwise use scientific counting method. %3g reserves 3 significant digits and adopts decimal or scientific counting method.