100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Resumen

Summary of the course introduction to programming for Python, VU

Puntuación
4.0
(1)
Vendido
2
Páginas
32
Subido en
29-10-2022
Escrito en
2020/2021

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

Institución
Grado











Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
Estudio
Grado

Información del documento

Subido en
29 de octubre de 2022
Número de páginas
32
Escrito en
2020/2021
Tipo
Resumen

Temas

Vista previa del contenido

]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
$6.65
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Reseñas de compradores verificados

Se muestran los comentarios
2 año hace

4.0

1 reseñas

5
0
4
1
3
0
2
0
1
0
Reseñas confiables sobre Stuvia

Todas las reseñas las realizan usuarios reales de Stuvia después de compras verificadas.

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
freekcool Vrije Universiteit Amsterdam
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
15
Miembro desde
3 año
Número de seguidores
12
Documentos
7
Última venta
7 meses hace

4.3

3 reseñas

5
1
4
2
3
0
2
0
1
0

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes