Skip to content

Latest commit

 

History

History

2

Introduction to Python

Hey Guys! Welcome to session 2. Today we will start working on Python-an introduction on some fundamental datatypes like lists, dictionaries, etc. We will also look into loops, functions and classes in Python. Finally we will also look on how Python allocates memory which an interesting topic which all of you must definitely check out.

We will having today's sessions on Jupyter Notebooks. Hope you all didn't face any issues while setting up python. If you do, please do post your issues on the issues tab.

Links to the Notebooks:

Some slides as well for your reference - link


GIT Setup and references


Tasks for the day:

Task 1

Write a program to print a fibonacci triangle. - Given a number n (i.e) number of lines the program must output a Fibonacci triangle.

For example:

Input : n = 5 
Output :
1 
1 2 
3 5 8 
13 21 34 55 
89 144 233 377 610 

Input : n = 7
Output :
1 
1 2 
3 5 8 
13 21 34 55 
89 144 233 377 610 
987 1597 2584 4181 6765 10946 
17711 28657 46368 75025 121393 196418 317811 

Task 2

Write a program to find all possible permutations of a given list.

Given a list [1,2,3]

Output:

[(1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1)]

Note: There is a library in python to do this as well. We expect you to try both methods and come up with a solution by defining a function on your own as well as identify the function

Solutions have been updated link


Note:

For the case of these tasks I suggest everyone to please fork this repository to your personal GitHub page and create a python file on the corresponding day to solve the above task on that repository. Once done, please add the files on to your forked repository and make a pull request.

We will be going through all your codes and we will be checking them out. Once everyone puts their codes, we will be choosing the best one and merging the code to the main repository here.

We encourage you to do this as this will give you an understanding of GitHub as it very important and necessary. Next you will also be able to see everyones codes by clicking on the pull requests tab of this repo and we will ensure to reply and suggest improvements for everyone.

Please do make best use of this opportunity and feel free to communicate with us.