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

Beknopte wet. programmeren samenvatting (PYTHON)

Rating
-
Sold
-
Pages
14
Uploaded on
25-09-2024
Written in
2023/2024

Dit document bevat een samenvatting van het vak wetenschappelijk programmeren in de programmeertaal Python. Het bevat formules, redeneringen, voorbeelden, ... . De inhoud staat vermeld per PC lab.

Institution
Course









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

Written for

Institution
Study
Course

Document information

Uploaded on
September 25, 2024
Number of pages
14
Written in
2023/2024
Type
Summary

Subjects

Content preview

Wetenschappelijk programmeren: pyhton
PC lab 1
7 ---> int
➔ ASCII
7.8 ---> float
“sqldngoi” ---> str -> built in gegevenstype
B = True (=1) / Falsee (=0) ---> bool
List = [ B, “a”, 8, -16.13 ]

Operatoren: (vanaf 1 float => resultaat ook float)

- Op int en float:
o +;-;*; /
o ** ---> machtsverheffing
o // ---> gehele deling
o % ---> rest na deling
- Op str: a = ‘mooi’ ; b = ‘weer’
o a + b ---> concatenatie ~~~> ‘mooiweer’
o a*3 ---> duplicatie ~~~> ‘mooimooimooi’
- op bool:
o and, not x, or
o <, <=, >, >=, !=, ==
- Logische operatoren: &, |, ^, ~

Ingebouwde functies:

- Len() --> # karakters
- Pow(x, 2) ---> x tot de tweede macht
- Round(3.14159, 2) ---> afronden 2 getallen na komma
- Max(x,y,z) // Min(x,y,z) ---> max // min v argumenten
- Abs(-6298) ---> absolute waarde
- Range(6,36,2) ---> van 6 tem 35 in stappen v 2 (start, stop, step)
- Help() ---> functiedocumentatie weergeven
- Print()
o Sep = “-“*10
o End = “!” ; end = “\n” ---> nieuwe regel
- Andere: tabel 3.4 (p62 op computer)

Aliasing:

- a=2 ; a=b => b = 2 (garbage collection)

Expressie  statement met a = 8

- Expr: 8 + 3*4 log expr: a > 2
- Stat: res1 = a + 3*a -2 res2 = a < 2 (---> False)

Modules:

- Import math: (3.6.2)
o Math.sqrt()

, o Math.sin()
o …
- Import random (3.6.3)
o Random.randit(1,6) ---> random getallen tss 1 en 6
- Import numpy
o numpy.mean([2,4,9]) = gem v 2,4,9 = 15/3 = 5
o Eenv: import numpy spec: from numpy import mean met alias: import
numy as np

Typeconversies:

- Type() ---> gegevenstype opvragen: int / float / str / bool
- Bij input: gegstype = str
- Float -> str // int -> float // int -> str
- Float -> int ~~~> afronden naar 0
- Str -> float/int ~~~> niet altijd mogelijk



PC lab 2
If-elif-else:

- If LE1:
Uit te voeren code ----> als LE1 = True (stopt hier: gaat niet verder nr elif,
programma stopt wnr 1e criterium voldaan is => met negatieve werken)
- Elif LE2:
Uit te voeren als LE1 = False en LE2 = True
- …
- Else:
Uit te voeren als alles hierboven = False
- Kan genest w

While(-else):

- While LE:
Code die herhaaldelijk uitgevoerd w zolang LE = True
Else:
Code die 1x uitgevoerd w als False bij while
(als 1 keer totaal printen: uit while-lus ; als iedere keer printen: in while-lus)
(vaak in while lus opnieuw vraag stellen zodat lus blijft doorgaan)
- Som v getallen: getal = (2)
som = 0 (teller initialiseren vóót wihile-lus)
while ???: (waaraan het moet voldoen)
som = som + getal
getal = getal + (stappen waarin je gaat)
- Alles in lus moet aan de VOORWAARDE voldoen
- Als nooit = False => oneindige lus (stoppen: scripts -> CNTRL-SHIFT-C ; interactive:
interrupt/restart)
- Kan genest w
- Stopt als ‘exact’/’break’ ingegeven w
$5.39
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
biobroeder

Get to know the seller

Seller avatar
biobroeder Universiteit Gent
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
1 year
Number of followers
0
Documents
6
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

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 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

Frequently asked questions