摘要:
from turtle import * def square(size=50, rgb='orange'): '''绘制正方形 参数size指定边长 参数rgb指定画笔颜色 如果没有给参数,采用默认值 ''' pencolor(rgb) for i in range(4): fd(size) le 阅读全文
摘要:
class User: count = 0 def __init__(self, name='guest', password=111111, status=1): User.count += 1 self.name = name self.password = password self.stat 阅读全文
摘要:
task1-1 task1-2 task1-3 task2-1 task2-2 task2-3 task2-4 task3 def is_valid(m): if len(m)==18 and m.isdigit(): return '合法' elif len(m)==18 and m[-1]==' 阅读全文
摘要:
task1 with open('data1_1.txt', 'r', encoding = 'utf-8') as f: data=f.readlines() n=0 for line in data: if line.strip('\n')=='': continue n +=1 print(f 阅读全文
摘要:
print(sum) sum = 42 print(sum) def inc(n): sum = n + 1 print(sum) return sum sum = inc(7) + inc(7) print(sum) question:task1.py源码中,共有4处有python语句print( 阅读全文
摘要:
import random print('用列表存储随机整数:')ls = [random.randint(1,100) for i in range(5)]print(ls) print('\n用集合存储随机整数:')s1 = {random.randint(1,100) for i in ran 阅读全文
摘要:
x = list(range(10)) print('整数输出1: ', end = '') for i in x: print(i, end=' ') print('\n整数输出2: ', end = '') for i in x: print(f'{i:02d}', end = '-') # 指 阅读全文