摘要:
from random import shuffle color = ['1', '2', '3', '4', '5'] shuffle(color) print(color) 阅读全文
posted @ 2018-11-15 21:23
anobscureretreat
阅读(978)
评论(0)
推荐(0)
摘要:
#Initialize a complex number cn = complex(2,3) print("Complex Number: ",cn) print("Complex Number - Real part: ",cn.real) print("Complex Number - Imaginary part: ",cn.imag) 阅读全文
posted @ 2018-11-15 21:16
anobscureretreat
阅读(13307)
评论(0)
推荐(0)
摘要:
import random print(random.choice('abcdefghijklm')) 阅读全文
posted @ 2018-11-15 21:13
anobscureretreat
阅读(3147)
评论(0)
推荐(0)
摘要:
import random nums = [1, 2, 3, 4, 5, 6, 7] random.shuffle(nums) print(nums) 阅读全文
posted @ 2018-11-15 21:10
anobscureretreat
阅读(7263)
评论(0)
推荐(0)
摘要:
from fractions import Fraction value = 4.2 print(Fraction(value).limit_denominator()) 阅读全文
posted @ 2018-11-15 21:07
anobscureretreat
阅读(1674)
评论(0)
推荐(0)
摘要:
import math print(math.fabs(-2.1)) print(math.fabs(-0.0)) print(math.fabs(10.1)) print(math.fabs(0.0)) 阅读全文
posted @ 2018-11-15 21:03
anobscureretreat
阅读(1952)
评论(0)
推荐(0)
摘要:
print("Addition of two complex numbers : ",(4+3j)+(3-7j)) print("Subtraction of two complex numbers : ",(4+3j)-(3-7j)) print("Multiplication of two complex numbers : ",(4+3j)*(3-7j)) print("D... 阅读全文
posted @ 2018-11-15 21:01
anobscureretreat
阅读(818)
评论(0)
推荐(0)
摘要:
import fractions f1 = fractions.Fraction(2, 3) f2 = fractions.Fraction(3, 7) print('{} + {} = {}'.format(f1, f2, f1 + f2)) print('{} - {} = {}'.format(f1, f2, f1 - f2)) print('{} * ... 阅读全文
posted @ 2018-11-15 20:59
anobscureretreat
阅读(732)
评论(0)
推荐(0)
摘要:
def is_Power_of_three(n): while (n % 3 == 0): n /= 3; return n == 1; print(is_Power_of_three(9)) print(is_Power_of_three(81)) print(is_Power_of_three(21)) ... 阅读全文
posted @ 2018-11-15 10:27
anobscureretreat
阅读(816)
评论(2)
推荐(0)
摘要:
def is_Power_of_four(n): while n and not (n & 0b11): n >>= 2 return (n == 1) print(is_Power_of_four(4)) print(is_Power_of_four(16)) print(is_Power_of_four(255)) 阅读全文
posted @ 2018-11-15 10:23
anobscureretreat
阅读(816)
评论(0)
推荐(0)
摘要:
def is_arithmetic(l): delta = l[1] - l[0] for index in range(len(l) - 1): if not (l[index + 1] - l[index] == delta): return False return True print(i... 阅读全文
posted @ 2018-11-15 10:20
anobscureretreat
阅读(3827)
评论(0)
推荐(0)
摘要:
def is_geometric(li): if len(li) <= 1: return True # Calculate ratio ratio = li[1]/float(li[0]) # Check the ratio of the remaining for i in range(1, len(li))... 阅读全文
posted @ 2018-11-15 10:15
anobscureretreat
阅读(2397)
评论(0)
推荐(0)
摘要:
def add_binary_nums(x,y): max_len = max(len(x), len(y)) x = x.zfill(max_len) y = y.zfill(max_len) result = '' carry = 0 for i in... 阅读全文
posted @ 2018-11-15 10:06
anobscureretreat
阅读(2813)
评论(0)
推荐(0)

浙公网安备 33010602011771号