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

Summary of the course introduction to programming for Python, VU

Rating
4.0
(1)
Sold
2
Pages
32
Uploaded on
29-10-2022
Written in
2020/2021

This summary covers all lectures of the course introduction to programming for Python. It also addresses some examples discussed during the lectures.

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
October 29, 2022
Number of pages
32
Written in
2020/2021
Type
Summary

Subjects

Content preview

]Week 1, college 1

● Install newest Python 2!
● Prepare practicals beforehand

Bits
● If you have 32 bits you can write 232 different codes.

Number types we can manipulate
● Int (Integer: geheel getal (7,8 bijvoorbeeld))
○ How do you write an integer in Python:
○ Exactly the way you just type them: 7
○ But you can only write positive numbers like that.
■ -4 Python sees that as a positive 4 with a - that says make it negative
operation.
○ 0123 Python sees as 83
■ Because Python sees the 0 as an sign for octal number.
■ In the octal system 1238 is 1x84 for example.
○ Only remember that you don’t begin with a number beginning with a 0.
● Long (long integer)
○ If you have very long numbers you need to use long.
○ Notation: If you write 7 as a long you write 7L.
○ You never need the type long in this course, you only need int!!!!

Sequence types
● Str (string)
○ Rows
○ Contains rows of elements
○ String is a row of characters.
■ Characters are symbols
■ All the things you can type on the keyboard are characters.
○ Notation: “abc”
■ or ‘abc’
■ Double quotes or single quotes are not part of the string.
■ Python prefers single quote so it will change it to single quote in the
answer, but you can use double quote.
○ Strings are used to manipulate text.
■ You can put a sentence in a string.
○ Strings are really useful to print text on the screen.
○ But what if you have ‘ab’cd’, this won't work because the second quote will
already close the string.
■ Then you can wrote a double quote: “ab’cd”
○ But what if you have “ab’cd’”ef”
■ You use a special escape character which is the backslash \
● Slash / (wrong)
● backslash \ (right you use this).

, ● backslash takes special meaning away of next character
● So you can say ‘ab\’cd’, then the ‘ in the middle is no special
character but just a character.
● If you print something it won't be in the output.
● But you cannot do ‘\’
○ You can write ‘\\’
○ Backslash takes away the special meaning of the
backslash.
■ Backslash can also give special meaning to next character
sometimes.
● \t is a tab
○ You write that if you do tabs in a string and python will
give that also as answer if you do tabs in a string.
● \n is a new line or return (enter).
○ So you can say ‘ab\ncd’ if you want ab on one rule and
cd on the next line if you print it.
○ If a string has a length of 0 it’s an empty string (0 characters).
● List

Rows

They contain rows of elements

Is a row of anything.
■ Either an int or an long or a float
■ These things you can put in a list.
○ You write a list by opening wit [
○ [ ] empty list.
○ [a] one element etc
○ [a, b, c], you write komma’s in between.
○ You can also have a list inside a list [1, 2, 3, 5, ‘abc’, [1,2]]
● The number types are elements, so no lists.

● One billion is een miljard in Nederlands

Week 1, college 2
2 types of data
● Number types
○ Int (3)
○ Long (3L)
○ Float (Decimals)
■ 1,5 is 1.5 (American style with dot)
■ Is called fixed point notation
■ Floating Point notation (wetenschappelijke notatie je weet wel):
● Is used if you have many 0’s after the decimal point.
● for example (1.6x1019)
○ The decimal point has to move 19 places to the left.
● In python you write (1.6e-19)

, ○ If you write a big E, it can but Python changes it to a
small e in the answer.



● The number of bits that is used to code float numbers is limited.
● So how does Python store all those numbers
● They don’t store it exact.
○ If you use 13.4 than it’s maybe not exact, it’s as close to the real value as
possible.
○ For small numbers it doesn’t matter but for large numbers you will get errors.
● You have a float if you have a decimal point in the number and you have at least one
digit.
○ 3. is a float
○ 3.0 is also a float
○ .5 is 0.5
○ You can also write a half as 5e-1.

Calculations with values
● If you write 1+2 you call the + the operator.
○ The values are operands.
○ 1 is the left operand and 2 is the right operand.
● Arithmetic operators
Math Python

+ (1 operand) +

- (1 operand) -

+ (2 operands, add) +

- (2 operands, substract) -

x ( multiplication) *

/ (divide) /

Modulo %

24 for example 2**4
● But you can only divide same type of numbers (int, long, float) to each other and not
across each other.
○ Also if Python will give the answer in the same type of number.
○ If you do 22/5 if will tell you 4 because you can take 5 4 times out of 22.
○ But you can do 22%5 than it tells you 2, so it tells you how much there is left
after you take out the 5’s.
○ If both operands are ints then the answer will be a int (and with the others).
○ 1 + 2. cannot be calculated.

, ■But the first one can be transformed to the nearest float, so 1.+2. can
be calculated.
■ You change ints into floats, not the other way around.
■ If you do 13/0.5 the answer will always be a float.
■ Remember, floats are not exact.
● Relational operators
Math Python

< <

> <

<= (left is smaller or equal to right). <=

= ==

not = !=


● If you type 3<4 you get a boolean.
○ A boolean is a truth value, has 2 values which are True and False (note the
uppercase letters).
○ Python is uppercase and lowercase sensitive.
○ 3<4 will get the output true.
○ 3>4 will get the output false.
● Boolean operators
○ Were the operators are of the type boolean.
Math Python

and

or

not
¬
Some truth tables
a b a and b

f f F

f t F

t f F

t t T

Reviews from verified buyers

Showing all reviews
2 year ago

4.0

1 reviews

5
0
4
1
3
0
2
0
1
0
Trustworthy reviews on Stuvia

All reviews are made by real Stuvia users after verified purchases.

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
freekcool Vrije Universiteit Amsterdam
Follow You need to be logged in order to follow users or courses
Sold
15
Member since
3 year
Number of followers
12
Documents
7
Last sold
7 months ago

4.3

3 reviews

5
1
4
2
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