Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Tuesday, 4 April 2017

A well occupied Weekend (Pyladies and Python-Pune)

Weekend as the word comes to our mind, we are like lot of fun and time to relax. Same I did this weekend, infact lot more than this. As I attended two meetups Pyladies and Python Pune, and it was more fun as they were organised at Reserved Bit, which I personally love to visit.

Pyladies
Saturday(25th March 17) We had our  Pyladies meetup, and for this meet up we had planned to have a discussion among us, so that we can share our experience and discuss about our projects ideas. This meet up was basically organised so that we can get ideas about different projects we can work on. So we all were there by 11 am. When I reached and look around, I realized few known faces were missing from the meetup, later came to know they were having some work in college. But the good part was that we were having lot of new members this time who were working in different organisation. Also we had people who were familiar with embedded( electronics). As this was a discussion session we discussed about Pycon-Pune, which I was not able to attend :(. But most of them attended it and shared their experience. I shared my experience how I stared my journey with Python and so on.. 
Lot of ideas were discussed, also I got to know some of them were interested in automation, so I decided to take a session on it as I am currently working on automation using different framework like Robot Framework, Behave. Anwesha discussed about her project "Bunny Uncle" upon which she worked in Pycon-Pune. So we ended up discussing about the projects which we can work upon in our next meetup.

Python-Pune
Sunday(26th March 17) As it was Sunday I want to sleep a little more, but the topic of the meetup made me to wake up that day. Raspberry-Pi as till now I have only heard of it from many people but didn't got a chance to work with it. So this meetup was a platform to start with it. It was also at Reserved Bit. After we all were set Girish and Chandan started with the session. They introduced us to Raspberry-Pi and shared a doc how we can get started with it. So we started with installing raspbian/ubuntu on memory card.
Here are the steps shared by Girish. which we followed:

install raspbian/ubuntu on memory card.
    $ df
    after this you will get the mmcblock file.
    
then unmount the memorycard partition using umount.
    $ umount /media/<user>/<partition>

format the memorycard with Fat32 filesystem.
    $ sudo mkdosfs -F 32 -v /dev/mmcblk0
    
now copy the raspbian/ubuntu on memorycard using dd.
    $ sudo dd bs=1M if="osImage.img" of=/dev/mmcblk0
    

to connect to the wifi network
    $ vim etc/network/interfaces
        auto wlan0
        allow-hotplug wlan0
        iface wlan0 inet manual
            wpa-ssid "reserved-bit"
            wpa-psk "8tn6r23eskasm"
        wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

to enable ssh
    $ touch /etc/SSHFLAG
    
    $ vim /etc/rc.local
    
      if [ -e /etc/SSHFLAG ]; then
          /usr/sbin/update-rc.d -f ssh defaults
          /bin/rm /etc/SSHFLAG
          /sbin/shutdown -r now
      fi
      
      sudo /etc/init.d/ssh start
      exit 0
      
to start vnc session
    $ sudo apt-get install tightvncserver
    
    $ vncserver :1 -geometry 1024x768 -depth 24 -dpi 96

      You will require a password to access your desktops.
      Password: 
      Warning: password truncated to the length of 8.
      Verify:   
      Would you like to enter a view-only password (y/n)? n

first get update.
    sudo apt-get update

then install python-dev
    sudo apt-get install python-dev

try if RPi.GPIO is there in python packages.
    import RPi.GPIO as gpio

check the version of GPIO

After this we were able to ssh to our pi and were ready to play with it. Upto this it was the time for lunch which was already there from Rajdhani arranged by Python Pune group only.
After this came the electronics part for which Nikhil took over the session. We started with very simple program to glow a led. Then we added a switch to control the led. So it was fun modifying our code and have different pattern in which led was glowing. A simple program for led and button is as below:

from RPi import GPIO as io import time io.setmode(io.BOARD) io.setup(18, io.IN, pull_up_down=io.PUD_DOWN) io.setup(16, io.OUT) def check_button_state(): while True: if io.input(18) == 1: print("pressed") io.output(16, io.LOW) time.sleep(1) io.output(16, io.HIGH) else: pass try: check_button_state() except: print 'except'
io.cleanup()


A day out with raspberry pi and Python was great Fun!! :) 


