Académique Documents
Professionnel Documents
Culture Documents
Contents
Basic Example : Fibonacci
List
Dictionary
Function (Fibonacci example with function)
Fibonacci with memoization (modify existing code)
Classes
Find topological order using AAT recursive (unit delay, and sort by AATs)
RAT recursive (first generate fanout lists from fanin lists)
Source: http://interactivepython.org/runestone/static/pythonds/Introduction/GettingStarted.html
List : Demo
Refer to list_demo.py
Lists: Exercise
If you do not feel comfortable with lists, refer the lists section in the link
Write a python script using Lists to do the following tasks and discuss your
results:
1.
2.
3.
Create 2 lists (A & B) with 5 entries of numbers that are multiples of the
last 2 digits of your roll no.
Join the list and remove duplicate occurrences of elements in the joined
list - List1
Copy this created list into another list (List2) and remove the elements
that are lesser than the mean of the List1; print List1 and List2
Dictionary : Demo
Refer to dict_demo.py
Dictionary: Exercises
If you do not feel comfortable with lists, refer the lists section in the link
Write a python script using Dictionary to do the following tasks and discuss
your results:
1.
2.
3.
Functions
Analogous to functions in C/C++
Syntax:
Using Functions
Refer to the example function_example.py given
Classes
Analogous to classes in C++
Syntax
Inheritance
Use same data members and functions as of parent class
Parent:
Child:
#Call superclass const.
Inheritance
1.
2.
RAT exercise
Given the AAT_recursive code and an RAT of 20 at the final node, write a
Python script to find the RAT at all the nodes of the same graph