Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 3 out of 24 pages
Summary

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

Document preview thumbnail
Preview 3 out of 24 pages

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 better! :) Following the course outline, this summary includes: Chapters 1 and 2, 3, 4 , 5, 6, 8. Information & Data Management: SUMMARY of the book: Automate The Boring Stuff with Python, ISBN: 9 7815 9327 5990

Content preview

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

Connected book
 image
Al Sweigart, Al Sweigart Automate the Boring Stuff with Python
Publisher: Unknown ISBN: 9781593275990 Edition: 1

Document information

Study
Summarized whole book?
Unknown
Uploaded on
September 1, 2019
Number of pages
24
Written in
2018/2019
Type
Summary
$8.30

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

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.
chiara-uva
4.2
(72)
Sold
570
Followers
360
Items
0
Last sold
4 months ago


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

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions