标签:str port 打印 orm 个数 and sum range NPU
import random num1 = random.randint(1, 5) print(num1) # 显示随机数 num2 = int(input(‘please the input digital:‘)) if num2 > num1: print(‘bigger‘) elif num2 < num1: print(‘less‘) else: print(‘equal‘)
count = 0 for i in range(1, 100): num = str(i) if ‘9‘ in num: i = int(num) print(i, end=‘ ‘) count += 1 print() print(‘共有{}个数‘.format(count))
count = 0 s = set() # 集合,为了去除重复项 for i in range(1, 100): if i < 10: num = str(i) if ‘9‘ in num: count += 1 num1 = int(num) s.add(num1) else: num = str(i) if num[0] == ‘9‘: count += 1 num1 = int(num) s.add(num1) if num[1] == ‘9‘: count += 1 num1 = int(num) s.add(num1) li = list(s) li.sort() print(li) print(‘出现的次数共{}次‘.format(count))
for i in range(1, 10): for j in range(1, i + 1): m = i * j print(‘{} * {} = {}‘.format(j, i, m), end=‘ ‘) print()
li = [] for i in range(1, 5): i = str(i) for a in range(1, 5): a = str(a) s = i + a if i == a: continue for b in range(1, 5): b = str(b) if i == a or i == b or a == b: continue if len(s + b) == 3: sum = s + b sum = int(sum) li.append(sum) print(‘互不相同且无重复数字的三位数个数为{}‘ .format(len(li))) print(li)
标签:str port 打印 orm 个数 and sum range NPU
原文地址:https://www.cnblogs.com/lin961234478/p/10678523.html