Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 3 out of 21 pages
Summary

Samenvatting Basisprogrammeren: commando's werkcolleges

Document preview thumbnail
Preview 3 out of 21 pages

Alle te kennen commando's zouden in deze samenvatting uitgelegd moeten staan. Van de modules staan de basisprincipes van: math, statistics en random ook uitgelegd.

Content preview

Commando’s basis programmeren Python3
Commando’s basis programmeren Python3................................................1
Variabelen.................................................................................................2
Bewerkingen.............................................................................................3
Printmethodes...........................................................................................4
Formatmethode....................................................................................4

%-methode...........................................................................................4

Toepassing: Spaties en enters..............................................................4

Conditionele programmeertechnieken......................................................5
If … elif … else …..................................................................................5

For-lus...................................................................................................5

While lus:..............................................................................................6

Woordenboeken........................................................................................6
Lijsten.....................................................................................................10
Matrix......................................................................................................10
Functies...................................................................................................11
Modules...................................................................................................12
Module importeren:............................................................................12

Functies of variabelen importeren:.....................................................12

Module: Math......................................................................................13

Module: Random.................................................................................14

Module: Statistics...............................................................................15

Module: numpy...................................................................................16

Module: copy......................................................................................17

Packages.................................................................................................18
Package: matplotlib............................................................................18

Herhalingsoefening oplossing.................................................................20




1

,Variabelen
Commando Wat doet het?
x=y=… x en y gelijk stellen aan …. OPM:
als je later x alleen verandert,
verandert y niet mee!
x,y = a, b x krijgt waarde a toegevegen, y
waarde b
Omzetten string naar een geheel
getal
if getal.isnumeric(): Controleert of een getal natuurlijk
is.*
getal=round(getal,2) Rond een getal af tot op 2 cijfers na
de komma.
Belangrijk:

 In Python verwijst een variabele naar een object
o Object = gegevens-entiteit
o Variable (tijdelijk) gekoppeld aan een object via object ID
 Static Typing VS (Dynamic Typing)
o Koppeling ‘geeft’ waarde en type aan variable
o Object != variable

Dynamic Typing:

- Koppeling is tijdelijk
- Variabele kan gekoppeld worden aan een ander object.
- -> Python

Static Typing:

- Koppeling is vast aan type en waarde
- Variabele kan niet veranderen




Slides H3: variabelen: 25-28

2

, Immutabel vs mutabel: 41

Immutabele gegevenstypes: integer, real, tupel, Boolean

Mutabele gegeventypes: list, set, dictionnary

Commando Wat doet het?
getal = eval(getalStr) Omzetten string naar het best
passende getal
getal= float(getalStr) Omzetten string naar een reëel
getal
getal=int(getalStr) Omzetten string naar een geheel
getal
if getal.isnumeric(): Controleert of een getal natuurlijk
is.*
getal=round(getal,2) Rond een getal af tot op 2 cijfers na
de komma.
getal = 7E4 wetenschappelijk notatie,
automatisch geregistreerd als
float. 7*10^4
0b011010 prefix 0b geeft aan dat het een
binair getal is**
0o1475 prefix 0o  octaal getal**
0xAF45E2 prefix 0x  hexadecimaal
getal**
c1String = bin(c) c omzetten naar binaire vorm (in
type string)
c2String = oct(c) c omzetten naar octale voorstelling
c3String = hex(c) hexadecimale voorstelling
*In werkelijkheid controleert dit commando of een string enkel uit getallen
bestaat of niet. Wanneer dit zo is, kan die string dus omgezet worden naar
aan natuurlijk getal! (Want er zijn geen mintekens of komma’s.)

**De invoer gebeurt in het betreffende getalstelsel, maar intern worden
deze getallen als gehele getallen opgeslagen. Als je hun type opvraagt,
staat er: “int”

Bewerkingen
Commando Wat doet het?
a + b, a – b optelling, aftrekking
a*b, a/b vermenigvuldiging, deling
a**b a tot de macht b
a//b gehele deling (3//2 = 1)
a%b restdeling (5%3 = 2)
a += x (of -=, *=, /=, **=, //=, %/) gecombineerd toewijzen
==, !=, >, <, >=, <= Boleaanse vergelijkingen: True of
False
and, or, or not, not Logische bewerkingen (te
3

Connected book
 image
Ignace van de Woestyne, Jan Vanthienen Softwareontwerp en Programmeren met Phython 3
Publisher: Unknown ISBN: 9789463448192 Edition: 1

Document information

Study
Summarized whole book?
No
Which chapters are summarized?
Alles wat gekend moest zijn voor het examen: h3 - h13
Uploaded on
January 25, 2024
Number of pages
21
Written in
2023/2024
Type
Summary
$6.58

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
verkoper12
2.0
(2)
Sold
6
Followers
4
Items
6
Last sold
5 months ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions