{"id":220,"date":"2026-01-15T08:22:57","date_gmt":"2026-01-15T07:22:57","guid":{"rendered":"https:\/\/yb-isn.fr\/2025\/nsi\/?p=220"},"modified":"2026-01-20T14:39:12","modified_gmt":"2026-01-20T13:39:12","slug":"plafond-nuageux-corrige","status":"publish","type":"post","link":"https:\/\/yb-isn.fr\/2025\/nsi\/2026\/01\/15\/plafond-nuageux-corrige\/","title":{"rendered":"23-Fonctions, assertions et docstring en Python"},"content":{"rendered":"<p><!--more--><\/p>\n\n\n<p class=\"wp-block-paragraph\">Calculer et afficher  la hauteur du plafond nuageux \u00e0 partir de la temp\u00e9rature et du taux d&rsquo;humidit\u00e9 dans une page web.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/fr.wikipedia.org\/wiki\/Base_d%27un_nuage\">base d&rsquo;un nuage<\/a>        <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/fr.wikipedia.org\/wiki\/Point_de_ros%C3%A9e\">point de ros\u00e9e<\/a>       <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.w3schools.com\/js\/js_math.asp\">math-javascript<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"http:\/\/www.python-simple.com\/python-modules-math\/fonctions-mathematiques.php\" target=\"_blank\" rel=\"noreferrer noopener\">math-python<\/a><\/p>\n\n\n\n<p class=\"has-black-color has-text-color has-background has-link-color wp-elements-b683c465c67120c2d00f962a5bc8cc6a wp-block-paragraph\" style=\"background:linear-gradient(135deg,rgb(216,244,179) 0%,rgb(17,184,81) 100%)\">1) <strong>R\u00e9solution<\/strong> : python<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Commencez&nbsp; par coder la m\u00e9thode de calcul en python \u00e0 l&rsquo;aide d&rsquo;une fonction.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Nous allons ensuite&nbsp; documenter cette fonction .Un programme peu ou mal document\u00e9 est difficile \u00e0 corriger, modifier et r\u00e9utiliser. Il est donc important de documenter , commenter son code. Vous connaissez d\u00e9j\u00e0 les commentaires classiques (en utilisant le caract\u00e8re di\u00e8se <strong><span style=\"color: #008000;\">#<\/span><\/strong><span style=\"color: #008000;\"> ) .<span style=\"color: #000000;\">On peut aller plus loin avec :<\/span><\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>l&rsquo;affichage des types<\/li>\n\n\n\n<li>la documentation docstring<\/li>\n\n\n\n<li>On peut ajouter des assertions<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/capytale2.ac-paris.fr\/web\/c\/ecb8-2888969\">https:\/\/capytale2.ac-paris.fr\/web\/c\/ecb8-2888969<\/a><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import math\n\ndef plafondNuageux(tpre:float,tH:float)->tuple:\n    \n  \"\"\"\n  Calcul de la hauteur du plafond nuageux:\n  La temperature doit \u00eatre en \u00b0C et tH. \n  l'humidit\u00e9 relative est comprise entre 0 et 100\n  la fonction renvoi un tuple contenant la temperature de ros\u00e9e puis le plafond nuageux.\n\n  Args:\n    arg1 (float): temp\u00e9rature en \u00b0C\n    arg2 (float): tau d'humidit\u00e9 en %\n\n  Returns:\n    tuple: Temp\u00e9rature de ros\u00e9e,hauteur du plafond nuageux\n  \"\"\"\n\n  assert tH>=0 and tH&lt;=100, \"tH n'est pas compris entre 0 et 100\" \n    \n  a=17.27\n  b=237.7\n    \n  alpha=((a*tpre)\/(b+tpre) +math.log(tH \/ 100))\n  t_rosee = (b* alpha) \/ (a-alpha)\n    \n  plafondNuage = 125 * (tpre -t_rosee)\n  \n  return t_rosee,plafondNuage<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"http:\/\/yb-isn.fr\/2022\/nsi\/wp-content\/uploads\/2023\/01\/fonction-doc.png\" alt=\"\" class=\"wp-image-349\"\/><\/figure>\n\n\n<!-- PDF Embedder: Please provide an \"URL\" attribute in your shortcode. -->\n\n<!-- PDF Embedder: Please provide an \"URL\" attribute in your shortcode. -->\n\n\n<p class=\"has-larger-font-size wp-block-paragraph\"><strong><a href=\"https:\/\/capytale2.ac-paris.fr\/web\/c\/ce86-9053968\">Exercices \u00e0 chercher<\/a><\/strong><\/p>\n\n\n\n<p class=\"has-larger-font-size wp-block-paragraph\"><strong><a href=\"https:\/\/capytale2.ac-paris.fr\/web\/c\/8191-9053900\" target=\"_blank\" rel=\"noreferrer noopener\">Corrig\u00e9s des exercices<\/a><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-220","post","type-post","status-publish","format-standard","hentry","category-non-classe"],"_links":{"self":[{"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/posts\/220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/comments?post=220"}],"version-history":[{"count":10,"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/posts\/220\/revisions"}],"predecessor-version":[{"id":253,"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/posts\/220\/revisions\/253"}],"wp:attachment":[{"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/media?parent=220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/categories?post=220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/tags?post=220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}