Monday, 16 January 2017

First Pyladies meetup of year 2k17(Jan)


I was not able to attend last Pyladies(Dec) meetup as I was having my badminton match, this time also I had my Dance practice for office annual party therefore I reached a little late, but still I was happy as I was able to attend it. When I stepped in, the whole room was full and I felt  good to see all. Then I took a seat at the back row, as whole room was already filled.
The topics for that meetup were:
Kushal session on System Programming was going on when I reached, so I quickly turned on my laptop and get started. As time was less as we also had a guest session by Paul Everitt (PyCharm Developer Advocate at JetBrains) on Pycharm. So Kushal ended the session on defined time and planned to take more session on System Programming later. Then he made the setup for Paul as he was taking a live session whom I  met in Pycon India 2016 in Delhi. More people joined us later for the session. As it was early morning for Paul there was snowfall also, still he managed to get up early in such a chilled weather, thanks to him for that. He started with what we are going to do in this session and it was interesting as we were going to write a game of collecting coins using an arcade library of python using Python 3.6 in PyCharm. He covered several skills like:
  • Running Python code in pycharm
  • Using Version control using Pycharm
  • Debugging
  • Writing test cases
  • Test coverage
Then he started with the setup by installing all the dependencies, it was so easy using Pycharm as PyCharm itself installed and imported it for him.  Then it was available for use. Then he showed us how we can run our Python code in Pycharm followed by how we can put our code under a local git repository and further commit changes. Also he covered the branches in version control using which many people can work on a single project individually. Then he talked about debugging as it is most important if we are writing code. The game was ready as the image was able to move and collect coins as a result score was increasing using collision detection, that was interesting. Also he covered  Debugging, testing and test coverage. You can find the video here. Also he took questions in between by chat and answered them to clarify our queries. This game reminded me of a game Mario which we use to play in our childhood, we wondered how the boy move and collects coins, treasure and our score go up and see now I know how it worked ,in fact I can myself write a game now, that's so easy. This session was so interesting, loved it :).

Once again thanks Paul for such a wonderful session and also Thanks to Kushal and Anwesha for organising this guest session. Hope in future also you will come up with these types of session, really enjoyed it.

Thursday, 24 November 2016

Pyladies November Meetup

After a long festive season(Diwali) we had our Pyladies Meetup on 13th Nov at RedHat office and it was so good to see new faces as the number of Pyladies were increasing with each meetup. As always I was excited about the meetup and to learn about Creating our own Map using GeoJSON and more about Git as these were the Topics for this meetup which Nisha have mailed us. So the meetup started with a session on Git by Sayan Chowdhaury. Starting with the basic introduction to Git like what it is, why we need it, whats are benefits, he started the session. It is very important if we want to contribute to upstream or any projects. Here are fews benefits of using it :
  • Easy collaboration
  • Work Offline
  • Contribute to any open source project
So we started with initiating our own project named “Pyladies” and then moving it to github. Also he told us how we can send PR(Pull Request), so we forked his Pyladies project and send a PR to it. We all learned the basics commands of git like:
  • git init
  • git config --global user.name “username”
  • git config --global user.email “userEmail”
  • git add <filename>
  • git commit -m "Commit message"
  • git push origin master
  • git status
  • git remote add origin <server>
  • git checkout -b <branchname>
  • git fetch origin
Sayan also told a site which we can refer for learning more about git through git tower.

After this we had a break as it was lunch time and our hungry tummy needs something to continue with learning new stuffs . After the break Nisha came up, as I told there were lots of new faces it was their first meetup, so there was a introduction session where she brief about how we started and what we do in the meetups. Then we all introduced ourself to each other. After this she started with her talk talking about spatial data and how we can map anything related to our own life to many others crucial information like she have mapped the number of accidents in different cities. Also she gave an excellent example that how we can use map in our CV too, she showed us a CV in which the person has marked his educational institutes and places of work where she had worked till now geographically, and it really sounds interesting. She told us about how we can start with it and explained about  GIS, mapbox, leaflet etc. To make us started she explained how we can start mapping using github as all of us have learned git in the previous session so it was a good idea. All we had to do was:
  1. Convert the CSV format file to geoJSON(for this we can either write a script in python or use any other method)
  2. Then we have to upload that geoJSON file to github.
  3. Then view map on github
  4. Map renders magically.

