Python Advanced Core Technology 97 speak ☝☝☝

Python Advanced Core Technology 97 speak ☝☝☝

 

Python Advanced Core technology 97 speaking tutorial series tutorials

 

Python's standard integer type is the most common numeric types. In most 32-bit machines, standard type integer in the range of -2 ** 31 to 2 ** 31-1.
Numerical Python long integer type that can be expressed only with your machine supports the (virtual) memory size related, in other words, Python can easily express large integers.
Long integer type is a superset of the standard integer type, when the program requires more than a standard integer integer, you can use a long integer type. Add back an integer value L, it is an integer that represents long integer.
Both integer type is gradually unified into a.
The remaining one of the integer type is a boolean integer. That Boolean True and Boolean False.

 

5-2.
Operator.
( A) a write function that calculates and returns the product of two numbers.
( B) to write a piece of code calls this function and show its results.
[Answer]
code is as follows:
DEF Multi_P (A, B):
    C = A * B
    return C

 

a = raw_input("Please input the first number: ...  ")
b = raw_input("Please input the second number: ...  ")
print Multi_P(float(a), float(b))

 

5-3.
Standard type operators. Write a script, enter a test scores, according to the following criteria, scoring output of his accomplishments ( the AF).
A: 90 ~ 100 B: 80 ~ 89 C: 70 ~ 79 D: 60 ~ 69 F: <60
[Answer]
code is as follows:
the while True:
    A = a float (the raw_input ( "Please The INPUT Score: ...") )
    IF A <60: Print "F."
    elif 60 <= A <70: Print "D"
    elif 70 <= A <80: Print "C" 
    elif 80 <= A <90: Print "B"
    elif 90 <= a <= 100: Print "a"
    the else: BREAK
[unfinished] and there is no case where the input is not a check digit. Enter an invalid value, such as the character "a" will be able to jump out of the loop.

 

5-4.
I take. Determining whether a given year is a leap year. Use the following formula.
It means that it is a leap year can be divisible by 4, but can not be divided by 100, or both can be divisible by 4 and can be 100. For example, in 1992, 1996 and 2000 is a leap year, but 1967 and 1900 are not leap years. The next one is the whole century leap year is 2400.
[Answer]
code is as follows:
the while True:
    A = int (the raw_input ( "Please The year INPUT: ..."))
    A4 = A%. 4
    AlOO A = 100%
    A400% = A 400
    IF (A4 == 0 and AlOO ! = 0) or a400 == 0 : print '% i is a leap year! '% A
here not check the input is not a number of cases. Enter an invalid value, such as the character "a" will be able to jump out of the loop.

 

Guess you like

Origin www.cnblogs.com/itye2/p/11704116.html