• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 13 pages
Summary

Summary Endterm Information and Data Management (Python)

Document preview thumbnail
Preview 3 out of 13 pages

Summary for the endterm of Information and Data Management. Includes: Al Sweigart: Chapter 1, 2, 3, 4, 5 Jake Vanderplas: The Basics of NumPy Arrays, Aggregations: Min, Max, and Everything In Between, Computation on Arrays: Broadcasting Tutorials UvA: Week 1, Week 2, Week 5

Content preview

AL SWEIGART
Chapter 1: Python Basics
Python data types:
● String​: number of characters enclosed by quotation marks → ‘tomato’
● Integer​: a number without decimals → 4
● Floats​: a number which has decimals → 5.5
● None​: absence of value
→ p​ rint(type(x))​ → shows the datatype of the variable

Rules using data types together:
✓ Integer * float → ​5 * 5.5
✓ String * integer →​ ​2*tomato = tomatotomato
⌧ String + integer → ​‘tomato’ + 4 = syntax error
⌧ String * float → ​5.5 * tomato = syntax error

Variable​: containers for storing data
x = ‘tomato’
print(x)
tomato
→ must start with a letter or underscore ( _ ). Can only contain A-z, 0-9, and _.

String methods:
x.title()​ ​→ avatar becomes Avatar
x.upper()​ ​→ avatar becomes AVATAR
x.lower ()​ ​→ AVATAR becomes avatar
x.islower () (or .isupper etc.)​ → True or False
x.find('a')​ ​→ Finding the first occurance of a value inside a string → 0


Integer methods:
● for i in range(4): print(i)
= Printing each integer in a range of 0 - 4
0
1
2
3


Converting data types​: ​x = int(age), x = str(age), x = float(age)

,Chapter 2: Flow Control
Boolean​: only 2 values: True or False
Operators:
● Not: not True = False, not False = True.
● And: True and True = True, False and True = False, False and False = False
● Or: True or True = True, True or False = True, False or False = False
As a convention it is accepted that True=1, so True+2 = 3

Comparison operators (output True/False):
● == → equal to
● < → less than
● > → greater than
● != → not equal to
● <= → less than or equal to
● >= → greater than or equal to

Flow Control Statements
If .. Then Statements
if 200 >33:
print("b is greater than a")
else:
print("b is not greater than a")

Elif Statements
if 200 >33:
print("b is greater than a")
elif 200 = 33:
print("b is not a")
else:
print("b is not greater than a")

While Loops
Execute a set of statements as long as a condition is true. E.g. ‘Print number 1 till 5’
i = 1
while i < 6:
print(i)
i += 1

, For Loops
A for loop is used for iterating over a sequence. E.g. ‘Print each fruit in a fruit list’:
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)

Range()

print('My name is')
for i in range(5):
print('Jimmy Five Times (' + str(i) + ')')



for i in range(0, 10, 2):
print(i



Break Loops
Break (while loop). E.g. ‘Print 1 till 3’
i = 1
while i < 6:
print(i)
if i == 3:
break
i += 1

Break (for loop). E.g. ‘Print apple till banana’.
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)
if x == "banana":
break

Continue Loops
Continue (while loop). E.g. ‘Print 1, 2, 4, 5, 6’ (3 is missing from the loop)
i = 0
while i < 6:
i += 1
if i == 3:
continue
print(i)

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?
No
Which chapters are summarized?
1 - 5
Uploaded on
October 11, 2020
Number of pages
13
Written in
2019/2020
Type
Summary
$6.34

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.
jtimmermans
3.6
(17)
Sold
152
Followers
106
Items
14
Last sold
11 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