100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Summary

Samenvatting Basisprogrammeren: commando's werkcolleges

Rating
-
Sold
-
Pages
21
Uploaded on
25-01-2024
Written in
2023/2024

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.

Institution
Module










Whoops! We can’t load your doc right now. Try again or contact support.

Connected book

Written for

Institution
Study
Module

Document information

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

Subjects

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
$5.99
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
verkoper12
2.0
(2)

Get to know the seller

Seller avatar
verkoper12 Katholieke Universiteit Leuven
Follow You need to be logged in order to follow users or courses
Sold
4
Member since
4 year
Number of followers
4
Documents
6
Last sold
1 year ago
Samenvattingen

2.0

2 reviews

5
0
4
0
3
1
2
0
1
1

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

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

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight 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 smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions