Month: December 2016

PyLadies December Meetup

This meetup was going to be a Python 101 session as decided in the last one. The PyLadies had to pick up any topic of interest from the list posted by Nisha on the Pyladies google group. I had picked up the topic Tuples, Sets and Dictionaries. As most of us had our exams going in the last month, we didn’t get much time to prepare and therefore, the session was taken by Kushal.

Kushal began with telling us the basics of Python for e.g. unlike other languages, there is no need to mention the data type in Python, we don’t have curly braces to mark the beginning and end of a block of code, everything we write has to be properly indented and various other points to be kept in mind while coding in Python. We began with writing very basic code like printing numbers from 1 to 10, printing the sum of numbers from 1 to 10 and printing various patterns using “*”. After learning about how to use the loops ( while and for loop) and learning about the conditional statements (if…else), Kushal taught us about the Lists. We then learnt about the methods like append(), insert(), sort(), max(), remove() and pop() that are used with the list objects and wrote some functions like :-

> def add(a, b):
…     return a + b

>>> add(5,4)

>> add(9)
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
TypeError: add() missing 1 required positional argument: ‘b’

This function simply adds up two numbers passed as arguments to the function and returns the sum. If we do not pass arguments to the function correctly, we get a TypeError as mentioned above.

>> def myfilter(numbers, n):
…     list2 = []
…     for i in numbers:
…         if i > n:
…             list2.append(i)
…     return list2

>>> myfilter([34,35,67,54,9], 50)
[67, 54]

This function takes a list (called numbers) and an integer(n) as arguments and returns a list (list2 in the above code) of numbers that are greater than n.

Kushal also gave us a problem to solve which was called “fizzbuzz”. The problem statement was:- Print the numbers upto n. If the number is divisible by 3, print fizz, if the number is divisible by 5, print buzz and if the number is divisible by both 3 and 5, print fizzbuzz.

Here is the solution to the problem :-

#!/usr/bin/env python3
n = 1
while n < 101:
    if n % 3 == 0 and n % 5 == 0:
        print(“fizz buzz”)
    elif n % 3 == 0:
    elif n % 5 == 0:
    n +=1

The output of the above code is as follows:-

$ python3
fizz buzz

After learning about the lists and writing some basic codes, we had a lunch and coffee break. 😀 When we returned, we learnt how to use the Api to get various kinds of information. We used the World Population Api, to list the countries all over the world and to find the life expectancy of a person, which was real fun. 😀

This is how we did it :-

  1. To list all countries.

import requests
>>> r = requests.get(“;)  # r is the response object
>>> r.status_code
200                                                                                        #response code 200 means OK
>>> print(r.text)                                                                # to see the html of the website
>>> r = requests.get(“;)
>>> r.status_code
>>> result = r.json()  #to convert the result to json format
>>> type(result)
<class ‘dict’>
>>> result.keys()
>>> countries = result[‘countries’]
>>> type(countries)
<class ‘list’>
>>> for name in countries:
…     print(name)

Antigua and Barbuda
The Bahamas



2. To find the life expectancy of a person.

>> r = requests.get(“;)
>>> r.status_code
>>> result = r.json()
>>> result.keys()
dict_keys([‘country’, ‘date’, ‘remaining_life_expectancy’, ‘age’, ‘sex’])
>>> result[‘remaining_life_expectancy’]

In the end, we had a discussion about the next meetup. Anwesha told us that we would be having a session on PyCharm (an IDE used mainly for Python) in the next month.

The Python 101 session was really helpful for all of us as it helped us recall the concepts from the very beginning.

I really enjoyed this meetup and look forward to the next meetup in January. 🙂





Pyladies November meetup.

Like every month, the Pyladies met this month too. I was really looking forward to this meetup as we were going to learn about how to create our own map using GeoJSON and the basics of Git. The meetup started with a session on Git by Sayan Chowdhury. He gave us a brief introduction of Git, why it is used and how it is beneficial. We started by making our own project and moving it to github.

Here are some commands we used:-

  1. git init :- This initializes git in the directory.
  2. git config –global ‘your_userame’ :- Configure your username.
  3. git config –global ‘your_emailid’ :- Configure your email.
  4. git status :- To check the status of the repository.
  5. git add <filename> :- Add files for Git to track.
  6. git commit -m “The message you want to show” :- To commit the changes to Git.
  7. git diff :- To check the changes since last commit.
  8. git log :- To check the changes made to your project since the beginning.
  9. git remote add origin <url> :- To push your code to a remote server.(e.g. Github)

We also learnt how to create a .gitignore file. If you create a .gitignore file in your repository, Git uses it to determine which files and directories to ignore before making a commit. Sayan also told us about Pull Requests (PR). We forked his pyladies project and after making some changes to the file in this repository, we sent a PR to it.


After this, we had a session by Nisha on how to create maps using GeoJSON. It was really a interesting and new concept. She told us where we can use these maps, and amongst many examples, the one which I liked the most was the idea of using a map for your CV. She showed us the CV of a girl who used a map to mark her educational institutes and also the places she had worked so far. Nisha also told us about GIS, leaflet etc. and explained to us how we could start mapping using github.

The session ended with a discussion about Pycon Pune which is going to be held in February 2017. Also, the date and topic for next month’s meetup was decided and before leaving, we took a group photo with all the Pyladies. 🙂

P.S. :- Here is a link for learning more about Git : –