python 趣味问题之一

python 趣味问题之一
1.python 里,写中文必须加什么,才会不报错?

  1. 在用Python读网页或文档时,最好统一将获取的内容统一转换成什么编码?

  2. Python 可以同一行显示多条语句吗?

  3. 以单下划线开头 的代表什么?

  4. 以双下划线开头的 __foo 代表什么;以双下划线开头和结尾的 foo 代表 什么?

  5. 所有 Python的关键字是小写还是大写?

  6. lambda是Python中的保留字符吗?

  7. 使用什么符号将一行的语句分为多行显示?

  8. 不换行输出怎么表示?

  9. 0x69,10;-4721885298529L,70.2E-12;4.53e-7j,以上分别是什么符号类型?

  10. int(x [,base ])
    long(x [,base ])
    float(x )
    complex(real [,imag ])
    str(x )
    repr(x )
    eval(str )
    tuple(s )
    list(s )
    chr(x )
    unichr(x )
    ord(x )
    hex(x )
    oct(x ) 试解释以上各条命令。

abs(-10) 返回 多少

  1. math.ceil(4.1) 返回 什么

  2. cmp(x, y)

,如果 x < y 返回 多少, 如果 x == y 返回 几, 如果 x > y 返回 什么

  1. math.exp(1) 返回 多少

  2. math.fabs(-10) 返回几

  3. math.floor(4.9)返回 什么

  4. math.log(math.e)返回什么?

  5. math.log(100,10)返回什么

  6. math.log10(100)返回 几

  7. 试解释以下函数
    max(x1, x2,…)

min(x1, x2,…)

modf(x)
pow(x, y)
round(x [,n])
sqrt(x)

22… 解释以下函数
choice(seq)

randrange ([start,] stop [,step])

random()

seed([x])

shuffle(lst)

uniform(x, y)

23… 解释以下函数
acos(x)

asin(x)

atan(x)

atan2(y, x)

cos(x)
hypot(x, y)

sin(x)

tan(x)

degrees(x)

radians(x)

24…解释以下符号
%c

%s

  %d

%u

%o

%x

%X

%f

%e

%E

  %g
  %G
   %p
  1. 试写出以下命令输出结果
    len([1, 2, 3])

[1, 2, 3] + [4, 5, 6]

[‘Hi!’] * 4

  1. 试写出以下命令输出结果

3 in [1, 2, 3]

for x in [1, 2, 3]: print x,

  1. 试预测下列表达式的结果
>>> 2 + 2

>>> 50 - 5*6

>>> (50 - 5*6) / 4

>>> 8 / 5

>>> 17 / 3  # classic division returns a 
>>>
>>> 17 // 3  # floor division discards the fractional part

>>> 17 % 3  # the % operator returns the remainder of the division

>>> 5 * 3 + 2  # result * divisor + remainder

>>> 5 ** 2  # 5 squared

>>> 2 ** 7  # 2 to the power of 7

  1. 写出下列命令的结果
>>> width = 20
>>> height = 5 * 9
>>> width * height
>>> tax = 12.5 / 100
>>> price = 100.50
>>> price * tax

>>> price + _

>>> round(_, 2)

30.试写出下列命令结果

>>> word = 'Python'
>>> word[0]  # character in position 0

>>> word[5]  # character in position 5

  1. 试写出下列命令结果
>>> s = 'supercalifragilisticexpialidocious'
>>> len(s)


32.试写出下列命令结果

>>> squares = [1, 4, 9, 16, 25]
>>> squares

>>>
>>> squares[0]  # indexing returns the item


>>> squares[:]

>>>
>>> squares + [36, 49, 64, 81, 100]
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

33.试写出下列命令结果

>>> cubes = [1, 8, 27, 65, 125]  # something's wrong here
>>> 4 ** 3  # the cube of 4 is 64, not 65!

>>> cubes[3] = 64  # replace the wrong value
>>> cubes

34.试写出下列命令结果

>>> letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
>>> letters

>>> # replace some values
>>> letters[2:5] = ['C', 'D', 'E']
>>> letters

>>> # now remove them
>>> letters[2:5] = []
>>> letters

>>> # clear the list by replacing all the elements with an empty list
>>> letters[:] = []
>>> letters

35.试写出下列命令结果

>>> letters = ['a', 'b', 'c', 'd']
>>> len(letters)

36.试写出下列命令结果

>>> a = ['a', 'b', 'c']
>>> n = [1, 2, 3]
>>> x = [a, n]
>>> x

>>> x[0]

>>> x[0][1]

37.试写出下列命令结果

>>> a, b = 0, 1
>>> while a < 1000:
...     print(a, end=',')
...     a, b = b, a+b

38.试写出下列命令结果

 -3**2

 (-3)**2.
微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值