100% tevredenheidsgarantie Direct beschikbaar na betaling Zowel online als in PDF Je zit nergens aan vast
logo-home
Information & Data Management: SUMMARY Automate The Boring Stuff with Python €6,49
In winkelwagen

Samenvatting

Information & Data Management: SUMMARY Automate The Boring Stuff with Python

 186 keer bekeken  10 keer verkocht

English summary for the course Information & Data Management of the bachelor Business Administration at the UvA. It includes all the required chapters of 'How to automate the boring stuff with Python' and some additional lecture notes. If you read this you will understand Python and programming way...

[Meer zien]

Voorbeeld 3 van de 24  pagina's

  • Onbekend
  • 1 september 2019
  • 24
  • 2018/2019
  • Samenvatting
  • python
  • 9781593275990
book image

Titel boek:

Auteur(s):

  • Uitgave:
  • ISBN:
  • Druk:
Alle documenten voor dit vak (17)
avatar-seller
chiara-uva
AUTOMATE THE BORING STUFF:
/ CH1 /

A window with the >>> prompt should appear; that’s the interactive shell.

2 + 2 is called an expression: consist of values (such as 2) and operators (such as +),
and they can always evaluate (that is, reduce) down to a single value.

** Exponent 2 ** 3 8

% Modulus/remainder 22 % 8 6

// Integer division/floored quotient 22 // 8 2

Modules/Remainder: divides by whole number (22-(2x8)=6)
Integer division: divides by whole number and deletes any decimals. 22//8=2.75 → = 2

Precedence: the order of operations: ** , *, /, //, % , +, - . Use parentheses ( ) [haakjes] to
override the usual precedence if you need to.

Data type: a category for values, and every value belongs to exactly one data type.
- Integer (int): indicates values that are whole numbers.
- Floating-point (floats): Numbers with a decimal point, such as 3.14. Note that
even though the value 42 is an integer, the value 42.0 would be a floating-point
number.

- Strings: single quote showing where to begin and end.
'a', 'aa', 'aaa', 'Hello!', '11 cats' '' = blank string

When + is used on two string values, it joins the strings as the string
concatenation operator.
>>> 'Alice' + 'Bob'
'AliceBob'
Combining an + operator on a string and an integer value will result in an error.

Combining an * operator on a string value and one integer value = string
replication operator
>> 'Alice' * 5
'AliceAliceAliceAliceAlice'
‘Alice’ * 5.0 would give an error.

Variable: a box in the computer’s memory where you can store a single value (to use later).
1. Only one word.
2. Use only letters, numbers, and the underscore _ character.
3. Can’t begin with a number.
a) Variable names are (capital letter) case-sensitive.

Assignment statement: consists of a variable name, an equal sign (= assignment
operator), and the value (=integer value) to be stored.
>>> spam = 40
>>> eggs = 2
>>> spam + eggs
42

,A variable is initialized the first time a value is stored in it.
Overwriting the variable: When a variable is assigned a new value, the old value is forgotten.
>>> spam = spam + 2
>>> spam
42

File editor: has some specific features for typing in source code.
- The interactive shell window will always be the one with the >>> prompt.
- The file editor window will not have the >>> prompt.

When there are no more lines of code to execute, the Python program terminates (exits);
that is, it stops running.

# is a comment. Python ignores comments (and the blank lines after it), and you can use
them to write notes or remind yourself what the code is trying to do.
Commenting out: Sometimes, programmers will put a # in front of a line of code to temporarily remove it
while testing a program.


The print() function displays the string value inside the parentheses on the screen.
When Python executes a line, you say that Python is calling the print()function and
the string value is being passed to the function. A value that is passed to a function
call is an argument.

The input()function waits for the user to type some text on the keyboard and
press ENTER. Always returns a string (even if the user typed in a number).

print('It is good to meet you, ' + myName)

The len () function: evaluates to the integer value of the number of characters in that
string.
>>> len('hello')
5

The str() function is handy when you have an integer or float that you want to concatenate to a
string.
>>> str(29)
'29'
>>> print('I am ' + str(29) + ' years old.')
I am 29 years old.


The int() function is helpful if you have a number as a string value that you want to
use in some mathematics. Treat variable as an integer instead of a string:
>>> spam = input()
101

>>> spam = int(spam)

>>> spam *
202.0


The int () function is useful if you need to round a floating-point number down. If you
want to round a floating-point number up, just add 1 to it afterward.

2

, >>> int(7.7)
7
>>> int(7.7) + 1
8

An integer can be equal to a floating point, as they’re both numbers (unlike a string, which is
text).
>>> 42 == 42.0
True
>>> 42.0 == 0042.000
True




/ CH2 /

Flow control statements can decide which Python instructions to execute under which
conditions. There is usually more than one way to go from the start to the end.

Boolean data type has only two values: True and False.
>>> spam = True
>>> spam
True


Comparison operators compare two values and evaluate down to a single Boolean value.
Operator Meaning
== Equal to
!= Not equal to
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to

>>> 'dog' != 'cat'
True
>>> 42 == 42.0
True
>>> 42 == '42'
False

>>> eggCount = 42
>>> eggCount <= 42
True

• The == operator (equal to) asks whether two values are the same as each other.
• The = operator (assignment) puts the value on the right into the variable on the
left.




3

Voordelen van het kopen van samenvattingen bij Stuvia op een rij:

Verzekerd van kwaliteit door reviews

Verzekerd van kwaliteit door reviews

Stuvia-klanten hebben meer dan 700.000 samenvattingen beoordeeld. Zo weet je zeker dat je de beste documenten koopt!

Snel en makkelijk kopen

Snel en makkelijk kopen

Je betaalt supersnel en eenmalig met iDeal, creditcard of Stuvia-tegoed voor de samenvatting. Zonder lidmaatschap.

Focus op de essentie

Focus op de essentie

Samenvattingen worden geschreven voor en door anderen. Daarom zijn de samenvattingen altijd betrouwbaar en actueel. Zo kom je snel tot de kern!

Veelgestelde vragen

Wat krijg ik als ik dit document koop?

Je krijgt een PDF, die direct beschikbaar is na je aankoop. Het gekochte document is altijd, overal en oneindig toegankelijk via je profiel.

Tevredenheidsgarantie: hoe werkt dat?

Onze tevredenheidsgarantie zorgt ervoor dat je altijd een studiedocument vindt dat goed bij je past. Je vult een formulier in en onze klantenservice regelt de rest.

Van wie koop ik deze samenvatting?

Stuvia is een marktplaats, je koop dit document dus niet van ons, maar van verkoper chiara-uva. Stuvia faciliteert de betaling aan de verkoper.

Zit ik meteen vast aan een abonnement?

Nee, je koopt alleen deze samenvatting voor €6,49. Je zit daarna nergens aan vast.

Is Stuvia te vertrouwen?

4,6 sterren op Google & Trustpilot (+1000 reviews)

Afgelopen 30 dagen zijn er 50843 samenvattingen verkocht

Opgericht in 2010, al 14 jaar dé plek om samenvattingen te kopen

Start met verkopen
€6,49  10x  verkocht
  • (0)
In winkelwagen
Toegevoegd