随笔分类 - python
摘要:import turtle as t t.speed(0) t.color('red') t.begin_fill() t.circle(100) t.end_fill() t.penup() t.goto(0, 20) t.pendown() t.color('white') t.begin_fi
阅读全文
摘要:# 单词默写小程序。import easygui as equestions = ["局部", "野怪", "重复", "添加", "动画"]answers = ["local", "monster", "repeat", "append", "animation"]# 计算列表questions的
阅读全文
摘要:【问题描述】 1. 人的智商一般用IQ来表示,等级划分如下: ① 天才:140以上 ② 超常:130-139 ③ 优秀:120-129 ④ 中上、聪慧:110-119 ⑤ 中等:90-109 ⑥ 中下:80-89 ⑦ 临界智能不足:70-79 ⑧ 智力缺陷:70以下 2. 智商的测算公式:IQ(智商
阅读全文
摘要:pip install virtualenv -i https://pypi.tuna.tsinghua.edu.cn/simple 2. virtualenv DksVenv 3. 激活虚拟环境:activate 4. 关闭虚拟环境:deactivate 4.1 更新pip包:pip instal
阅读全文
摘要:代码示例 string = input() # 30,99,28,200,10 list_1 = string.split(",") len = len(list_1) # 输出输入的数字。 for i in range(0, len-1): print(list_1[i], end=",") pr
阅读全文
摘要:sum = 0for i in range(310000, 320000): if i // 10000 == 31 and i % 100 // 10 == i % 10 and i % 16 == 0 and i % 46 == 0: print(i) sum += 1print(sum)
阅读全文
摘要:输入两个整数,分别作为分子和分母,输出最简分数。要求:如果最简分式的分母为1,则输出整数,即分子。样例: 输入1: 30 45 输出1: 2/3 输入2: 81 9 输出2: 9 str = input().split(" ")fen_zi = eval(str[0])fen_mu = eval(s
阅读全文
摘要:考察知识点:(难度☆☆) 循环和分支语句的综合使用. 代码示例: m = input()list = m.split(",")total = 0for i in range(0, int(len(list))-1): a = int(list[i]) b = int(list[i+1]) if a
阅读全文
摘要:from turtle import * hideturtle() for i in range(12): color("red") circle(120, 30) color("yellow") begin_fill() right(60) fd(80) right(60) fd(80) righ
阅读全文
摘要:# 输出单词在文章中首次出现时该单词的首字母的位置(下标)和单词出现的频率。(只考虑空格和英文字符) word = input().lower() text = input().lower() string = "" index = -1 number = 0 first_word = True f
阅读全文
摘要:# ① 导入turtle模块并重命名为t。import turtle as ti = 1while i <= 5: # ② forward()/fd(): 前进;返回None。 t.forward(100) # ③ backward()/back()/bk(): 后退;返回None。 # t.bac
阅读全文
摘要:# python模拟桶排序。def bucketSort(li): max_num = max(li) # 定义列表bucket并初始化为0。 bucket = [0] * (max_num + 1) # 待排序的元素设为桶的下标,统计每个元素出现的次数作为桶元素。 for i in li: buc
阅读全文
摘要:# 冒泡排序aList = [90, 88, 78, 98, 67, 56, 80, 20]print("比较前:", aList)# 比较len(aList)-1趟。for j in range(0, len(aList)-1): # 比较一趟(len(aList)-1次) for i in ra
阅读全文
摘要:"""(中难度)有n栈灯全部打开,n个人来关灯,第1个人关闭是1的倍数的灯,第2个人关闭是2的倍数的灯,第3个人关闭是3的倍数的灯,以此类推,最后哪些灯是关闭的(哪些灯是打开的?)。"""n = int(input("请输入灯盏的数量:"))light = list()# 第一个元素忽略不计(从下标
阅读全文
摘要:import pygame# 导入事件和键名.from pygame.locals import *# 设置窗口(尺寸和背景图片宽高保持一致).canvas = pygame.display.set_mode((1050, 660))# 修改窗口的标题.pygame.display.set_capt
阅读全文