So to practice she mailed us an CSV file which we can use to create  our own map as an assignment. The meetup ended with a discussion on the next meetup, I was not able to be a part of that discussion because I have to go with Praveen, he was having his Football match as Redhat Annual Sports were going on. So we left saying bye to all Pyladies, and looking forward to meet them all in sixth Pyladies meetup.
How can we forget Pycon Pune which is in February(16th -19th), excited to meet all the Pyladies and many more people from various communities. So hurry up just grab your ticket as time is running out so as tickets.

Monday, 14 November 2016

Pyladies- October Meetup

Like every month we meet up for this month also, this time it was for half day only but it was very special as we were having Hong Phuc Dang  founder FOSSASIA with us.


 It was a great experience to meet her, as she shared a lot of things with us and also tell us about FOSSASIA, what it is and how we can contribute to it. She encouraged the pyladies to be a part of open source and start contributing to it. Also She invited us to FOSSASIA which is in Singapore from 17th to 19th March. After her talks there were lightening talks from Pyladies which was decided by Anwesha in our last meeting that we will have lightening talks in every meetups as most of us are afraid of speaking in Public so to overcome that fear this session was started from this meetup and will be continued... So our first speaker was Samriddhi who is a student, she shared her experience and about Pyladies. Next was my turn I was ready with my Presentation, so quickly after setting up, I started with a brief introduction of mine and then continued with the topic which was "Difference between Python2 and Python-3.


After talks, now it was Kushal who was going to take a workshop on building shell with cmd2 module, so we all were set with our laptops in which we have installed cmd module. Then we learnt how to build our own shell and it was interesting to build a shell and play with it. All of us practiced that and solved the problem given by Kushal. Upto that time Kushal has ordered Pizza for us. Then it was the time for Pizza Party and as always we had a very good discussion during that time. Hong Phuc Dang gave us more ideas on how we can lift our self up in the open source community and many other information.And this is how the meetup ended with a plan to meet in November :)

Friday, 30 September 2016

Pyladies in pycon-india



umbrella1.jpg
Pyladies, a chapter lost in the darkness got a spark in Pune(India) when Anwesha, Nisha, Rupali decided to open that closed chapter and lighten the Pyladies community with its light. Hats off to their courage as Anwesha and Nisha have small daughter, and it’s really difficult to manage anything with kids but still they are giving their time to Pyladies, I have to learn a lot from them as in this busy world why would anyone care of about anything so much, especially when it has lost its existence. But these ladies reopen the Pyladies-Pune Chapter and made it a success. A community which was unknown in India a few days back, is now known and people are talking about. They want to know more about it, want to be a part of it and contribute in one way or other. All this happen after our efforts in Pycon. Pycon was a great success for  Pyladies, also Pyladies was one of the reason for which I went to Pycon India.

Pyladies, I came know about it when the Pune-chapter was restarted and I attended its first meetup in July. As I was also new to Python and programming, so I became a part of it and started waiting for the date of next meetup announced on the mailing list. Till now we are meeting once in month but can also think of twice in a month if possible. After we had started meeting regularly, we wanted Pyladies in Pycon India so that the people come to know about it, so we planned to set up a booth in Pycon India, but plans doesn’t go smoothly every time, and same was a case with us when Anwesha told us that she had applied for a booth in Pycon India in August and they have  refused us to give space as there is no space available for the Pyladies booth as we were not the sponsors  and here comes the sorrow :-( . Then comes Rupali like a life saver to Pyladies, offering us a space, as Red Hat was ready to give us space in its booth, then we were like no one can stop us from being a part of Pycon India, and there our faces were like :-).

