SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Downloaden Sie, um offline zu lesen
You are encouraged to start up
a Python environment (like
Spyder or Jupyter Notebook). If
you do so, you can try out the
examples while listening. If you prefer
to listen only, that’s fine as well.
Basics Exercise Next meetings
Big Data and Automated Content Analysis
Week 2 – Monday
»Getting started with Python«
Damian Trilling
d.c.trilling@uva.nl
@damian0604
www.damiantrilling.net
Afdeling Communicatiewetenschap
Universiteit van Amsterdam
13 February 2017
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Today
1 The very, very, basics of programming with Python
Datatypes
Functions and methods
Indention: The Python way of structuring your program
2 Exercise
3 Next meetings
Big Data and Automated Content Analysis Damian Trilling
The very, very, basics of programming
You’ve read all this in chapter 4.
Basics Exercise Next meetings
Datatypes
Python lingo
Basic datatypes (variables)
int 32
float 1.75
bool True, False
string "Damian"
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Datatypes
Python lingo
Basic datatypes (variables)
int 32
float 1.75
bool True, False
string "Damian"
(variable name firstname)
"firstname" and firstname is not the same.
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Datatypes
Python lingo
Basic datatypes (variables)
int 32
float 1.75
bool True, False
string "Damian"
(variable name firstname)
"firstname" and firstname is not the same.
"5" and 5 is not the same.
But you can transform it: int("5") will return 5.
You cannot calculate 3 * "5" (In fact, you can. It’s "555").
But you can calculate 3 * int("5")
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Datatypes
Python lingo
More advanced datatypes
Note that the elements of a list, the keys of a dict, and the values
of a dict can have any datatype! (It should be consistent, though!)
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Datatypes
Python lingo
More advanced datatypes
list firstnames = [’Damian’,’Lori’,’Bjoern’]
lastnames =
[’Trilling’,’Meester’,’Burscher’]
Note that the elements of a list, the keys of a dict, and the values
of a dict can have any datatype! (It should be consistent, though!)
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Datatypes
Python lingo
More advanced datatypes
list firstnames = [’Damian’,’Lori’,’Bjoern’]
lastnames =
[’Trilling’,’Meester’,’Burscher’]
list ages = [18,22,45,23]
Note that the elements of a list, the keys of a dict, and the values
of a dict can have any datatype! (It should be consistent, though!)
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Datatypes
Python lingo
More advanced datatypes
list firstnames = [’Damian’,’Lori’,’Bjoern’]
lastnames =
[’Trilling’,’Meester’,’Burscher’]
list ages = [18,22,45,23]
dict familynames= {’Bjoern’: ’Burscher’,
’Damian’: ’Trilling’, ’Lori’: ’Meester’}
dict {’Bjoern’: 26, ’Damian’: 31, ’Lori’:
25}
Note that the elements of a list, the keys of a dict, and the values
of a dict can have any datatype! (It should be consistent, though!)
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Functions and methods
Python lingo
Functions
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Functions and methods
Python lingo
Functions
functions Take an input and return something else
int(32.43) returns the integer 32. len("Hello")
returns the integer 5.
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Functions and methods
Python lingo
Functions
functions Take an input and return something else
int(32.43) returns the integer 32. len("Hello")
returns the integer 5.
methods are similar to functions, but directly associated with
an object. "SCREAM".lower() returns the string
"scream"
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Functions and methods
Python lingo
Functions
functions Take an input and return something else
int(32.43) returns the integer 32. len("Hello")
returns the integer 5.
methods are similar to functions, but directly associated with
an object. "SCREAM".lower() returns the string
"scream"
Both functions and methods end with (). Between the (),
arguments can (sometimes have to) be supplied.
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Functions and methods
Writing own functions
You can write an own function:
1 def addone(x):
2 y = x + 1
3 return y
Functions take some input (“argument”) (in this example, we
called it x) and return some result.
Thus, running
1 addone(5)
returns 6.
Big Data and Automated Content Analysis Damian Trilling
Indention: The Python way of structuring your program
Basics Exercise Next meetings
Indention
Indention
Structure
The program is structured by TABs or SPACEs
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
Structure
The program is structured by TABs or SPACEs
1 firstnames=[’Damian’,’Lori’,’Bjoern’]
2 age={’Bjoern’: 27, ’Damian’: 32, ’Lori’: 26}
3 print ("The names and ages of these people:")
4 for naam in firstnames:
5 print (naam,age[naam])
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
Structure
The program is structured by TABs or SPACEs
1 firstnames=[’Damian’,’Lori’,’Bjoern’]
2 age={’Bjoern’: 27, ’Damian’: 32, ’Lori’: 26}
3 print ("The names and ages of these people:")
4 for naam in firstnames:
5 print (naam,age[naam])
Don’t mix up TABs and spaces! Both are valid, but you have
to be consequent!!! Best: always use 4 spaces!
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
Structure
The program is structured by TABs or SPACEs
1 print ("The names and ages of all these people:")
2 for naam in firstnames:
3 print (naam,age[naam])
4 if naam=="Damian":
5 print ("He teaches this course")
6 elif naam=="Lori":
7 print ("She is a former assistant")
8 elif naam=="Bjoern":
9 print ("He helped teaching this course in the past")
10 else:
11 print ("No idea who this is")
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
The line before an indented block starts with a statement
indicating what should be done with the block and ends with a :
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
The line before an indented block starts with a statement
indicating what should be done with the block and ends with a :
Indention of the block indicates that
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
The line before an indented block starts with a statement
indicating what should be done with the block and ends with a :
Indention of the block indicates that
• it is to be executed repeatedly (for statement) – e.g., for
each element from a list
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
The line before an indented block starts with a statement
indicating what should be done with the block and ends with a :
Indention of the block indicates that
• it is to be executed repeatedly (for statement) – e.g., for
each element from a list
• it is only to be executed under specific conditions (if, elif,
and else statements)
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
The line before an indented block starts with a statement
indicating what should be done with the block and ends with a :
Indention of the block indicates that
• it is to be executed repeatedly (for statement) – e.g., for
each element from a list
• it is only to be executed under specific conditions (if, elif,
and else statements)
• an alternative block should be executed if an error occurs
(try and except statements)
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
The line before an indented block starts with a statement
indicating what should be done with the block and ends with a :
Indention of the block indicates that
• it is to be executed repeatedly (for statement) – e.g., for
each element from a list
• it is only to be executed under specific conditions (if, elif,
and else statements)
• an alternative block should be executed if an error occurs
(try and except statements)
• a file is opened, but should be closed again after the block has
been executed (with statement)
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
We’ll now together do a simple exercise . . .
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Next meetings
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Wednesday
We will work together on “Describing an existing structured
dataset” (Appendix A).
Preparation: Make sure you understood all of today’s
concepts!
Big Data and Automated Content Analysis Damian Trilling

