当前位置: 首页 > wzjs >正文

如何知道网站用什么程序做的做音乐网站建设的开发平台

如何知道网站用什么程序做的,做音乐网站建设的开发平台,自己做开奖网站,湖南住建云目的 :熟练操作组合数据类型。 试验任务: 1. 基础:生日悖论分析。 如果一个房间有23 人或以上,那么至少有两个人的生日相同的概率大于50%。编写程序,输出在不同随机样本数量下,23 个人中至少两个人生日相…

目的 :熟练操作组合数据类型。
试验任务:

1. 基础:生日悖论分析。

如果一个房间有23 人或以上,那么至少有两个人的生日相同的概率大于50%。编写程序,输出在不同随机样本数量下,23 个人中至少两个人生日相同的概率。

import random
import matplotlib.pyplot as pltdef birthday_paradox_simulation(num_people, num_simulations):"""模拟生日悖论"""count = 0for _ in range(num_simulations):birthdays = [random.randint(1, 365) for _ in range(num_people)]if len(birthdays) != len(set(birthdays)):count += 1return count / num_simulationsdef analyze_birthday_paradox():"""分析生日悖论"""num_people = 23simulation_sizes = [100, 1000, 5000, 10000, 50000, 100000]probabilities = []print("生日悖论分析 (23人):")print("模拟次数\t概率")for size in simulation_sizes:prob = birthday_paradox_simulation(num_people, size)probabilities.append(prob)print(f"{size}\t\t{prob:.4f}")# 绘制结果plt.figure(figsize=(10, 6))plt.plot(simulation_sizes, probabilities, marker='o')plt.axhline(y=0.5, color='r', linestyle='--', label='50%概率线')plt.xscale('log')plt.xlabel('模拟次数(对数尺度)')plt.ylabel('概率')plt.title('23人中至少两人生日相同的概率随模拟次数的变化')plt.legend()plt.grid(True)plt.show()# 运行生日悖论分析
analyze_birthday_paradox()

2. 进阶:统计《一句顶一万句》文本中前10 高频词,生成词云。

# coding:utf-8
import jieba
from collections import Counter
from wordcloud import WordCloud
import matplotlib.pyplot as pltdef process_text_and_generate_wordcloud():"""处理文本并生成词云"""# 请将文本文件放在同一目录下,文件名为"yiju.txt"try:with open("yiju.txt", "r", encoding="utf-8") as f:text = f.read()except FileNotFoundError:print("未找到文本文件'yiju.txt',请将文件放在同一目录下")return# 使用jieba分词words = jieba.lcut(text)# 去除停用词和单字with open("stopwords.txt", "r", encoding="utf-8") as f:stopwords = set([line.strip() for line in f])filtered_words = [word for word in words if len(word) > 1 and word not in stopwords]# 统计词频word_counts = Counter(filtered_words)top10_words = word_counts.most_common(10)print("《一句顶一万句》前10高频词:")for word, count in top10_words:print(f"{word}: {count}次")# 生成词云wc = WordCloud(font_path="C:/Windows/Fonts/simhei.ttf",  # 使用黑体,请确保字体文件存在background_color="white",max_words=200,width=800,height=600)wc.generate_from_frequencies(word_counts)plt.figure(figsize=(10, 8))plt.imshow(wc, interpolation="bilinear")plt.axis("off")plt.show()# 运行文本分析
process_text_and_generate_wordcloud()

3. 拓展:金庸、古龙等武侠小说写作风格分析。

输出不少于3 个金庸(古龙)作品的最常用10 个词语,找到其中的相关性,总结其风格。

import jieba
from collections import Counter
import matplotlib.pyplot as pltdef analyze_author_style(author_name, book_files):"""分析作者风格"""all_words = []for book_file in book_files:try:with open(book_file, "r", encoding="utf-8") as f:text = f.read()words = jieba.lcut(text)all_words.extend(words)except FileNotFoundError:print(f"未找到文件: {book_file}")continue# 去除停用词和单字with open("stopwords.txt", "r", encoding="utf-8") as f:stopwords = set([line.strip() for line in f])filtered_words = [word for word in all_words if len(word) > 1 and word not in stopwords]# 统计词频word_counts = Counter(filtered_words)top10_words = word_counts.most_common(10)print(f"\n{author_name}作品中最常用的10个词语:")for word, count in top10_words:print(f"{word}: {count}次")return dict(top10_words)def compare_authors_styles():"""比较金庸和古龙的写作风格"""# 假设有这些文本文件,实际使用时请替换为真实文件路径jin_yong_books = ["shediao.txt", "tlbb.txt", "tianlong.txt"]gu_long_books = ["xiaoli.txt", "chulai.txt", "liuxing.txt"]# 分析金庸风格jin_yong_words = analyze_author_style("金庸", jin_yong_books)# 分析古龙风格gu_long_words = analyze_author_style("古龙", gu_long_books)# 找出共同高频词common_words = set(jin_yong_words.keys()) & set(gu_long_words.keys())print("\n两位作家共同的高频词:", common_words)# 找出各自独特的高频词jin_yong_unique = set(jin_yong_words.keys()) - set(gu_long_words.keys())gu_long_unique = set(gu_long_words.keys()) - set(jin_yong_words.keys())print("\n金庸独特的高频词:", jin_yong_unique)print("古龙独特的高频词:", gu_long_unique)# 简单风格分析print("\n风格分析:")print("1. 金庸的作品更常使用:", [word for word in jin_yong_unique if word in jin_yong_words][:3])print("2. 古龙的作品更常使用:", [word for word in gu_long_unique if word in gu_long_words][:3])print("3. 两位作家都常用的词:", list(common_words)[:3])# 运行风格分析
compare_authors_styles()

http://www.dtcms.com/wzjs/809414.html

相关文章:

  • 中国比较好的设计网站wordpress图片浏览器
  • 建一个图片类网站需要多少钱织梦多网站
  • 网站建设公司的小程序选择什么做网站还能挣钱
  • 南充网站制作湖南在建工程查询
  • ovz的vps怎么做网站定制网站哪个好
  • 自助建站是什么意思海口网站制作价格
  • 西安网站建设技术外包优书网怎么注册不了
  • 在哪买网站链接自己电脑做服务器网站吗
  • 做标签网站是干嘛的如何查网站注册信息
  • 快速搭建网站信息库企业展厅建筑
  • 大连网站开发 简维科技如何做公司的英文网站
  • wordpress 很好的博客针对百度关键词策划和seo的优化
  • 网站前台附近展览制作工厂
  • 政务网站建设建议查询域名是否注册
  • 网站名称可以更换吗分销系统价格多少
  • 企业网站一年多少钱三维动画设计制作公司
  • 软件做网站创办一家公司需要多少钱
  • 中国镇江网站拼多多关键词优化是怎么弄的
  • 廉政建设网站最新新闻国际新闻
  • 手机怎么建造网站网站网站服务器
  • 最大的搜索网站排名1网站免费建站
  • 资金盘网站开发公司哪里好免费建网站那个软件好
  • 观澜网站制作网站改版声明
  • 东营房地产网站建设建筑必看六个网站
  • 网站引导页分为三个板块设计风格营口市城乡住房建设局网站
  • 北京seo网站开发晋城网站建设公司排名
  • 徐州企业网站模板建站wordpress 停站
  • 我的世界查建筑网站建个好网站
  • 网站建设需要软件如何做盗版网站
  • 网站自适应手机代码排名前十的网页游戏