So here come the day, we were waiting for 24th September 2015, and we were at JNU convention centre venue for Pycon. After registration I directly went to Red Hat booth where we were going to set up our Pyladies table. After inspecting the space I had a cup of coffee and then went for the Keynote by Baishampayan Ghose, by that time Anwesha and Nisha were also there, it was great keynote, learnt a lot from it. After attending the talk, we all pyladies rushed to the booth to set up our table. So first thing was that how to show our presence there, as we were not having pyladies t-shirt to promote it, but that problem was solved by Trishna, as she has brought pyladies print out. So we planned to put them on our t-shirts, and then we either pinned it up or paste it so that people came to know about it. We all quickly cut those logos and put them on our T-shirts.  These logos grabbed the attention of people present there. Then comes the Pyladies Umbrella which was a point of attraction for the public, thanks to Nisha for that, as she carried it along the way from Pune to Delhi. The leds present were not glowing when we switched it on, that was a little disappointment for us. Then Praveen came to help us, and he was successful in it, leds were lightening so were our faces. It was very beautiful, and that can be seen in the pictures as how everyone is posing with it, I liked it so much that I was the first to click a pic with it :P.
pooja.jpg

Then we started telling people what actually Pyladies is and how we are organizing meetups. Anwesha was going to people to tell them about Pyladies, I and Nisha were at booth for the people who were coming there, and answering their questions as we were new, and it was just a beginning, so many question were there for us like:
  • What is Pyladies?
  • Is it only for ladies?
  • How we can join or contribute to it?
  • Is it for Pune only?
  • Can we have Pyladies in our own city?
And many more………
Every question was answered and it was good to see that people are showing their interest in Pyladies. In between I attended few talks also and keynote by Van. So the first day ended explaining what we are and what we do at Pyladies.

Then comes the second day of Pycon, attended the keynote by Andreas Mueller in morning. After seeing such a great response for Pyladies, we decided for a talk in Open Space so that we can address everyone interested and can get some ideas and insights for our group for its further growth as we all were new. Janki helped us to get a space for us in open space. Kushal and Praveen helped to setup for the discussion. Paul Everitt, Jeff Rush, Van Lindberg and Dmitry Filippov were approached for it, and they were ready to give their time to our group, that was so sweet of them.
dis.jpg

The talk was started with a brief introduction of Pyladies and its current state by Rupali. Then the discussion started which was really the best part of Pyladies in Pycon as we got a lot new ideas for our community and we were able to communicate our thoughts to the people present there about Pyladies. Paul, Jeff, Dmitry and Van shared their personal experience  and gave us the useful tips to make Pyladies a Success, they were also impressed by seeing us doing such a great job for our group. Then we distributed the slips where we have written the email-ids for joining Pyladies and the mailing list. So it was good session and thanks all for joining it and providing their insights.

pyladies.jpg


In the end there was a feedback session, where Anwesha asked for a space for Pyladies in next Pycon, hope we will get our space the next year for Pyladies. Thanks to all the Pyladies for making the event a success, and we all will take Pyladies to a great height. It was a great experience attending Pycon, looking forward for next year…...

Friday, 16 September 2016

PyLadies Meetup Event Report


We had our pyladies meetup this Saturday, last week we were not able to do as in Maharashtra, there is a festival Ganesh Chaturthi, honouring the birth of Lord Ganesha it is celebrated for ten days so we planned to do meet this week instead of last week. Again it was great meetup, started with Nisha Menon’s talk “The practical usage of Python", but unfortunately I missed it this time : ( , when I reached she was about to finish. I was late as that morning I decided to try something new in breakfast ie radish parathas that took a lot of time to prepare, but that was a good experiment as they were mouth-watering. So after having a delicious parathas with curd and pickle I reached there, and took my seat, everyone was already ready with their laptop, this time there were lot of new faces, many new student had come to attend the meetup, without delaying anymore I also get started as by that time Nisha talk was ended and she invited Trishna for her session. 


She was going to take a session on “Using WEB API in Python3 “. So before starting she just confirmed how many of us were familiar with Python basics, as it was discussed in previous meetup. But still for the new members and to brush up our knowledge she revised all the basics to keep us all on a same platform. Although it was a revision session but she explained each and everything and gave time to all of us to try the different commands on our terminal and solved everyone queries. Thanks to her for that, then she discussed about the things which we were going to do in our workshop that day. She has chosen a great topic and problem for the workshop. We were going to use the API of Zomato website. It seems very interesting as it was about food, and everyone love that. So we generated an API_KEY for that, by that time it was the time for lunch, so we all went for lunch. 