Weitere ähnliche Inhalte

Was ist angesagt?

From TREC to Watson: is open domain question answering a solved problem?
From TREC to Watson: is open domain question answering a solved problem?From TREC to Watson: is open domain question answering a solved problem?
From TREC to Watson: is open domain question answering a solved problem?Constantin Orasan
 
Analyzing Stack Overflow - Problem
Analyzing Stack Overflow - ProblemAnalyzing Stack Overflow - Problem
Analyzing Stack Overflow - ProblemAmrith Krishna
 
Stack Overflow slides Data Analytics
Stack Overflow slides Data Analytics Stack Overflow slides Data Analytics
Stack Overflow slides Data Analytics Rahul Thankachan
 
Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning ParrotAI
 
QALL-ME: Ontology and Semantic Web
QALL-ME: Ontology and Semantic WebQALL-ME: Ontology and Semantic Web
QALL-ME: Ontology and Semantic WebConstantin Orasan
 
Python for Big Data Analytics
Python for Big Data AnalyticsPython for Big Data Analytics
Python for Big Data AnalyticsEdureka!
 
Building a Dynamic Bidding system for a location based Display advertising Pl...
Building a Dynamic Bidding system for a location based Display advertising Pl...Building a Dynamic Bidding system for a location based Display advertising Pl...
Building a Dynamic Bidding system for a location based Display advertising Pl...Ekta Grover
 
PyCon 2013 - Experiments in data mining, entity disambiguation and how to thi...
PyCon 2013 - Experiments in data mining, entity disambiguation and how to thi...PyCon 2013 - Experiments in data mining, entity disambiguation and how to thi...
PyCon 2013 - Experiments in data mining, entity disambiguation and how to thi...Ekta Grover
 
Question Answering - Application and Challenges
Question Answering - Application and ChallengesQuestion Answering - Application and Challenges
Question Answering - Application and ChallengesJens Lehmann
 
