Commit 9237fa0e3374834e39e7db5b6ed9d837c169b97c

Authored by Rémi Emonet
1 parent 88903236d0
Exists in master

Add print examples

Showing 1 changed file with 20 additions and 1 deletions

07-variables-et-types/index.html View file @ 9237fa0
... ... @@ -3,7 +3,7 @@
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6   - <meta http-equiv="last-modified" content="2017-08-31 18:06:22 +0200">
  6 + <meta http-equiv="last-modified" content="2017-09-26 16:35:59 +0200">
7 7 <meta name="viewport" content="width=device-width, initial-scale=1">
8 8 <!-- meta "search-domain" used for google site search function google_search() -->
9 9 <meta name="search-domain" value="">
10 10  
... ... @@ -223,7 +223,26 @@
223 223  
224 224 </blockquote>
225 225  
  226 +<p>Exemple de programme illustrant en partie les variables et types :</p>
226 227  
  228 +<div class="language-python highlighter-rouge"><pre class="highlight"><code><span class="k">print</span><span class="p">(</span><span class="s">"Bonjour"</span><span class="p">)</span>
  229 +
  230 +<span class="n">a</span> <span class="o">=</span> <span class="s">"Hello"</span>
  231 +<span class="k">print</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
  232 +<span class="k">print</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">a</span><span class="p">))</span>
  233 +
  234 +<span class="n">un_entier</span> <span class="o">=</span> <span class="mi">123</span>
  235 +<span class="k">print</span><span class="p">(</span><span class="n">un_entier</span><span class="p">)</span>
  236 +<span class="k">print</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">un_entier</span><span class="p">))</span>
  237 +
  238 +<span class="n">truc</span> <span class="o">=</span> <span class="mf">18.5</span>
  239 +<span class="k">print</span><span class="p">(</span><span class="n">truc</span><span class="p">,</span> <span class="nb">type</span><span class="p">(</span><span class="n">truc</span><span class="p">))</span>
  240 +
  241 +<span class="n">truc</span> <span class="o">=</span> <span class="s">"Une « string » (chaîne de caractère)"</span>
  242 +<span class="k">print</span><span class="p">(</span><span class="n">truc</span><span class="p">)</span>
  243 +<span class="k">print</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">truc</span><span class="p">))</span>
  244 +</code></pre>
  245 +</div>
227 246  
228 247  
229 248 <blockquote class="keypoints">