100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4.2 TrustPilot
logo-home
Overig

Python notes

Beoordeling
4,0
(1)
Verkocht
4
Pagina's
7
Geüpload op
28-02-2022
Geschreven in
2020/2021

Information and Data Management UvA notes on Python.










Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Documentinformatie

Geüpload op
28 februari 2022
Aantal pagina's
7
Geschreven in
2020/2021
Type
Overig
Persoon
Onbekend

Onderwerpen

Voorbeeld van de inhoud

PYTHON

WEEK 1

Variables
- String: text, images, messages
- Integer: number without decimals
- Float: number with decimals
- print(type(variable)) in order to determine the type of the variable.

Variable type conversion
- Cannot add two different types of variables (e.g. one cannot add string and integer/float), so therefore conversion is necessary.
- Convert to:
o String (str(variable))
o Integer (int(variable))
o Float (float(variable))

Rules
- Separate by a comma (,)

Inputs
- input: requires user to fill data
- Asking the user to type a value, reading from a file, reading a network connection, accessing a database.
- Store the result in a variable. The variable type will be a string. One may need to convert the variable into an integer or a float.

Operations
- Standard operators in order of priority:
o Power (**)
o Multiply (*)
o Divide (/)
o Plus (+)
o Minus (–)
- Parentheses are used to show priority.

Output
- What is presented to the user.
- print: displays text.
- Integers and floats do not use quotation marks, whereas strings do.

Rounding numbers
- round (variable, decimal spaces)

WEEK 2

Conditions
- Doing different things depending on different values.
- If… then…, else….
- if condition:
print
- else:
print
print(“Ending statement”)
- Indentations: the spaces before print are mandatory.
- A condition is a calculation that has a Boolean result: it is either true or false.
o print(comparison)
o It will print either “true” or “false”
- Comparisons:
o < less than
o <= less than or equal
o > higher than
o >= higher than or equal
o == equal
o != not equal, indifferent

Multiple conditions
- When a and b are conditions:
o a and b: TRUE when both conditions are TRUE
o a or b: TRUE when any condition is TRUE.

, Control flow
- What instructions will be executed?
o Instructions run in sequence, line by line.
o In case of error, the code after the error is not executed,
o The code can be divided in blocks of code, blocks are indicated by the indentation.
 Lines at the same indentation level belong to the same block.
 Indentations should only happen when there is a need for a separate block: after if, for, while, defining a function, or a class. It
should not happen in the middle of a block, or it generates and issue.

Lists
- A list is a variable that contains not just one value, but multiple values.
- Values are called elements.
- Each element is stored at an index.
- Indexes start at 0.
- The number of elements is called length of the list.
- Create lists using [ ].
- Separate elements with (,).
- Do not call a variable “list”. It is a function name.
- Counting the number of elements in a list:
o len(the_list)
- Access:
o The first item has an index of 0.
o For convenience, the last item has an index of -1.
o If there are 5 items, the index goes from 0-4.
o Accessing element at index i (the_list [i]).
- Modification:
o Modification of the value of the element at index i.
o the_list[i] = new_value
- Concatenation:
o Putting two lists together.
o the_list1 + the_list2
o One can also add a list that contains only one string.
- Check if a value is in a list:
o The result is true or false.
o if value (not) in the_list:
print
Strings
- A list of characters, except no modification is possible.

For loops
- Print each letter in variable
for x in variable:
print (x)
- Print each item of list
for x in list:
print (x)
- Print a word multiple time
for x in list:
print (“Word”)
- Sum:
o Start with a total at 0.
o For each value in the list, add it to the total.
o for value in the_list.
o Example:
my_list = [1, 2, 3]
total = 0
for elt in my_list:
total = total + elt
print(total) if you want the total at the end of each element in the list
print(total) if you want the total at the end

Range
- Print numbers in a particular range
- for x in range(number):
print

Beoordelingen van geverifieerde kopers

Alle reviews worden weergegeven
3 jaar geleden

4,0

1 beoordelingen

5
0
4
1
3
0
2
0
1
0
Betrouwbare reviews op Stuvia

Alle beoordelingen zijn geschreven door echte Stuvia-gebruikers na geverifieerde aankopen.

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
bastudent Universiteit van Amsterdam
Bekijk profiel
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
60
Lid sinds
5 jaar
Aantal volgers
51
Documenten
0
Laatst verkocht
1 maand geleden

3,4

8 beoordelingen

5
3
4
1
3
2
2
0
1
2

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Veelgestelde vragen