Developing A Big Data Search Engine - Where we have gone. Where we are going:...
Developing A Big Data Search Engine - Where we have gone. Where we are going:...Developing A Big Data Search Engine - Where we have gone. Where we are going:...
Developing A Big Data Search Engine - Where we have gone. Where we are going:...Lucidworks
 

Was ist angesagt? (20)

BDACA1516s2 - Lecture6
BDACA1516s2 - Lecture6BDACA1516s2 - Lecture6
BDACA1516s2 - Lecture6
 
BD-ACA week3a
BD-ACA week3aBD-ACA week3a
BD-ACA week3a
 
BDACA - Lecture5
BDACA - Lecture5BDACA - Lecture5
BDACA - Lecture5
 
BDACA1516s2 - Lecture8
BDACA1516s2 - Lecture8BDACA1516s2 - Lecture8
BDACA1516s2 - Lecture8
 
BDACA1617s2 - Lecture7
BDACA1617s2 - Lecture7BDACA1617s2 - Lecture7
BDACA1617s2 - Lecture7
 
From TREC to Watson: is open domain question answering a solved problem?
From TREC to Watson: is open domain question answering a solved problem?From TREC to Watson: is open domain question answering a solved problem?
From TREC to Watson: is open domain question answering a solved problem?
 
Analyzing Stack Overflow - Problem
Analyzing Stack Overflow - ProblemAnalyzing Stack Overflow - Problem
Analyzing Stack Overflow - Problem
 
Stack Overflow slides Data Analytics
Stack Overflow slides Data Analytics Stack Overflow slides Data Analytics
Stack Overflow slides Data Analytics
 
Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning
 
Python training
Python trainingPython training
Python training
 
QALL-ME: Ontology and Semantic Web
QALL-ME: Ontology and Semantic WebQALL-ME: Ontology and Semantic Web
QALL-ME: Ontology and Semantic Web
 
Python for Big Data Analytics
Python for Big Data AnalyticsPython for Big Data Analytics
Python for Big Data Analytics
 
NLP and LSA getting started
NLP and LSA getting startedNLP and LSA getting started
NLP and LSA getting started
 
Building a Dynamic Bidding system for a location based Display advertising Pl...
Building a Dynamic Bidding system for a location based Display advertising Pl...Building a Dynamic Bidding system for a location based Display advertising Pl...
Building a Dynamic Bidding system for a location based Display advertising Pl...
 
PyCon 2013 - Experiments in data mining, entity disambiguation and how to thi...
PyCon 2013 - Experiments in data mining, entity disambiguation and how to thi...PyCon 2013 - Experiments in data mining, entity disambiguation and how to thi...
PyCon 2013 - Experiments in data mining, entity disambiguation and how to thi...
 
Python programming l2
Python programming l2Python programming l2
Python programming l2
 
Basics of IR: Web Information Systems class
Basics of IR: Web Information Systems class Basics of IR: Web Information Systems class
Basics of IR: Web Information Systems class
 
Question Answering - Application and Challenges
Question Answering - Application and ChallengesQuestion Answering - Application and Challenges
Question Answering - Application and Challenges
 
Aspects of NLP Practice
Aspects of NLP PracticeAspects of NLP Practice
Aspects of NLP Practice
 
Developing A Big Data Search Engine - Where we have gone. Where we are going:...
Developing A Big Data Search Engine - Where we have gone. Where we are going:...Developing A Big Data Search Engine - Where we have gone. Where we are going:...
Developing A Big Data Search Engine - Where we have gone. Where we are going:...
 

Andere mochten auch

ірімшіктің түрлері
ірімшіктің түрлеріірімшіктің түрлері
ірімшіктің түрлеріAsem Sarsembayeva
 
NAPL Quick Tips: A Primer on Hydrocarbon Sheens
NAPL Quick Tips: A Primer on Hydrocarbon SheensNAPL Quick Tips: A Primer on Hydrocarbon Sheens
NAPL Quick Tips: A Primer on Hydrocarbon SheensAntea Group
 
Illuminate Ad Effectiveness
Illuminate Ad EffectivenessIlluminate Ad Effectiveness
Illuminate Ad EffectivenessCraig_Frost
 
U3 t1 aa1_marcos_gaspar
U3 t1 aa1_marcos_gasparU3 t1 aa1_marcos_gaspar
U3 t1 aa1_marcos_gasparHITRATT
 