Kushal and Praveen ordered lunch for us, thanks to them to fill our hungry tummy. During lunch we all had discussion on different topics related to python and other stuffs.  Also Kushal took the students for a small walk in redhat. After lunch we all gathered in the same room named Harishchandgarh which reminds me of King HARISHCHANDRA who never lied and always kept his promise. We all were set, one of us was facing problem with her laptop, as she was having a window laptop, so it was suggested by Kushal to switch to linux as it is far easy to handle problems on it and its best if we want to contribute to development side or  to any project. So for that time a laptop was arranged for her with linux. Then we all were set to start. 

Trishna made us familiar with “requests” module in python3 which is the only Non-GMO HTTP library for Python. We all installed the requests module as it was required for the session from the below commands.
  • dnf install python3-requests
So the task was we have to list out the nearby restaurants to our current location, for that we used the longitude and latitude to provide our current location. We wrote a python3  program for searching the restaurants, added to it also the url for menu and we were able to list the nearby restaurants with menu url near Magarpatta, the list was as below for restaurants names if someone want to visit any:
  • Deccan Harvest
  • Cuba Libre
  • Wah Marathi Dine N Wine
  • TGI Fridays
  • Rajdhani Thali Restaurant
  • Eagle Boys Pizza
  • Charcoal Grill
  • The Waffles Hut
  • Barbeque Nation

Then we played with the code , Trishna assigned us to find the restaurants which have chinese cuisine and we all tried that ourself and found out one restaurants from above restaurants which have chinese cuisine => Deccan Harvest
After completing it we started playing with the code to find out the various other things like finding User rating, currency accepted, photo url for different restaurants. With this the event ended, with a discussion to meet next month.

Monday, 15 August 2016

Pyladies 2nd Meetup(Pune)

After a long one month, it was the day (7 Aug) for Pyladies meetup and again we were going to meet at Redhat Pune office. As it was the day I was waiting for after the first meetup, though it was sunday when we usually plan to relax or hang out but I was excited for the meetup. So in morning I went for running in Magarpatta city(Aditi Garden) as it has a nice track for running. Then after having South-Indian breakfast at UpSouth, I came back to my home as it was time to get ready for the meetup as I was running out of time but still I managed to reach on time. When I entered the room there were many people already sat, some familiar to me as have met them in first meetup, few were new to the meetup. After saying hello to the people I also took my seat, then we shifted to the cafeteria due to some maintenance work in that room.



After we all were set, Nisha started with her talk on " Basic Communication skill", as communication is very necessary in open source world or in any community. So it was a great topic chosen by her, as it was a help to all of us in knowing the better way to communicate with the people in various communities so that we are listened and answered by others. As the way in which you communicate is very much important, she discussed about various things, as how to ask questions in a smart way. Do and don't while communicating and many more things.



After this there was a video of Keynote( Talk to talk' session) by Jacob Kaplan-Moss from Pycon 2015. Jacob Kaplan-Moss known for his work on Django and the director of security at Heroku. He begin with this intro, talked about his background and what people think about him.He  stated that "People believe that I am successful because of my programming skill. But that simply isn't true: "I am, at best, an average programmer", he said (with a slide that read "Hi, I'm Jacob, and I'm a mediocre programmer."). Then he introduced ultra-marathon runner Ann Trason, who is the most accomplished competitor in the history of that sport. He talked about Trason runs and records, he included that in his talk because he also recently finished his first 50km race, so we can say he was a runner too and I too am a runner who have just started running a month back : ). So I liked this part . Then he talked about programming abilities and how people measure that. He talked about a U shaped curve on which people distribute the programming skill and most of them are on one end or the other but  for going from absolutely terrible to wonderful we have to traverse the middle ground. After this he talked about myth about the U curve that sets up a world where you can only program if you are a rock star or a ninja. This myth is preventing "most of the growth and the improvement we'd like to see". And this motivated all of us sitting there and then he said" The truth is that programming isn't a passion or a talent, it is just a bunch of skills that can be learned". Also he added 10x programmers to his talks adding the famous picture of Linus Torvalds flipping off NVIDIA under the "brilliant asshole" label in his slide. He then asked what a 10x programmer look like and put up a series of pictures of "Mark Zuckerberg". When we see someone who does not look like one of those three men, we assume they are not a real programmer, he said. Almost all of the women he knows in the industry have a story about someone assuming they aren't a programmer. He talked to multiple women attending PyCon 2015 who were asked which guy they are there with—the only reason they would come is because their partner, the man, is the programmer. "If you're a dude, has anyone ever asked you that?" And this was a great motivation for the ladies present in pyladies meetup. He also talked about Lynn Root a founder of the San Francisco chapter of PyLadies, a Python Software Foundation board member. In the of the keynode he took several questions. It was great keynode selected for this meetup. 



After this it was the time for lunch, and during lunch time we had quite interesting conversation with each other, we all  talked about Pycon 2016( Delhi) which I am also attending and Pyladies and many more things. 

After lunch it was the time to learn some python skills. So there was a session  'Hands on Python' by Chandan Kumar. He started from where we left in the last meetup. He covered several topics like functions, different python module and file handling. So we practiced all these , ending up with an assignment given by Chandan. There was a one more session on Object Oriented Programming but as it was already 5 in evening, that why we decided to have that session in the next meetup.So we end up with a short conversation that in future what else we can do for pyladies meetup so that we have more pyladies member and we all left with a plan to meet next month again : ).

Tuesday, 17 May 2016

Unit Testing -Debugging the code

Testing is very much important to ensure the quality of product in any field. In Software development it is essential to point out the defects and errors in any program. Its a good practice to test your code . So I started with Unit Testing after I have learned Python programming language. In unit testing we use a module called unittest using which we can test our code. It is a testing framework . It comes pre-installed with python from 2.1.

The standard workflow is:
 1. Firstly we define our own class derived from unittest.TestCase.
 2. Then we fill it with functions that start with ‘test_’.
 3. After that we run the tests by placing unittest.main() in your file,        usually at the bottom.


 Before writing unit testcase, we should have few things in our mind that our
 testcase should be able to:
  • Run completely by itself, without any human input. Unit testing is about automation.
  • Determine by itself whether the function it is testing has passed or failed, without a human interpreting the results.
  • Run in isolation, separate from any other test cases (even if they test the same functions).

In unit test we also have setUp() and tearDown() function which are optional.  The setUp() function is used to set up the test environment and tearDown()  is used to clean up after a test. Setup method will run prior to each test case and teardown method will run after each test case.
We use assert functions to check whether the result is correct or not. There are a lot of assert functions in unittest.
Some of them are listed below:
assertEqual()
assertTrue()
assertFalse()
assertNotEqual()
assertIs()

To run a unittest, at the bottom of the test file,we have to give this code:

 if __name__ = "__main__":
     unittest.main()

This allows us to run all of the test code just by running the file.
Running it with no options is the most terse, and running with a ‘-v’ is more
verbose, showing which tests ran.   

Monday, 4 April 2016

A New Beginning with Python

After making my mind to step into programming, the very first question that comes to my mind was "Which programming langauge must be learned to start with programming?" Then I hunted for which langauge should I start with being a beginner and ended up with 'Python' after a long research and conversation with my friends who already are in developing.

Python can become a stepping stone for everyone who want their career in programming universe as it was designed with newcomers in mind. It is easy to learn and grasp as the command are easy to remember because they are similar to the english words we use in our daily life. It is so simple, that you can start coding the very first day and make your own simple programs using python.

There are many more reasons I started with python as its a general purpose,
high level, interpreted language. The first code I leaned was how to print something in python, and it was so easy,I printed 'Hello World!' as it was the first code given in the book which I was referring ie  "Python for you and me".

>>> print "Hello World!"
Hello World!

"Python for you and me" was my first teacher to help me in learning Python (an interpreted , object oriented programming language) and helped me to get into python more and more with very new topics.

Also I joined the course of Udacity that is "Linux Command Line Basics" which was an introduction to the Linux Command Line interface and it
helped me in knowing more about the language and its basics. One thing I liked most about Udacity course is that we have different quizes followed by detailed solution after every topic. This keep us more involved in the course and makes it more interesting to learn and practice.The way of delivering each lesson was  just awesome, so it was worth joining that course.

After gaining enough knowledge about python I just started with some exercise having python programmes, and I found what I was looking for some good exercise of "Coding Bat" related to the topics which I have covered so far in Python.This helped me alot to brush up my concepts in programming.