04 2023 档案
摘要:import jieba with open("qi.txt","r",encoding = "utf-8") as f: hua = f.read()word = jieba.cut(hua) count = {}for ci in word: if ci in count: count[ci]
阅读全文
摘要:{ "cells": [ { "cell_type": "markdown", "id": "3d99180e", "metadata": {}, "source": [ "## 画布知识\n" ] }, { "cell_type": "code", "execution_count": null,
阅读全文
摘要:# -*- coding: utf-8 -*-"""Created on Tue Apr 13 21:31:58 2021 @author: Administrator"""#coding=utf-8import turtlespiral=turtle.Turtle()ninja=turtle.Tu
阅读全文
摘要:#coding=utf-8import turtlepainter= turtle.Turtle()painter.pencolor("blue") for i in range(30): painter.forward(30) #数字是代表半径 painter.left(100) painter.
阅读全文
摘要:#北京奥运会吉祥录制import turtleturtle.title('冰墩墩')turtle.speed(40) # 可以自己调节速度# 左手turtle.penup()turtle.goto(177, 112)turtle.pencolor("lightgray")turtle.pensize
阅读全文
摘要:# -*- coding: utf-8 -*-"""Created on Tue Apr 13 21:31:12 2021 @author: Administrator"""#coding=utf-8import turtle#画五角星(动态)spiral=turtle.Turtle() for i
阅读全文
摘要:from turtle import *import time setup(800,600,0,0)speed(0)penup()seth(90)fd(340)seth(0)pendown() speed(5)begin_fill()fillcolor('red')circle(50,30) for
阅读全文
摘要:"""简单的计算器 这是一个简单的计算器,可以进行加、减、乘、除四种运算。 代码如下: """# 简单的计算器 # 加法def add(a, b): return a + b # 减法def sub(a, b): return a - b # 乘法def mul(a, b): return a *
阅读全文
摘要:# 学生成绩管理系统 # 定义学生信息元组student = ('name', 'age', 'gender', 'score') # 定义学生信息列表students = [] # 添加学生信息def add_student(): name = input("请输入学生姓名:") age = in
阅读全文
摘要:#一个有趣的元组应用案例是使用元组来模拟掷骰子游戏。在这个游戏中,玩家掷两个骰子并将它们的点数相加。#如果点数为985,则玩家A胜利;如果点数为211,则玩家B胜利;如果点数为其他数字,则玩家继续掷骰子。 #下面是一个使用元组来模拟掷骰子游戏的示例代码: import random def roll
阅读全文
摘要:#假设你是一名老师,你想要管理你班级学生的成绩。你可以使用Python的字典来记录每个学生的成绩。以下是一个简单的程序: # 创建一个空字典来存储学生成绩student_scores = {} # 添加学生成绩记录student_scores['张三'] = {'语文': 90, '数学': 80,
阅读全文
摘要:perators = {"+": lambda x, y: x + y, "-": lambda x, y: x - y, "*": lambda x, y: x * y, "/": lambda x, y: x / y} op = input("请输入运算符(+、-、*、/):")num1 = f
阅读全文
摘要:#假设你是一家水果店的老板,你想要统计每种水果的销售情况。你可以使用Python的字典来记录每种水果的销售数量和总销售额。以下是一个简单的程序: # 创建一个空字典来存储水果销售情况fruit_sales = {} # 添加销售记录fruit_sales['苹果'] = {'数量': 100, '总
阅读全文
摘要:text = input("请输入一段文本:")words = text.split()print(words)word_count = {} for word in words: if word in word_count: word_count[word] += 1 else: word_cou
阅读全文
摘要:""""这个程序可以读取一个文本文件,统计每个单词出现的次数,并按照出现次数从高到低排序。程序可以用字典来记录每个单词出现的次数。"""with open("text.txt", "r") as f: text = f.read() # 将文本分割成单词words = text.split() #
阅读全文
摘要:import random chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+-="length = int(input("请输入密码长度:")) password = ""for i
阅读全文
摘要:# 初始化英汉词典dictionary = { "apple": "苹果", "banana": "香蕉", "cherry": "樱桃", "orange": "橙子", "pear": "梨子"} # 获取用户输入word = input("请输入一个英文单词:") # 查找对应的中文翻译if
阅读全文