International Journal of Solid State Materials vol 2 issue 1
International Journal of Solid State Materials vol 2 issue 1International Journal of Solid State Materials vol 2 issue 1
International Journal of Solid State Materials vol 2 issue 1JournalsPub www.journalspub.com
 
impact of tv advertisment on consumer buying behaviour
impact of tv advertisment on consumer buying behaviourimpact of tv advertisment on consumer buying behaviour
impact of tv advertisment on consumer buying behaviourHimabindu Pasupuleti
 
Communication in health and social care
Communication in health and social careCommunication in health and social care
Communication in health and social careAssignment Help
 

Andere mochten auch (9)

ірімшіктің түрлері
ірімшіктің түрлеріірімшіктің түрлері
ірімшіктің түрлері
 
NAPL Quick Tips: A Primer on Hydrocarbon Sheens
NAPL Quick Tips: A Primer on Hydrocarbon SheensNAPL Quick Tips: A Primer on Hydrocarbon Sheens
NAPL Quick Tips: A Primer on Hydrocarbon Sheens
 
Illuminate Ad Effectiveness
Illuminate Ad EffectivenessIlluminate Ad Effectiveness
Illuminate Ad Effectiveness
 
U3 t1 aa1_marcos_gaspar
U3 t1 aa1_marcos_gasparU3 t1 aa1_marcos_gaspar
U3 t1 aa1_marcos_gaspar
 
International Journal of Solid State Materials vol 2 issue 1
International Journal of Solid State Materials vol 2 issue 1International Journal of Solid State Materials vol 2 issue 1
International Journal of Solid State Materials vol 2 issue 1
 
impact of tv advertisment on consumer buying behaviour
impact of tv advertisment on consumer buying behaviourimpact of tv advertisment on consumer buying behaviour
impact of tv advertisment on consumer buying behaviour
 
BDACA1617s2 - Lecture5
BDACA1617s2 - Lecture5BDACA1617s2 - Lecture5
BDACA1617s2 - Lecture5
 
Communication in health and social care
Communication in health and social careCommunication in health and social care
Communication in health and social care
 
Parlamento e governo
Parlamento e governoParlamento e governo
Parlamento e governo
 

Ähnlich wie BDACA1617s2 - Lecture 2

Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018Garth Gilmour
 
Class 27: Pythonic Objects
Class 27: Pythonic ObjectsClass 27: Pythonic Objects
Class 27: Pythonic ObjectsDavid Evans
 
These questions will be a bit advanced level 2
These questions will be a bit advanced level 2These questions will be a bit advanced level 2
These questions will be a bit advanced level 2sadhana312471
 
Write better python code with these 10 tricks | by yong cui, ph.d. | aug, 202...
Write better python code with these 10 tricks | by yong cui, ph.d. | aug, 202...Write better python code with these 10 tricks | by yong cui, ph.d. | aug, 202...
Write better python code with these 10 tricks | by yong cui, ph.d. | aug, 202...amit kuraria
 
Programming in Python
Programming in Python Programming in Python
Programming in Python Tiji Thomas
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python ProgrammingDozie Agbo
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python amiable_indian
 
Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...Simplilearn
 
The Ring programming language version 1.5.1 book - Part 5 of 180
The Ring programming language version 1.5.1 book - Part 5 of 180The Ring programming language version 1.5.1 book - Part 5 of 180
The Ring programming language version 1.5.1 book - Part 5 of 180Mahmoud Samir Fayed
 
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red Team
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red TeamWhat is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red Team
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red TeamMITRE ATT&CK
 

Ähnlich wie BDACA1617s2 - Lecture 2 (20)

BDACA - Lecture2
BDACA - Lecture2BDACA - Lecture2
BDACA - Lecture2
 
Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018
 
BDACA - Lecture3
BDACA - Lecture3BDACA - Lecture3
BDACA - Lecture3
 
Python cheat-sheet
Python cheat-sheetPython cheat-sheet
Python cheat-sheet
 
Class 27: Pythonic Objects
Class 27: Pythonic ObjectsClass 27: Pythonic Objects
Class 27: Pythonic Objects
 
BD-ACA week7a
BD-ACA week7aBD-ACA week7a
BD-ACA week7a
 
These questions will be a bit advanced level 2
These questions will be a bit advanced level 2These questions will be a bit advanced level 2
These questions will be a bit advanced level 2
 
