Pythonで計算して合計の割合を作成したいです
Q&A
Closed
解決したいこと
aからa4まで合計と平均値と割合
dかd4まで合計と平均値と割合
fからf4までまで合計と平均値と割合
の計算をしたいです
a~a4の合計(d,fも同様)
a系統の合計とd系統の合計とf系統の合計
をすべて足して全体の数字を出してa系統の割合が何%、d系統の割合が何%、f系統の割合が何%と出したいです
下記のサイト参考にしましたができなかったので協力お願いします
発生している問題・エラー
出ているエラーメッセージを入力
例)
NameError (uninitialized constant World)
または、問題・エラーが起きている画像をここにドラッグアンドドロップ
該当するソースコード
import statistics
import matplotlib.pyplot as plt
import numpy as np
a = [108,223,100,89,298,73,98,108,109,356,154,487,88,98,158,341,367,1320,84,1419,320,198,235,278,250,193,100,105,299,405,383,290,656,230,355,61,550,73,88,613,390,100,270,790]
d = [200,300,326,218,700,780,500,95,96,699,410,100,323,88,504,106,323,350,68,110,224,1309,128,59]
f = [224,2500,298,276,90,88,600,103,73,63,100,1257,96,213,540,451,680,100,327,221,1540,1080,65,321,1837,71,257,2268,600,272,100,90,100,1122,254,91,908,74,182,165,91,53,6160,97,6050]
a1 = [106,108,169,99,127,165,200,224,500,362,267,1106,95,170,105,850,99,2550,122,1210,180,370,108,200,200,1475,238,88,88,179,200,1680]
d1 = [78,1210,98,48,84,376,224,1080,393,280,370,264,339,454,3900,95,96,355,1200,305,450,5500,3960,650,149,1089,2990,600,600,2480,800,91,179,302,224,270,207,1070,404,100,108,200,650,110,650]
f1 = [196,82,82,99,908,285,158,744,254,3220,213,2286,644,1092,213,149,20790,827,52,451,1200,300,100,100,69,14760,98,73,100,73]
a2 = [211,1458,160,100,492,105,200,330,217,370,810,308,280,84,500,119,128,91,73,95,235,158]
d2 = [1115,1036,622,105]
f2 = [78,149,425,105,1345,149,1008,299,102,406,1481,147,85,190,105,230,149,2990,73,908]
a3 = [202,127,805,810,95,334,100,300,278,270,322,146,105,216,146,594,105,788,860,500,150,100,116,118,990,883,1210,767,100,500,90,680,1298,73,100,100,140]
d3 = [110,1560,63,84,63,300,300,164.984,116,548,370,116]
f3 = [149,1170,394,198,401,297,1458,210,524,1409,427,1210,432,738,199,276]
a3 = [410,507,300,259,105,108,518,280,380,130,470,1800,370,200,170,559,237,522,369,360,216]
d3 = [110,224,100,108,820,278,267,63,73,339,320,84,1976,91,75,98,224,397,266,224,976,331,248,267,105,438,192,470,127,600,1150]
f3 = [980,149,548,734,181,300,267,149,367,1048,105,3000,99,630,63,322,481,665,860,84,341]
a4 = [209,470,214,104,420,160,2040,180,397,162,1580,319,291,110,436,1320,104,97,261,95,235,235]
d4 = [106,289,719,415,373,581,200,697,352,110,380,132,2029]
f4 = [298,2497,642,1431,149,385,110,482,330,1100,804,980,981,562,170,373,181,382]
# print("合計",sum(a),)
# print("合計",sum(d),)
# print("合計",sum(f),)
自分で試したこと
ここに問題・エラーに対して試したことを記載してください。
一つずつ計算すると手間だと思ったのでまとめて計算しようと思いました
https://www.sejuku.net/blog/74185
https://www.choge-blog.com/programming/pythontwodimensionallistgetsum/
https://udemy.benesse.co.jp/data-science/data-analysis/python-graph.html