{"id":2516,"date":"2025-09-07T11:34:00","date_gmt":"2025-09-07T09:34:00","guid":{"rendered":"https:\/\/labodemaths.fr\/WordPress3\/?p=2516"},"modified":"2025-09-08T07:35:39","modified_gmt":"2025-09-08T05:35:39","slug":"nsi-tp-chaines-de-caracteres","status":"publish","type":"post","link":"https:\/\/labodemaths.fr\/WordPress3\/nsi-tp-chaines-de-caracteres\/","title":{"rendered":"NSI, 2025-2026,TP1 : cha\u00eenes de caract\u00e8res"},"content":{"rendered":"\n<div class=\"wp-block-file\"><a href=\"https:\/\/labodemaths.fr\/WordPress3\/wp-content\/uploads\/2024\/09\/NSI-lec\u0327on-les-chai\u0302nes-de-caracte\u0300res.pdf\">NSI-lec\u0327on-les-chai\u0302nes-de-caracte\u0300res<\/a><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code># les fonctions du tp\n\ndef parcourir_chaine_indice(texte):\n    for indice in range(len(texte)):\n        print(texte&#91;indice])\n        \ndef fonction1(texte):\n    retour=\"\"\n    for caract in texte:\n        retour=caract+retour\n    return retour\n\ndef fonction2(texte):\n    retour=0\n    for caract in texte:\n        retour+=1\n    return retour\n\ndef fonction3(n):\n    retour=\"\"\n    for i in range(n):\n        retour=retour+\"*\"\n    return retour\n\ndef fonction4(texte,caractere):\n    s=0\n    for carac in texte:\n        if carac==caractere:\n            s+=1\n    return s\n\nimport math\ndef est_premier(nombre):\n    if nombre==1:\n        return False\n    for diviseur in range(2, int(math.sqrt(nombre))+1):\n        if nombre%diviseur==0:\n            return False\n    return True\n\ndef liste_nombres_premier(n):\n    '''\n    retourne la liste des nombres premiers inf\u00e9rieurs\n    ou \u00e9gaux \u00e0 n\n    : entr\u00e9e : n : int\n    : sortie : str\n    &gt;&gt;&gt;&gt;&gt;&gt; liste_nombres_premier(11)\n    '2,3,5,7,11'\n    liste_nombres_premier(100)\n    '2,3,5,7,11,13,17,19,23,29,31,37,\n    41,43,47,53,59,61,67,71,73,79,83,89,97'\n    '''\n\n    \n<\/code><\/pre>\n\n\n\n<p>Proposition de correction pour la derni\u00e8re fonction :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Proposition de correction pour la derni\u00e8re fonction :<\/p>\n","protected":false},"author":2,"featured_media":2517,"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\/2516"}],"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=2516"}],"version-history":[{"count":5,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts\/2516\/revisions"}],"predecessor-version":[{"id":2851,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts\/2516\/revisions\/2851"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/media\/2517"}],"wp:attachment":[{"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/media?parent=2516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/categories?post=2516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/tags?post=2516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}