Dynamic Python
Dynamic PythonDynamic Python
Dynamic Python
 
Python45 2
Python45 2Python45 2
Python45 2
 
BD-ACA week5
BD-ACA week5BD-ACA week5
BD-ACA week5
 
Write better python code with these 10 tricks | by yong cui, ph.d. | aug, 202...
Write better python code with these 10 tricks | by yong cui, ph.d. | aug, 202...Write better python code with these 10 tricks | by yong cui, ph.d. | aug, 202...
Write better python code with these 10 tricks | by yong cui, ph.d. | aug, 202...
 
Programming in Python
Programming in Python Programming in Python
Programming in Python
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python
 
Unit-4 PPTs.pptx
Unit-4 PPTs.pptxUnit-4 PPTs.pptx
Unit-4 PPTs.pptx
 
Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...
 
BDACA1516s2 - Lecture7
BDACA1516s2 - Lecture7BDACA1516s2 - Lecture7
BDACA1516s2 - Lecture7
 
Python for Dummies
Python for DummiesPython for Dummies
Python for Dummies
 
The Ring programming language version 1.5.1 book - Part 5 of 180
The Ring programming language version 1.5.1 book - Part 5 of 180The Ring programming language version 1.5.1 book - Part 5 of 180
The Ring programming language version 1.5.1 book - Part 5 of 180
 
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red Team
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red TeamWhat is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red Team
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red Team
 

Mehr von Department of Communication Science, University of Amsterdam

Mehr von Department of Communication Science, University of Amsterdam (16)

BDACA - Lecture8
BDACA - Lecture8BDACA - Lecture8
BDACA - Lecture8
 
BDACA - Lecture7
BDACA - Lecture7BDACA - Lecture7
BDACA - Lecture7
 
BDACA - Lecture6
BDACA - Lecture6BDACA - Lecture6
BDACA - Lecture6
 
BDACA - Tutorial5
BDACA - Tutorial5BDACA - Tutorial5
BDACA - Tutorial5
 
BDACA - Lecture4
BDACA - Lecture4BDACA - Lecture4
BDACA - Lecture4
 
BDACA - Tutorial1
BDACA - Tutorial1BDACA - Tutorial1
BDACA - Tutorial1
 
BDACA - Lecture1
BDACA - Lecture1BDACA - Lecture1
BDACA - Lecture1
 
BDACA1617s2 - Lecture6
BDACA1617s2 - Lecture6BDACA1617s2 - Lecture6
BDACA1617s2 - Lecture6
 
BDACA1617s2 - Lecture 1
BDACA1617s2 - Lecture 1BDACA1617s2 - Lecture 1
BDACA1617s2 - Lecture 1
 
Media diets in an age of apps and social media: Dealing with a third layer of...
Media diets in an age of apps and social media: Dealing with a third layer of...Media diets in an age of apps and social media: Dealing with a third layer of...
Media diets in an age of apps and social media: Dealing with a third layer of...
 
Conceptualizing and measuring news exposure as network of users and news items
Conceptualizing and measuring news exposure as network of users and news itemsConceptualizing and measuring news exposure as network of users and news items
Conceptualizing and measuring news exposure as network of users and news items
 
Data Science: Case "Political Communication 2/2"
Data Science: Case "Political Communication 2/2"Data Science: Case "Political Communication 2/2"
Data Science: Case "Political Communication 2/2"
 
Data Science: Case "Political Communication 1/2"
Data Science: Case "Political Communication 1/2"Data Science: Case "Political Communication 1/2"
Data Science: Case "Political Communication 1/2"
 
BDACA1516s2 - Lecture4
 BDACA1516s2 - Lecture4 BDACA1516s2 - Lecture4
BDACA1516s2 - Lecture4
 
BDACA1516s2 - Lecture1
BDACA1516s2 - Lecture1BDACA1516s2 - Lecture1
BDACA1516s2 - Lecture1
 
Should we worry about filter bubbles?
Should we worry about filter bubbles?Should we worry about filter bubbles?
Should we worry about filter bubbles?
 

Kürzlich hochgeladen

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 

Kürzlich hochgeladen (20)

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 

