0% found this document useful (2 votes)
1K views17 pages

VLSI CAD Python Tutorial

This document provides an overview of key Python concepts including: 1. Lists - Ordered collections that can be created and manipulated using built-in methods. Examples demonstrate creating lists and performing operations like joining and removing elements. 2. Dictionaries - Collections of key-value pairs that can be indexed by keys. Examples show creating dictionaries from data and sorting/removing entries. 3. Functions - Analogous to functions in other languages, with syntax and examples of passing arguments by reference. 4. Classes - Analogous to classes in C++ with syntax and examples of inheritance between classes for vector transformations. 5. Exercises - Examples provided to find topological sorting using AAT recursion and calculating R

Uploaded by

aswin1990
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (2 votes)
1K views17 pages

VLSI CAD Python Tutorial

This document provides an overview of key Python concepts including: 1. Lists - Ordered collections that can be created and manipulated using built-in methods. Examples demonstrate creating lists and performing operations like joining and removing elements. 2. Dictionaries - Collections of key-value pairs that can be indexed by keys. Examples show creating dictionaries from data and sorting/removing entries. 3. Functions - Analogous to functions in other languages, with syntax and examples of passing arguments by reference. 4. Classes - Analogous to classes in C++ with syntax and examples of inheritance between classes for vector transformations. 5. Exercises - Examples provided to find topological sorting using AAT recursion and calculating R

Uploaded by

aswin1990
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Python Tutorial

EE677 Foundations of VLSI CAD

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

Fibonacci - Basic example


Print statements
For loops
Indentation for for/if
Commenting precedes with #

List : Concept and Methods


A list is an ordered collection of zero or more references to Python data
objects. Lists are written as comma-delimited values enclosed in square
brackets. The empty list is simply [ ].

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

Print the output in each case and analyse the results

Dictionary : Concept and Methods


Dictionaries are collections of associated pairs of items where each pair
consists of a key and a value. This key-value pair is typically written as
key:value

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.

Create a dictionary with 5 entries of your friends roll numbers indexed


with their names as keys
Sort the dictionary alphabetically and save as a list
Remove the entry of your best friends roll number

Functions
Analogous to functions in C/C++
Syntax:

Arguments are passed by reference

Using Functions
Refer to the example function_example.py given

Functions - Argument Passing


Please run the script function_ref.py in your python console
Observe the output, Is it different? If so, Why?

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.

Use classes for calculating angle between 2 vectors in x-y coordinate


system.

2.

Use inheritance to transform vectors from cartesian to polar coordinate


system.

AAT and topological sort exercise


Find the topological sort by calculating the AAT with unit delay at all the nodes
Refer to file: aat_recursive_exercise.py

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy