[python]数据类型-练习题

更新时间:2023-05-25 23:25:32 阅读: 评论:0

[python]数据类型-练习题
运算符
1、算数运算:
lo的过去式2、⽐较运算:
3、赋值运算:
4、逻辑运算:
5、成员运算:
基本数据类型
1、数字
int(整型)
  在32位机器上,整数的位数为32位,取值范围为-2**31~2**31-1,即-2147483648~2147483647
  在64位系统上,整数的位数为64位,取值范围为-2**63~2**63-1,即-9223372036854775808~9223372036854775807
class int(object):
四级身份证
"""
int(x=0) -> int or long
int(x, ba=10) -> int or long
Convert a number or string to an integer, or return 0 if no arguments
are given.  If x is floating point, the conversion truncates towards zero.    If x is outside the integer range, the function returns a long instead.
goldbach conjectureIf x is not a number or if ba is given, then x must be a string or
Unicode object reprenting an integer literal in the given ba.  The
literal can be preceded by '+' or '-' and be surrounded by whitespace.
The ba defaults to 10.  Valid bas are 0 and 2-36.  Ba 0 means to    interpret the ba from the string as an integer literal.
>>> int('0b100', ba=0)
"""
def bit_length(lf):
""" 返回表⽰该数字的时占⽤的最少位数 """
"""
int.bit_length() -> int
Number of bits necessary to reprent lf in binary.
>>> bin(37)
'0b100101'
>>> (37).bit_length()
"""
return 0
def conjugate(lf, *args, **kwargs): # real signature unknown
""" 返回该复数的共轭复数 """
""" Returns lf, the complex conjugate of any int. """
pass
def__abs__(lf):
""" 返回绝对值 """
""" x.__abs__() <==> abs(x) """
pass
def__add__(lf, y):
""" x.__add__(y) <==> x+y """
pass
def__and__(lf, y):
""" x.__and__(y) <==> x&y """
pass
def__cmp__(lf, y):
""" ⽐较两个数⼤⼩ """
""" x.__cmp__(y) <==> cmp(x,y) """
pass
def__coerce__(lf, y):
""" 强制⽣成⼀个元组 """
""" x.__coerce__(y) <==> coerce(x, y) """
pass
def__divmod__(lf, y):
""" 相除,得到商和余数组成的元组 """
""" x.__divmod__(y) <==> divmod(x, y) """
pass
def__div__(lf, y):
""" x.__div__(y) <==> x/y """
pass
def__float__(lf):
""" 转换为浮点类型 """
""" x.__float__() <==> float(x) """
pass
def__floordiv__(lf, y):
""" x.__floordiv__(y) <==> x//y """
pass
def__format__(lf, *args, **kwargs): # real signature unknown
pass
def__getattribute__(lf, name):
""" x.__getattribute__('name') <==> x.name """
pass
def__getnewargs__(lf, *args, **kwargs): # real signature unknown
""" 内部调⽤ __new__⽅法或创建对象时传⼊参数使⽤ """
pass
def__hash__(lf):
"""如果对象object为哈希表类型,返回对象object的哈希值。哈希值为整数。在字典查找中,哈希值⽤于快速⽐较字典的键。两个数值如果相等,则哈希值也相等。"""
""" x.__hash__() <==> hash(x) """
pass
def__hex__(lf):
""" 返回当前数的⼗六进制表⽰ """
""" x.__hex__() <==> hex(x) """
pass
def__index__(lf):
""" ⽤于切⽚,数字⽆意义 """
""" x[y:z] <==> x[y.__index__():z.__index__()] """
pass
def__init__(lf, x, ba=10): # known special ca of int.__init__
""" 构造⽅法,执⾏ x = 123 或 x = int(10) 时,⾃动调⽤,暂时忽略 """
"""
int(x=0) -> int or long
int(x, ba=10) -> int or long
Convert a number or string to an integer, or return 0 if no arguments
are given.  If x is floating point, the conversion truncates towards zero.
If x is outside the integer range, the function returns a long instead.
If x is not a number or if ba is given, then x must be a string or
Unicode object reprenting an integer literal in the given ba.  The
literal can be preceded by '+' or '-' and be surrounded by whitespace.
The ba defaults to 10.  Valid bas are 0 and 2-36.  Ba 0 means to
interpret the ba from the string as an integer literal.
>>> int('0b100', ba=0)
# (copied from class doc)
"""
pass
def__int__(lf):
""" 转换为整数 """
""" x.__int__() <==> int(x) """
pass
def__invert__(lf):
""" x.__invert__() <==> ~x """
pass
def__long__(lf):
""" 转换为长整数 """
""" x.__long__() <==> long(x) """
pass
def__lshift__(lf, y):
""" x.__lshift__(y) <==> x<<y """
pass
def__mod__(lf, y):
""" x.__mod__(y) <==> x%y """
pass
def__mul__(lf, y):
""" x.__mul__(y) <==> x*y """
pass
def__neg__(lf):
""" x.__neg__() <==> -x """
pass
@staticmethod # known ca of __new__
def__new__(S, *more):
""" T.__new__(S, ...) -> a new object with type S, a subtype of T """
pass
def__nonzero__(lf):
""" x.__nonzero__() <==> x != 0 """
pass
def__oct__(lf):
""" 返回改值的⼋进制表⽰ """
""" x.__oct__() <==> oct(x) """aux是什么意思
pass
def__or__(lf, y):
""" x.__or__(y) <==> x|y """
pass
def__pos__(lf):
""" x.__pos__() <==> +x """
pass
def__pow__(lf, y, z=None):
""" 幂,次⽅ """
bolted
""" x.__pow__(y[, z]) <==> pow(x, y[, z]) """
pass
def__radd__(lf, y):
""" x.__radd__(y) <==> y+x """
pass
def__rand__(lf, y):
""" x.__rand__(y) <==> y&x """
pass
def__rdivmod__(lf, y):
""" x.__rdivmod__(y) <==> divmod(y, x) """
pass
sorry that i love you
def__rdiv__(lf, y):
""" x.__rdiv__(y) <==> y/x """
pass
def__repr__(lf):
"""转化为解释器可读取的形式 """
""" x.__repr__() <==> repr(x) """
pass
def__str__(lf):
"""转换为⼈阅读的形式,如果没有适于⼈阅读的解释形式的话,则返回解释器课阅读的形式""" """ x.__str__() <==> str(x) """
pass
def__rfloordiv__(lf, y):
""" x.__rfloordiv__(y) <==> y//x """
pass
def__rlshift__(lf, y):
沪江日语""" x.__rlshift__(y) <==> y<<x """
pass
def__rmod__(lf, y):
""" x.__rmod__(y) <==> y%x """
pass
def__rmul__(lf, y):
""" x.__rmul__(y) <==> y*x """
pass
def__ror__(lf, y):
""" x.__ror__(y) <==> y|x """
pass
def__rpow__(lf, x, z=None):
""" y.__rpow__(x[, z]) <==> pow(x, y[, z]) """
pass
def__rrshift__(lf, y):
""" x.__rrshift__(y) <==> y>>x """
pass
def__rshift__(lf, y):
""" x.__rshift__(y) <==> x>>y """
pass
def__rsub__(lf, y):
""" x.__rsub__(y) <==> y-x """
pass
def__rtruediv__(lf, y):
""" x.__rtruediv__(y) <==> y/x """
pass
def__rxor__(lf, y):
""" x.__rxor__(y) <==> y^x """
pass
def__sub__(lf, y):
""" x.__sub__(y) <==> x-y """
pass
def__truediv__(lf, y):
""" x.__truediv__(y) <==> x/y """
pass
def__trunc__(lf, *args, **kwargs):
""" 返回数值被截取为整形的值,在整形中⽆意义 """
pass
def__xor__(lf, y):
""" x.__xor__(y) <==> x^y """
pass
denominator = property(lambda lf: object(), lambda lf, v: None, lambda lf: None)  # default """ 分母 = 1 """
"""the denominator of a rational number in lowest terms"""
imag = property(lambda lf: object(), lambda lf, v: None, lambda lf: None)  # default """ 虚数,⽆意义 """
"""the imaginary part of a complex number"""
numerator = property(lambda lf: object(), lambda lf, v: None, lambda lf: None)  # default """ 分⼦ = 数字⼤⼩ """
"""the numerator of a rational number in lowest terms"""
real = property(lambda lf: object(), lambda lf, v: None, lambda lf: None)  # default """ 实属,⽆意义 """sx什么意思
"""the real part of a complex number"""
int心灵鸡汤在线阅读
int
2、布尔值
  真或假
  1 或 0
3、字符串
class str(bastring):
"""
str(object='') -> string
Return a nice string reprentation of the object.
If the argument is a string, the return value is the same object.
"""
def capitalize(lf):
""" ⾸字母变⼤写 """
"""
S.capitalize() -> string
Return a copy of the string S with only its first character
capitalized.
"""
return""
def center(lf, width, fillchar=None):
""" 内容居中,width:总长度;fillchar:空⽩处填充内容,默认⽆ """
"""
<(width[, fillchar]) -> string
hifi是什么
Return S centered in a string of length width. Padding is
done using the specified fill character (default is a space)
"""
return""
def count(lf, sub, start=None, end=None):
""" ⼦序列个数 """
"""
Return the number of non-overlapping occurrences of substring sub in
string S[start:end].  Optional arguments start and end are interpreted
as in slice notation.
"""
return 0
def decode(lf, encoding=None, errors=None):
""" 解码 """
"""
S.decode([encoding[,errors]]) -> object
Decodes S using the codec registered for encoding. encoding defaults
to the default encoding. errors may be given to t a different error
handling scheme. Default is 'strict' meaning that encoding errors rai
a UnicodeDecodeError. Other possible values are 'ignore' and 'replace'
as well as any other name registered ister_error that is

本文发布于:2023-05-25 23:25:32,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/78/776626.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:返回   整数   形式   阅读   运算
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图