{"id":2249,"date":"2023-03-24T14:41:47","date_gmt":"2023-03-24T13:41:47","guid":{"rendered":"https:\/\/labodemaths.fr\/WordPress3\/?p=2249"},"modified":"2023-03-27T09:29:03","modified_gmt":"2023-03-27T07:29:03","slug":"nsi-tp-entrainement","status":"publish","type":"post","link":"https:\/\/labodemaths.fr\/WordPress3\/nsi-tp-entrainement\/","title":{"rendered":"NSI, tp entrainement"},"content":{"rendered":"\n<p>Compl\u00e9ter les 3 fonctions suivantes :<\/p>\n\n\n\n<p>def truc(chaine,carac):<br>\u00a0\u00bb&rsquo;<br>&gt;&gt;&gt;truc(\u00ab\u00a0chaine\u00a0\u00bb,\u00a0\u00bbc\u00a0\u00bb)<br>1<br>&gt;&gt;&gt;truc(\u00ab\u00a0chaine\u00a0\u00bb,\u00a0\u00bbm\u00a0\u00bb)<br>0<br>&gt;&gt;&gt;truc(\u00ab\u00a0carac\u00a0\u00bb,\u00a0\u00bba\u00a0\u00bb)<br>2<br>\u00a0\u00bb&rsquo;<\/p>\n\n\n\n<p>def truc2(chaine_bin):<br>\u00a0\u00bb&rsquo;<br>&gt;&gt;&gt;truc2(\u00ab\u00a010001101\u00a0\u00bb)<br>\u00ab\u00a001110010\u00a0\u00bb<br>&gt;&gt;&gt;truc2(\u00ab\u00a0010101\u00a0\u00bb)<br>\u00ab\u00a0101010\u00a0\u00bb<br>\u00a0\u00bb&rsquo;<\/p>\n\n\n\n<p>def truc3(chaine_bin):<br>\u00a0\u00bb&rsquo;<br>&gt;&gt;&gt;truc3(\u00ab\u00a010001101\u00a0\u00bb)<br>\u00ab\u00a000001111\u00a0\u00bb<br>&gt;&gt;&gt;truc3(\u00ab\u00a0101010\u00a0\u00bb)<br>\u00ab\u00a0000111\u00a0\u00bb<br>\u00a0\u00bb&rsquo;<\/p>\n\n\n\n<h2 class=\"has-vivid-cyan-blue-color has-luminous-vivid-amber-background-color has-text-color has-background\">Proposition correction :<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>def truc(chaine,carac):\n    compteur=0\n    for lettre in chaine:\n        if lettre==carac:\n            compteur+=1\n    return compteur\n\n    \ndef truc2(chaine_bin):\n    chaine_retour=\"\"\n    for carac in chaine_bin:\n        if carac==\"1\":\n            chaine_retour+=\"0\"\n        else :\n            chaine_retour+=\"1\"\n    return chaine_retour\n    \ndef truc3(chaine_bin):\r\n    retour=\"\"\r\n    # on ajoute des 0 autant de fois que n\u00e9cessaire\r\n    for i in range(truc(chaine_bin,\"0\")):\r\n        retour=retour+\"0\"\r\n    for i in range(truc(chaine_bin,\"1\")):\r\n        retour=retour+\"1\"\r\n    return retour\r\n\r\ndef truc3_bis(chaine_bin):\r\n    retour=\"\"\r\n    for carac in chaine_bin:\r\n        if carac==\"0\":\r\n            retour=carac+retour\r\n        else:\r\n            retour=retour+carac\r\n    return retour\r\n\r\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Compl\u00e9ter les 3 fonctions suivantes : def truc(chaine,carac):\u00a0\u00bb&rsquo;&gt;&gt;&gt;truc(\u00ab\u00a0chaine\u00a0\u00bb,\u00a0\u00bbc\u00a0\u00bb)1&gt;&gt;&gt;truc(\u00ab\u00a0chaine\u00a0\u00bb,\u00a0\u00bbm\u00a0\u00bb)0&gt;&gt;&gt;truc(\u00ab\u00a0carac\u00a0\u00bb,\u00a0\u00bba\u00a0\u00bb)2\u00a0\u00bb&rsquo; def truc2(chaine_bin):\u00a0\u00bb&rsquo;&gt;&gt;&gt;truc2(\u00ab\u00a010001101\u00a0\u00bb)\u00ab\u00a001110010\u00a0\u00bb&gt;&gt;&gt;truc2(\u00ab\u00a0010101\u00a0\u00bb)\u00ab\u00a0101010\u00a0\u00bb\u00a0\u00bb&rsquo; def truc3(chaine_bin):\u00a0\u00bb&rsquo;&gt;&gt;&gt;truc3(\u00ab\u00a010001101\u00a0\u00bb)\u00ab\u00a000001111\u00a0\u00bb&gt;&gt;&gt;truc3(\u00ab\u00a0101010\u00a0\u00bb)\u00ab\u00a0000111\u00a0\u00bb\u00a0\u00bb&rsquo; Proposition correction :<\/p>\n","protected":false},"author":2,"featured_media":1956,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[57],"tags":[],"_links":{"self":[{"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts\/2249"}],"collection":[{"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/comments?post=2249"}],"version-history":[{"count":3,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts\/2249\/revisions"}],"predecessor-version":[{"id":2255,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts\/2249\/revisions\/2255"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/media\/1956"}],"wp:attachment":[{"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/media?parent=2249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/categories?post=2249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/tags?post=2249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}