本文整理汇总了Python中fractions.Fraction.add方法的典型用法代码示例。如果您正苦于以下问题:Python Fraction.add方法的具体用法?Python Fraction.add怎么用?Python Fraction.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fractions.Fraction
的用法示例。
在下文中一共展示了Fraction.add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from fractions import Fraction [as 别名]
# 或者: from fractions.Fraction import add [as 别名]
print(x)
print(y)
print(x - y) # Difference
print(x | y) # Union
print(x & y) # Intersection
print(x ^ y) # Symmetric difference
print(x > y, x < y) # Superset, subset
print('e' in x) # Membership
print('e' in 'Camelot', 22 in [11, 22, 33]) # Works with other types as well
z = x.intersection(y) # Same as x & y
print(z)
z.add('SPAM') # Insert one item
print(z)
z.update({'X', 'Y'}) # Merge: in-place union
print(z)
z.remove('b') # Delete one item
print(z)
for item in set('abc'):
print(item * 3)
S = set([1, 2, 3])
print(S | set([3, 4])) # Expressions require both to be sets
# print(S | [3, 4])
print(S.union([3, 4])) # But their methods allow any iterable
print(S.intersection((1, 3, 5)))
print(S.issubset(range(-5, 5)))