import time date = time.localtime() print(date) #time.struct_time(tm_year=2018, tm_mon=2, tm_mday=24, tm_hour=19, tm_min=42, tm_sec=57, tm_wday=5, tm_yday=55, tm_isdst=0) year = date[0] month = date[1] day = date[2] day_month = [31, 28, 31, 30, 31, 3…
Python小代码_2_格式化输出 name = input("name:") age = input("age:") job = input("job:") salary = input("salary:") msg = ''' --------- info of %s --------- Name: %s Age: %s Job: %s Salary: %s --------- end --------- ''' % (n…
Python小代码_1_九九乘法表 max_num = 9 row = 1 while row <= max_num: col = 1 while col <= row: print(str(col) + "*" + str(row) + "=" + str(col*row), end="\t") col += 1 row += 1 print()…
menu = { "北京": { "朝阳区": { "三环到四环之间": {}, "四环到五环之间": {}, "五环到六环之间": {}, "管庄": {}, "北苑": {}, "定福庄": {}, "三环以内": {}, }, "海淀区": { "三环以内": {}, "三…
a = 4 b = 5 #第一种 c = a a = b b = c print(a, b) #输出结果 #5 4 #第二种 a = a + b b = a - b a = a - b print(a, b) #输出结果 #5 4 #第三种 a, b = b, a print(a, b) #输出结果 #5 4…
def demo(m, n): if m > n: m, n = n, m p = m * n while m != 0: r = n % m n = m m = r return (int(p / n), n) val = demo(20, 30) print('最小公倍数为:', val[0]) print('最大公因数为:', val[1]) #输出结果 #最小公倍数为: 60 #最大公因数为: 10…
def demo(t): print([1]) print([1, 1]) line = [1, 1] for i in range(2, t): r = [] for j in range(0, len(line) - 1): r.append(line[j] + line[j + 1]) line = [1] + r + [1] print(line) demo(10) #输出结果 ''' [1] [1, 1] [1, 2, 1] [1, 3, 3, 1] [1, 4, 6, 4, 1] […
def fib(n): a, b = 1, 1 while a < n: print(a, end=' ') a, b = b, a + b fib(100000) #输出结果 #1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025…
import math n = int(input('Input an integer:')) m = int(math.sqrt(n) + 1) for i in range(2, m): if n % i == 0: print('No') break else: print('Yes') #输出结果 #Input an integer:23 #Yes…
for i in range(100, 1000): ge = i % 10 shi = i // 10 % 10 bai = i // 100 if ge ** 3 + shi ** 3 + bai ** 3 == i: print(i, end=' ') #输出结果 #153 370 371 407…