BDACA1617s2 - Lecture 2

  • 1. You are encouraged to start up a Python environment (like Spyder or Jupyter Notebook). If you do so, you can try out the examples while listening. If you prefer to listen only, that’s fine as well.
  • 2. Basics Exercise Next meetings Big Data and Automated Content Analysis Week 2 – Monday »Getting started with Python« Damian Trilling d.c.trilling@uva.nl @damian0604 www.damiantrilling.net Afdeling Communicatiewetenschap Universiteit van Amsterdam 13 February 2017 Big Data and Automated Content Analysis Damian Trilling
  • 3. Basics Exercise Next meetings Today 1 The very, very, basics of programming with Python Datatypes Functions and methods Indention: The Python way of structuring your program 2 Exercise 3 Next meetings Big Data and Automated Content Analysis Damian Trilling
  • 4. The very, very, basics of programming You’ve read all this in chapter 4.
  • 5. Basics Exercise Next meetings Datatypes Python lingo Basic datatypes (variables) int 32 float 1.75 bool True, False string "Damian" Big Data and Automated Content Analysis Damian Trilling
  • 6. Basics Exercise Next meetings Datatypes Python lingo Basic datatypes (variables) int 32 float 1.75 bool True, False string "Damian" (variable name firstname) "firstname" and firstname is not the same. Big Data and Automated Content Analysis Damian Trilling
  • 7. Basics Exercise Next meetings Datatypes Python lingo Basic datatypes (variables) int 32 float 1.75 bool True, False string "Damian" (variable name firstname) "firstname" and firstname is not the same. "5" and 5 is not the same. But you can transform it: int("5") will return 5. You cannot calculate 3 * "5" (In fact, you can. It’s "555"). But you can calculate 3 * int("5") Big Data and Automated Content Analysis Damian Trilling
  • 8. Basics Exercise Next meetings Datatypes Python lingo More advanced datatypes Note that the elements of a list, the keys of a dict, and the values of a dict can have any datatype! (It should be consistent, though!) Big Data and Automated Content Analysis Damian Trilling
  • 9. Basics Exercise Next meetings Datatypes Python lingo More advanced datatypes list firstnames = [’Damian’,’Lori’,’Bjoern’] lastnames = [’Trilling’,’Meester’,’Burscher’] Note that the elements of a list, the keys of a dict, and the values of a dict can have any datatype! (It should be consistent, though!) Big Data and Automated Content Analysis Damian Trilling
  • 10. Basics Exercise Next meetings Datatypes Python lingo More advanced datatypes list firstnames = [’Damian’,’Lori’,’Bjoern’] lastnames = [’Trilling’,’Meester’,’Burscher’] list ages = [18,22,45,23] Note that the elements of a list, the keys of a dict, and the values of a dict can have any datatype! (It should be consistent, though!) Big Data and Automated Content Analysis Damian Trilling
  • 11. Basics Exercise Next meetings Datatypes Python lingo More advanced datatypes list firstnames = [’Damian’,’Lori’,’Bjoern’] lastnames = [’Trilling’,’Meester’,’Burscher’] list ages = [18,22,45,23] dict familynames= {’Bjoern’: ’Burscher’, ’Damian’: ’Trilling’, ’Lori’: ’Meester’} dict {’Bjoern’: 26, ’Damian’: 31, ’Lori’: 25} Note that the elements of a list, the keys of a dict, and the values of a dict can have any datatype! (It should be consistent, though!) Big Data and Automated Content Analysis Damian Trilling
  • 12. Basics Exercise Next meetings Functions and methods Python lingo Functions Big Data and Automated Content Analysis Damian Trilling
  • 13. Basics Exercise Next meetings Functions and methods Python lingo Functions functions Take an input and return something else int(32.43) returns the integer 32. len("Hello") returns the integer 5. Big Data and Automated Content Analysis Damian Trilling
  • 14. Basics Exercise Next meetings Functions and methods Python lingo Functions functions Take an input and return something else int(32.43) returns the integer 32. len("Hello") returns the integer 5. methods are similar to functions, but directly associated with an object. "SCREAM".lower() returns the string "scream" Big Data and Automated Content Analysis Damian Trilling
  • 15. Basics Exercise Next meetings Functions and methods Python lingo Functions functions Take an input and return something else int(32.43) returns the integer 32. len("Hello") returns the integer 5. methods are similar to functions, but directly associated with an object. "SCREAM".lower() returns the string "scream" Both functions and methods end with (). Between the (), arguments can (sometimes have to) be supplied. Big Data and Automated Content Analysis Damian Trilling
  • 16. Basics Exercise Next meetings Functions and methods Writing own functions You can write an own function: 1 def addone(x): 2 y = x + 1 3 return y Functions take some input (“argument”) (in this example, we called it x) and return some result. Thus, running 1 addone(5) returns 6. Big Data and Automated Content Analysis Damian Trilling
  • 17. Indention: The Python way of structuring your program
  • 18. Basics Exercise Next meetings Indention Indention Structure The program is structured by TABs or SPACEs Big Data and Automated Content Analysis Damian Trilling
  • 19.
  • 20. Basics Exercise Next meetings Indention Indention Structure The program is structured by TABs or SPACEs 1 firstnames=[’Damian’,’Lori’,’Bjoern’] 2 age={’Bjoern’: 27, ’Damian’: 32, ’Lori’: 26} 3 print ("The names and ages of these people:") 4 for naam in firstnames: 5 print (naam,age[naam]) Big Data and Automated Content Analysis Damian Trilling
  • 21. Basics Exercise Next meetings Indention Indention Structure The program is structured by TABs or SPACEs 1 firstnames=[’Damian’,’Lori’,’Bjoern’] 2 age={’Bjoern’: 27, ’Damian’: 32, ’Lori’: 26} 3 print ("The names and ages of these people:") 4 for naam in firstnames: 5 print (naam,age[naam]) Don’t mix up TABs and spaces! Both are valid, but you have to be consequent!!! Best: always use 4 spaces! Big Data and Automated Content Analysis Damian Trilling
  • 22. Basics Exercise Next meetings Indention Indention Structure The program is structured by TABs or SPACEs 1 print ("The names and ages of all these people:") 2 for naam in firstnames: 3 print (naam,age[naam]) 4 if naam=="Damian": 5 print ("He teaches this course") 6 elif naam=="Lori": 7 print ("She is a former assistant") 8 elif naam=="Bjoern": 9 print ("He helped teaching this course in the past") 10 else: 11 print ("No idea who this is") Big Data and Automated Content Analysis Damian Trilling
  • 23. Basics Exercise Next meetings Indention Indention The line before an indented block starts with a statement indicating what should be done with the block and ends with a : Big Data and Automated Content Analysis Damian Trilling
  • 24. Basics Exercise Next meetings Indention Indention The line before an indented block starts with a statement indicating what should be done with the block and ends with a : Indention of the block indicates that Big Data and Automated Content Analysis Damian Trilling
  • 25. Basics Exercise Next meetings Indention Indention The line before an indented block starts with a statement indicating what should be done with the block and ends with a : Indention of the block indicates that • it is to be executed repeatedly (for statement) – e.g., for each element from a list Big Data and Automated Content Analysis Damian Trilling
  • 26. Basics Exercise Next meetings Indention Indention The line before an indented block starts with a statement indicating what should be done with the block and ends with a : Indention of the block indicates that • it is to be executed repeatedly (for statement) – e.g., for each element from a list • it is only to be executed under specific conditions (if, elif, and else statements) Big Data and Automated Content Analysis Damian Trilling
  • 27. Basics Exercise Next meetings Indention Indention The line before an indented block starts with a statement indicating what should be done with the block and ends with a : Indention of the block indicates that • it is to be executed repeatedly (for statement) – e.g., for each element from a list • it is only to be executed under specific conditions (if, elif, and else statements) • an alternative block should be executed if an error occurs (try and except statements) Big Data and Automated Content Analysis Damian Trilling
  • 28. Basics Exercise Next meetings Indention Indention The line before an indented block starts with a statement indicating what should be done with the block and ends with a : Indention of the block indicates that • it is to be executed repeatedly (for statement) – e.g., for each element from a list • it is only to be executed under specific conditions (if, elif, and else statements) • an alternative block should be executed if an error occurs (try and except statements) • a file is opened, but should be closed again after the block has been executed (with statement) Big Data and Automated Content Analysis Damian Trilling
  • 29. Basics Exercise Next meetings We’ll now together do a simple exercise . . . Big Data and Automated Content Analysis Damian Trilling
  • 30. Basics Exercise Next meetings Next meetings Big Data and Automated Content Analysis Damian Trilling
  • 31. Basics Exercise Next meetings Wednesday We will work together on “Describing an existing structured dataset” (Appendix A). Preparation: Make sure you understood all of today’s concepts! Big Data and Automated Content Analysis Damian Trilling