Слайд 2
Structure
Key points of the Meeting III: English
meeting
Quick recap of Meeting II
Recursion
Tuples
Lists
Dictionaries
Meeting V = Midterm!
Meeting III
10 Words
Office Hours II – this time collective struggle
Preparation for Midterm!
Слайд 3
Recap of Meeting I & Meeting II
Functions
Functions:
Definitions
Methods
Bisection search
Variables
Types of variables
For loops
While loops
Conditional statements
Declarative and Imperative
knowledge!
Слайд 5
Recursion
Recursion is a way of programming or
coding a problem, in which a function calls itself
one or more times in its body.
Слайд 6
Recursion: finding factorial
def recursive_factorial(n):
if n == 1:
return
1
else:
return n*recursive_factorial(n-1)
def iterative_factorial(n):
result = 1
for i in range (2,
n+1):
result *= i
return result
Iteration
Recursion
vs
Слайд 7
Recursion
A recursive function has to terminate to
be used in a program. A recursive function terminates,
if with every recursive call the solution of the problem is downsized and moves towards a base case. A base case is a case, where the problem can be solved without further recursion. A recursion can lead to an infinite loop, if the base case is not met in the calls.
Слайд 8
Tuples, lists, dictionaries/dicts
Слайд 9
Tuple: ()
ninjaTurtlesTuple = (‘Michelangelo’, ‘Leonardo’, ‘Donatello’, ‘Rafael’)
Empty
tuple: ()
Important property: It is ordered
Can index: ninjaTurtlesTuple [1]
= ‘Leonardo’
Immutable (we can’t add ‘Splinter’ and we can’t change ‘Rafael’ to ‘Shrek’)
Mix of element types, it could be:
ninjaTurtlesTuple = (‘Michelangelo’, ‘Leonardo’, ‘Donatello’, ‘Rafael’, 3, 4.5)
Funky stuff: ninjaTurtlesTuple[1:2] = (‘Leonardo’, )
Слайд 10
List: []
ninjaTurtlesList = [‘Michelangelo’, ‘Leonardo’, ‘Donatello’, ‘Rafael’]
Empty
list: []
Ordered
Can index: ninjaTurtlesList[1] = ‘Leonardo’
Mutable! We CAN add
‘Splinter’! We CAN change elements!
Mix of element types, it could be:
ninjaTurtlesList = [‘Michelangelo’, ‘Leonardo’, ‘Donatello’, ‘Rafael’, 3, 2.66]
No funky stuff: ninjaTurtlesList[1:2] = [‘Leonardo’]
Слайд 12
Dictionary: {}
ninjaTurtlesDict = [‘Michelangelo’ : ‘Leader’, ‘Leonardo’
: ‘Sniper’, ‘Donatello’ : ‘Explosives’, ‘Rafael’ : ‘Medic’]
Empty dictionary:
{}
There is a key
‘Michelangelo’ – key0, ‘leader’ – val0
Mutable! We CAN add ‘Splinter’ : ‘Chief’!
ninjaTurtlesDict[‘Splinter’] = ‘Chief’
Quickly check:
In: ‘Givi’ in uselessSeparatistsDict (!!!!!!!!!!!!!HILARIOUS, 26.01.2017!!!!!!!!!!!)
Out: False
Слайд 13
HILARIOUS!!! In January it was:
Слайд 14
…and in 1 week it became! :-D
Quickly check:
In: ‘Givi’ in uselessSeparatistsDict
(!!!!!!!!!!!!!HILARIOUS, 26.01.2017!!!!!!!!!!!)
Out: False
Слайд 15
Meeting III: 10 words
Key points of the
second meeting
Quotes - лапки
Curly braces – фігурні скобки
Square brackets
– квадратні скобки
Alias – «псевдонім» (дзеркало)
Tuple – кортеж
To append - приєднати
To extend – продовжити
To split – розділити, розколювати
Pointer – вказівник
Tutor - репетитор
Слайд 16
Homework till Meeting IV (09/02/17)
Homework for the
following week
PSet2 for “less comfortable” + listen Lecture 5
& Lecture 6
Pset3 for “more comfortable”
Create GitHub account for “more comfortable”
START YOUR PREPARATION FOR MIDTERM!!! ☺
Слайд 17
Midterm: 29.06.2017
Key points:
You can use laptop
You can
google. But everything can be solved just by your
memory.
Don’t be afraid – minor mistakes will not count
Слайд 18
Office Hours II
America House, Saturday, 17/06/2017, 10:00 –
14:00…but w/o me ☺
Ukraine, Mykoly Pymonenka St, 6,
Київ
Don’t forget Passport/Driving License!
Andrey: 050 44 33 585