String
>>> a=9
>>> b=2
>>> a%b
1
>>> a//b
4
>>> x=[1,2,3,4,5,6,7,8,9]
>>> x.pop()
9
>>> x=[1,2,3,4,5,6,7,8,9]
>>> x.pop(-1)
9
>>> int('3.14')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '3.14'
>>> print(str(2*int(float('3.6')))*3)
666
The "3.6" of the string type is converted to 3.6 of the numeric type through float(); the
int() function rounds down the 3.6 of the numeric type to get the value 3;
then executes 2\3 equals 6, and 6 is converted by str() Into the string '6';
finally, the string '6'\3 can get the string '666'.
The priority of relational operators is from high to low: not and or
x = True
y = False
z = False
if x or y and z:
print("yes")
else:
print("no")
Function with parameter *
def greetPerson(*name):
print('Hello', name)
greetPerson('Student', 'Google')
The result
*name is a variable-length parameter, which can receive 0 or more values. When the function is called, the parameter will be automatically assembled into a tuple, so the output result is Hello ('Student','Google').