<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="https://peda.net/:static/535/atom.xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Luku 3: Python laskukoneena</title>
<id>https://peda.net/id/d50c5528778</id>
<updated>2022-01-17T13:51:40+02:00</updated>
<link href="https://peda.net/id/d50c5528778:atom" rel="self" />
<link href="https://peda.net/p/annakaisa.markkanen/python-ohjelmointi/luku-3-python-laskukoneena#top" rel="alternate" />
<logo>https://peda.net/:static/535/peda.net.logo.bg.svg</logo>
<rights type="html">&lt;div class=&quot;license&quot;&gt;Tämän sivun lisenssi &lt;a rel=&quot;license&quot; href=&quot;https://peda.net/info&quot;&gt;Peda.net-yleislisenssi&lt;/a&gt;&lt;/div&gt;&#10;</rights>

<entry>
<title>Python laskukoneena</title>
<id>https://peda.net/id/01b53914778</id>
<updated>2022-01-17T13:56:06+02:00</updated>
<link href="https://peda.net/p/annakaisa.markkanen/python-ohjelmointi/luku-3-python-laskukoneena/python-laskukoneena#top" />
<content type="html">&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;none&quot;--&gt;Pythonilla voidaan laskea erilaisia laskutoimituksia. Tavallisimmat laskutoimitukset ovat:&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/p&gt;&#10;&lt;table aria-rowcount=&quot;6&quot;&gt;&lt;!--filtered attribute: data-tablestyle=&quot;MsoTableGrid&quot;--&gt;&lt;!--filtered attribute: data-tablelook=&quot;1696&quot;--&gt;&#10;&lt;tbody&gt;&#10;&lt;tr aria-rowindex=&quot;1&quot;&gt;&#10;&lt;td&gt;&lt;!--filtered attribute: data-celllook=&quot;0&quot;--&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;none&quot;--&gt;laskutoimitus&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:2,&quot;335551620&quot;:2,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/p&gt;&#10;&lt;/td&gt;&#10;&lt;td&gt;&lt;!--filtered attribute: data-celllook=&quot;0&quot;--&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;none&quot;--&gt;selitys&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:2,&quot;335551620&quot;:2,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/p&gt;&#10;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr aria-rowindex=&quot;2&quot;&gt;&#10;&lt;td&gt;&lt;!--filtered attribute: data-celllook=&quot;0&quot;--&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;none&quot;--&gt;+&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:2,&quot;335551620&quot;:2,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/p&gt;&#10;&lt;/td&gt;&#10;&lt;td&gt;&lt;!--filtered attribute: data-celllook=&quot;0&quot;--&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;none&quot;--&gt;yhteenlasku&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:2,&quot;335551620&quot;:2,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/p&gt;&#10;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr aria-rowindex=&quot;3&quot;&gt;&#10;&lt;td&gt;&lt;!--filtered attribute: data-celllook=&quot;0&quot;--&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;none&quot;--&gt;-&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:2,&quot;335551620&quot;:2,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/p&gt;&#10;&lt;/td&gt;&#10;&lt;td&gt;&lt;!--filtered attribute: data-celllook=&quot;0&quot;--&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;none&quot;--&gt;erotus&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:2,&quot;335551620&quot;:2,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/p&gt;&#10;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr aria-rowindex=&quot;4&quot;&gt;&#10;&lt;td&gt;&lt;!--filtered attribute: data-celllook=&quot;0&quot;--&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;none&quot;--&gt;*&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:2,&quot;335551620&quot;:2,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/p&gt;&#10;&lt;/td&gt;&#10;&lt;td&gt;&lt;!--filtered attribute: data-celllook=&quot;0&quot;--&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;none&quot;--&gt;kertolasku&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:2,&quot;335551620&quot;:2,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/p&gt;&#10;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr aria-rowindex=&quot;5&quot;&gt;&#10;&lt;td&gt;&lt;!--filtered attribute: data-celllook=&quot;0&quot;--&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;none&quot;--&gt;/&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:2,&quot;335551620&quot;:2,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/p&gt;&#10;&lt;/td&gt;&#10;&lt;td&gt;&lt;!--filtered attribute: data-celllook=&quot;0&quot;--&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;none&quot;--&gt;jakolasku&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:2,&quot;335551620&quot;:2,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/p&gt;&#10;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr aria-rowindex=&quot;6&quot;&gt;&#10;&lt;td&gt;&lt;!--filtered attribute: data-celllook=&quot;0&quot;--&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;none&quot;--&gt;**&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:2,&quot;335551620&quot;:2,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/p&gt;&#10;&lt;/td&gt;&#10;&lt;td&gt;&lt;!--filtered attribute: data-celllook=&quot;0&quot;--&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;none&quot;--&gt;potenssi&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:2,&quot;335551620&quot;:2,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/p&gt;&#10;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;none&quot;--&gt;Testaa ylläolevat laskutoimitukset kirjoittamalla ja tulostamalla esimerkiksi seuraavat laskut:&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:6,&quot;335551620&quot;:6,&quot;335559739&quot;:160,&quot;335559740&quot;:259}&quot;--&gt; &lt;br/&gt;&#10;&lt;a href=&quot;https://peda.net/p/annakaisa.markkanen/python-ohjelmointi/luku-3-python-laskukoneena/python-laskukoneena/luku-3.1.jpg#top&quot; title=&quot;Luku 3.1.JPG&quot;&gt;&lt;img src=&quot;https://peda.net/p/annakaisa.markkanen/python-ohjelmointi/luku-3-python-laskukoneena/python-laskukoneena/luku-3.1.jpg:file/photo/320f4cd8f4c193eaa0c952a79744faf228a74463/Luku%203.1.JPG&quot; alt=&quot;&quot; title=&quot;Luku 3.1.JPG&quot; class=&quot;inline&quot; loading=&quot;lazy&quot;/&gt;&lt;/a&gt;&lt;br/&gt;&#10;&lt;br/&gt;&#10;&lt;span class=&quot;TextRun SCXW28944877 BCX0&quot; lang=&quot;FI-FI&quot;&gt;&lt;!--filtered attribute: data-contrast=&quot;auto&quot;--&gt;&lt;span class=&quot;NormalTextRun SCXW28944877 BCX0&quot;&gt;Edelliset laskut voisi kirjoittaa myös muuttujien avulla niin, että merkittäisi alussa muuttujat a ja b ja kirjotettaisi laskut niiden avulla:&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;EOP SCXW28944877 BCX0&quot;&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:6,&quot;335551620&quot;:6,&quot;335559739&quot;:160,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;br/&gt;&#10;&lt;a href=&quot;https://peda.net/p/annakaisa.markkanen/python-ohjelmointi/luku-3-python-laskukoneena/python-laskukoneena/luku-3.2.jpg2#top&quot; title=&quot;Luku 3.2.JPG&quot;&gt;&lt;img src=&quot;https://peda.net/p/annakaisa.markkanen/python-ohjelmointi/luku-3-python-laskukoneena/python-laskukoneena/luku-3.2.jpg2:file/photo/3e74ef5a930487eb6c26e458b2630b890312dce7/Luku%203.2.JPG&quot; alt=&quot;&quot; title=&quot;Luku 3.2.JPG&quot; class=&quot;inline&quot; loading=&quot;lazy&quot;/&gt;&lt;/a&gt;&lt;br/&gt;&#10;&lt;br/&gt;&#10;&lt;/span&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;auto&quot;--&gt;Tämä voi olla kätevää, jos laskuja on monta ja jossain vaiheessa tarvitsisi vaihtaa laskettavien lukujen arvoa.&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:6,&quot;335551620&quot;:6,&quot;335559739&quot;:160,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:6,&quot;335551620&quot;:6,&quot;335559739&quot;:160,&quot;335559740&quot;:259}&quot;--&gt; -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------&lt;/span&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;auto&quot;--&gt;Python noudattaa tavallista laskujärjestystä. Esimerkiksi laskussa 3+5*2 lasketaan ensin kertolasku, sitten yhteenlasku. Laskujärjestystä saadaan muutettua sulkujen avulla. Kokeile laskea seuraavat laskut:&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:6,&quot;335551620&quot;:6,&quot;335559739&quot;:160,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:6,&quot;335551620&quot;:6,&quot;335559739&quot;:160,&quot;335559740&quot;:259}&quot;--&gt;&lt;a href=&quot;https://peda.net/p/annakaisa.markkanen/python-ohjelmointi/luku-3-python-laskukoneena/python-laskukoneena/luku-3.3.jpg#top&quot; title=&quot;Luku 3.3.JPG&quot;&gt;&lt;img src=&quot;https://peda.net/p/annakaisa.markkanen/python-ohjelmointi/luku-3-python-laskukoneena/python-laskukoneena/luku-3.3.jpg:file/photo/44a94d3b59071768b702e42a146a519a9b1ad593/Luku%203.3.JPG&quot; alt=&quot;&quot; title=&quot;Luku 3.3.JPG&quot; class=&quot;inline&quot; loading=&quot;lazy&quot;/&gt;&lt;/a&gt;&lt;br/&gt;&#10;&lt;br/&gt;&#10;--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------&lt;br/&gt;&#10;&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;auto&quot;--&gt;Muuttujan arvon vaihtaminen:&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:6,&quot;335551620&quot;:6,&quot;335559739&quot;:160,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-contrast=&quot;auto&quot;--&gt;Pythonissa = -merkki on hieman erilainen kuin matematiikassa, jossa se tarkoittaa yhtäsuuruutta. Jos matematiikassa kirjoitetaan a=5, voidaan luottaa siihen, että yhtäsuuruus pätee. Pythonissa muuttujan arvo voi kuitenkin muuttua. Testaa, mitä seuraava ohjelma tulostaa:&lt;/span&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:6,&quot;335551620&quot;:6,&quot;335559739&quot;:160,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;span&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:6,&quot;335551620&quot;:6,&quot;335559739&quot;:160,&quot;335559740&quot;:259}&quot;--&gt;&lt;a href=&quot;https://peda.net/p/annakaisa.markkanen/python-ohjelmointi/luku-3-python-laskukoneena/python-laskukoneena/luku-3.4.jpg#top&quot; title=&quot;Luku 3.4.JPG&quot;&gt;&lt;img src=&quot;https://peda.net/p/annakaisa.markkanen/python-ohjelmointi/luku-3-python-laskukoneena/python-laskukoneena/luku-3.4.jpg:file/photo/cdd7483d4eb46cb6a11afac75fc38f6a85c10dff/Luku%203.4.JPG&quot; alt=&quot;&quot; title=&quot;Luku 3.4.JPG&quot; class=&quot;inline&quot; loading=&quot;lazy&quot;/&gt;&lt;/a&gt;&lt;br/&gt;&#10;&lt;br/&gt;&#10;&lt;span class=&quot;TextRun SCXW182687941 BCX0&quot; lang=&quot;FI-FI&quot;&gt;&lt;!--filtered attribute: data-contrast=&quot;auto&quot;--&gt;&lt;span class=&quot;NormalTextRun SCXW182687941 BCX0&quot;&gt;Python lukee koodia rivi kerrallaan, eikä se näe mitään ongelmaa siinä, että muuttuja a määritellään ensin luvuksi 4 ja seuraavalla rivillä luvuksi 6. Muuttujaa voidaan merkata myös = -merkin molemmille puolille, kuten rivillä 5.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;EOP SCXW182687941 BCX0&quot;&gt;&lt;!--filtered attribute: data-ccp-props=&quot;{&quot;201341983&quot;:0,&quot;335551550&quot;:1,&quot;335551620&quot;:1,&quot;335559739&quot;:160,&quot;335559740&quot;:259}&quot;--&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&#10;</content>
<published>2022-01-17T13:52:54+02:00</published>
</entry>


</feed>