Python 6.21

from math import pi as P
from os.path import getsize
from random import choice
from itertools import *
import math

r = 3
print(round(Prr,2))
print(choice('Python'))
print("----------------")

characters = '1234'
for item in combinations(characters,3):
print(item,end = '')
print('\n'+'='*20)
for item in permutations(characters,3):
print(item,end = '')
print("----------------")

print (math.factorial (32))
print (math.isclose (0.4-0.3,0.1))
num = 7
squreRoot = num ** 0.5
print (squreRoot2 == num)
print (math.isclose(squreRoot
2,num))
print("----------------")

X=0b1011
print (X)
print("----------------")

z=1.2+3.4j
print (z.imag)
print("----------------")

x=6
y=-5+2j
print (x+y)
print("----------------")

x=5
y=2
print (x/y,x//y)
print("----------------")

x_list = [1,2,3,5,8,9] #列表
print (x_list[5],x_list[3])
print (len(x_list)) #查看列表长度
print (max (x_list))
print("----------------")

x_tuple = (1,2,3,5,6,8,9,25) #元组
print (x_tuple.index(2)) #查看元素2在元组中时首次出现的位置
print("----------------")

x_set = { 1, 2 , 3 , 4,8} #集合
print (max (x_set)) #查看集合中最大值
print("----------------")

x_dict = {'a':97, 'b':98 ,'c':99} #字典
for key ,value in x_dict.items():
if value == 98:
print (key) #查看字典中98对应的键
print("----------------")

text = '''Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.'''
print (len (text)) #字符串长度
print (text.count('is')) #is出现的次数
print ('beautiful' in text) #是否包含单词beauiful
print ('='*20) #字符串重复
print ('Good' + 'Moring')
print("----------------")

上一篇:如何在android中的editText中输入最大长度的文本后自动隐藏键盘?


下一篇:用SAS进行泊松,零膨胀泊松和有限混合Poisson模型分析