{"id":853,"date":"2021-10-20T13:40:28","date_gmt":"2021-10-20T13:40:28","guid":{"rendered":"https:\/\/es-andreabianchini.it\/andrewsblog\/?p=853"},"modified":"2021-10-22T05:24:16","modified_gmt":"2021-10-22T05:24:16","slug":"profmi","status":"publish","type":"post","link":"https:\/\/es-andreabianchini.it\/andrewsblog\/?p=853","title":{"rendered":"profMI"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code># profMI.py\n#\n# \n# Il professor MII insegna in una classe universitaria formata da\n# ragazzi e ragazze. Viene fornita una lista contenente una lista \n# per ogni studente. Il primo numero della lista \u00e8 l'idendificativo\n# dello studente, il secondo numero della lista rappresenta il sesso;\n# (0=MASCHIO,1=FEMMINA,2=LGBT). I restanti numeri indicano i voti\n# conseguiti per quello studente.\n# Il programma determina la media dei voti per genere sessuale.\n#\n# by Andrea Bianchini (2021)\n\nfrom random import randint\n\nN = 50\nMIN = 18\nMAX = 31\nNVOTI = 5\n\n#generazione casuale lista dei voti:\ncl=&#91;]\nfor i in range(N):\n    student=&#91;]\n    student.append(i)\n    student.append(randint(0,2))\n    for j in range(NVOTI):\n        student.append(randint(MIN,MAX))\n    cl.append(student)\n                   \n#calcolo\nmediatot=&#91;0.0,0.0,0.0]\nng=&#91;0,0,0]\nfor i in range(N):\n    medias=&#91;0.0,0.0,0.0]\n    student=cl&#91;i]\n    sex = student&#91;1]\n    ng&#91;sex]+=1\n    for j in range(NVOTI):\n        medias&#91;sex]+=float(student&#91;2+j])\n    medias&#91;sex]\/=float(NVOTI)\n    mediatot&#91;sex]+=medias&#91;sex]\n\nmediatot&#91;0]\/=float(ng&#91;0])\nmediatot&#91;1]\/=float(ng&#91;1])\nmediatot&#91;2]\/=float(ng&#91;2])\n\nprint(\"Lista studenti = \", cl)\nprint()\nprint(\"Media voti maschi = %.2f\" %mediatot&#91;0])\nprint(\"Media voti femmine = %.2f\" %mediatot&#91;1])\nprint(\"Media voti LGBT = %.2f\" %mediatot&#91;2])<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Esempio:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Lista studenti =  &#91;&#91;0, 0, 23, 23, 22, 24, 28], &#91;1, 0, 22, 18, 18, 24, 28], &#91;2, 0, 30, 25, 28, 21, 25], &#91;3, 1, 23, 18, 23, 24, 30], &#91;4, 0, 23, 19, 23, 25, 30], &#91;5, 0, 19, 24, 30, 29, 26], &#91;6, 1, 19, 21, 21, 20, 22], &#91;7, 1, 27, 30, 18, 26, 20], &#91;8, 1, 30, 24, 29, 21, 23], &#91;9, 2, 31, 19, 27, 30, 25], &#91;10, 2, 31, 27, 21, 31, 22], &#91;11, 1, 19, 25, 19, 31, 20], &#91;12, 2, 29, 24, 24, 26, 29], &#91;13, 0, 26, 23, 25, 26, 29], &#91;14, 0, 25, 29, 23, 21, 29], &#91;15, 0, 19, 28, 22, 20, 29], &#91;16, 1, 28, 21, 24, 22, 18], &#91;17, 2, 19, 22, 27, 25, 22], &#91;18, 1, 31, 22, 18, 27, 20], &#91;19, 2, 21, 25, 25, 19, 23], &#91;20, 2, 27, 23, 30, 25, 21], &#91;21, 1, 26, 29, 23, 30, 30], &#91;22, 1, 29, 22, 18, 30, 26], &#91;23, 0, 23, 30, 28, 20, 19], &#91;24, 1, 27, 29, 28, 19, 29], &#91;25, 0, 25, 27, 22, 24, 31], &#91;26, 1, 30, 26, 28, 26, 28], &#91;27, 0, 18, 22, 30, 27, 26], &#91;28, 1, 27, 18, 25, 24, 18], &#91;29, 0, 31, 23, 24, 21, 30], &#91;30, 2, 30, 28, 19, 24, 25], &#91;31, 2, 23, 22, 23, 22, 19], &#91;32, 2, 29, 31, 30, 25, 29], &#91;33, 1, 30, 21, 29, 20, 23], &#91;34, 1, 21, 26, 27, 23, 18], &#91;35, 1, 29, 25, 20, 29, 25], &#91;36, 2, 18, 21, 20, 22, 31], &#91;37, 1, 30, 20, 19, 26, 20], &#91;38, 0, 26, 19, 22, 22, 19], &#91;39, 0, 31, 27, 19, 29, 18], &#91;40, 2, 26, 26, 23, 24, 21], &#91;41, 2, 28, 26, 23, 22, 25], &#91;42, 2, 29, 27, 29, 25, 24], &#91;43, 1, 29, 21, 18, 31, 29], &#91;44, 1, 24, 22, 20, 31, 21], &#91;45, 1, 20, 21, 30, 28, 23], &#91;46, 0, 26, 24, 29, 26, 23], &#91;47, 1, 22, 26, 26, 31, 26], &#91;48, 2, 18, 23, 25, 23, 21], &#91;49, 0, 18, 22, 26, 23, 23]]\n\nMedia voti maschi = 24.43\nMedia voti femmine = 24.39\nMedia voti LGBT = 24.70\n&gt;&gt;&gt; <\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Esempio:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,7],"tags":[],"class_list":["post-853","post","type-post","status-publish","format-standard","hentry","category-python","category-stem"],"_links":{"self":[{"href":"https:\/\/es-andreabianchini.it\/andrewsblog\/index.php?rest_route=\/wp\/v2\/posts\/853","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/es-andreabianchini.it\/andrewsblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/es-andreabianchini.it\/andrewsblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/es-andreabianchini.it\/andrewsblog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/es-andreabianchini.it\/andrewsblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=853"}],"version-history":[{"count":2,"href":"https:\/\/es-andreabianchini.it\/andrewsblog\/index.php?rest_route=\/wp\/v2\/posts\/853\/revisions"}],"predecessor-version":[{"id":855,"href":"https:\/\/es-andreabianchini.it\/andrewsblog\/index.php?rest_route=\/wp\/v2\/posts\/853\/revisions\/855"}],"wp:attachment":[{"href":"https:\/\/es-andreabianchini.it\/andrewsblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/es-andreabianchini.it\/andrewsblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/es-andreabianchini.it\/andrewsblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}