Planet PyLadies Pune

October 10, 2017

Pooja Yadav

Fedora Women Day-Pune Sept,2017

On Sept 28,2017 we celebrated Fedora Women Day in D.Y PATIL COLLEGE OF ENGINEERING, Pune. As decided we all(Amita, Satyajit, Madhuri and me) were in office at 8.30 to leave for the venue. Amita booked a cab and we headed towards the destination. When we reached the college we were welcomed by Suvarna mam. Lot of things were going on there as they were preparing for some event, some construction work was also going on. All this reminded me of my college days and my memories as a student refreshed after watching the college students busy in different tasks.
Then we had a short break as they have to shift the audience to another room due to more number of participants then expected. After the break we were ready to start the event. It was nice to see that a major part of audience were girls. Then they welcomed us with the sacred plant “Tulsi”, it was an honor to get that.
After that we started with Amita’s talk on the topic “ Women in Open Source”. She started with a motivational discussion about the facts and myths which people have about women and that boosted up the stamina of each and every girl sitting there.  Then she covered What is Fedora and how they can contribute to it. She also talked about Women in Open Source Award and shared stories of some great women. After her talk was over she asked students to come up to give their intro, tell us how they feel about it and in which part they think they can contribute according to their interest. As the students were shy, again she pushed them a bit and promised to give awesome Fedora Women Day stickers :) and Fedora Live CD’s which Praveen gave us, thanks to him for that. Then two girls came up and share their ideas. It was really a very motivating talk by Amita.
















Next was Satyajit who was going to show how we can install Fedora in our laptop without messing up with the current OS or our data. As we have a discussion before with the faculty there that some student lost their whole data while installing Fedora, so here he come as a savior for those student. He very clearly explained and showed how they can safely install Fedora from an iso image without harming their data. He helped student to get started with Fedora as most of them were new to Fedora.


After Satyajit it was my turn to explain how they can install various packages and get started after installation of Fedora. So I introduced them to DNF. I gave a brief history of yum, dnf and about transition from yum to dnf. After this I showed them how they can install, update, remove packages using DNF. I gave them basic information about different commands and how they can see help or man pages. I asked some questions in the end and gave stickers to the audience. It was really a great experience with college students.



Then Madhuri came up with her talk on “Fedora loves Python” . She explained about Fedora and Python. She told them how they can contribute to Fedora and showed them different options available where they can contribute according to their interest. It was very informative.

This event was very useful, as most of the student had this in mind that they can contribute only if they know coding. But this cleared all their doubts by giving them a detailed information about the different options available where can contribute according to their interest.


After these session we gave remaining CD’s and Stickers to the students and finished the event with a thank you note. Then after lunch we were back to our office.

It was a great experience and awesome event :-)

by Pooja Yadav (noreply@blogger.com) at October 10, 2017 10:22 AM

September 18, 2017

Rishika Goyal

Behave and Selenium installation steps.

Selenium is a simple API to write functional/acceptance tests using Selenium WebDriver. Through Selenium Python API we can access all functionalities of Selenium WebDriver.

Behave is a simple python module that allows us to write tests in simple natural language.The tests written using behave module are backed up by Python Code which generally uses functionality of selenium for testing the Web Application.

1)Ensure Python3 is installed because we will be using python3
in our example.

2)Setting up Virtual environment.

a) Install vitualenv

pip install virtualenv

b) Create a directory for the project

mkdir project_dir

c) Create a virtualenv inside the directory with python3 as the default interpreter.
cd project_dir

virtualenv -p /usr/bin/python3 my_project

d) Activate the virtual environment

source my_project/bin/activate

3)Installing Behave

Install the python module “behave” in the virtual environment “my_project”

$pip install behave

Check if behave installed properly or not by importing the module in the interpreter.

[rgoyal@localhost ~]$ python3
Python 3.5.3 (default, May 10 2017, 15:05:55)
[GCC 6.3.1 20161221 (Red Hat 6.3.1-1)] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import behave
>>>

The interpreter mustn’t give prompt saying No module named behave

4) Downloading, installing and configuring selenium.
a) Install Selenium in the virtualenv my_project

$pip install selenium

b) Download geckodriver from Downloads section in the link given below.
Geckodriver is Firefox’s web driver that helps in automating . Make sure to download the one that corresponds to your system’s architecture.

Note: The linux 64 bit geckodriver is 3rd in the list

https://github.com/mozilla/geckodriver/releases

c) After downloading geckodriver, extract the tar ball

$tar -xvf <path of geckodriver>

c) Copy the geckodriver executable to /usr/bin

mv <path to geckodriver> /usr/bin

d) Verify that selenium is correctly installed by running this sample python code

in a file named example.py. [You can find this code and it’s explanation here: http://selenium-python.readthedocs.io/getting-started.html]

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get(“http://www.python.org&#8221;)
assert “Python” in driver.title
elem = driver.find_element_by_name(“q”)
elem.clear()
elem.send_keys(“pycon”)
elem.send_keys(Keys.RETURN)
assert “No results found.” not in driver.page_source
driver.close()

 

$python3 example.py

The firefox browser must open and take you to the python.org site.

With this you are all set to test your Web Applications.

Happy Coding!!


by PyRishika at September 18, 2017 07:04 AM

September 09, 2017

Samridhi Agarwal

Euler Problem no.30 with Python

This problem statement was quite interesting because that not only judged my coding skills but also my mathematical skills. So i tried to solve it in two different ways –

Problem Statement
Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
1634 = 14 + 64 + 34 + 44
8208 = 84 + 24 + 04 + 84
9474 = 94 + 44 + 74 + 44

As 1 = 14 is not a sum it is not included.

The sum of these numbers is 1634 + 8208 + 9474 = 19316.

Find the sum of all the numbers that can be written as the sum of fifth powers of their digits.

Solution –

I first thought of getting the set of numbers (which meet the problem’s criteria) that are to be added, and then add them together to verify that the set is correct and complete.

Secondly, make a list of constraints which put restriction on the solution set. This problem excludes the value 1 from consideration. In fact, by intuitive extension, it is excluding all single digit values (numbers < 10) as they cannot form a sum of digits. This is a clue that our search range starts from at least 10.Now we have to think on the end range that’s the maximum limit till which our code should search. After just a moment of thought it becomes clear that the number of digits for the sum must have the same number of digits as a value.
Look at the table below to get the maximum limit.

Digits Maximum n Limit = 95 x n Comments
9 999,999,999 531,441 they need to have the same no. of digits
8 99,999,999 472,392 nope, still too many digits of n .
7 9,999,999 413,343 not quite there
6 999,999 354,294 a valid search limit

So we got the maximum limit as 354,294 . Now let’s write the code.

Python Code –

TotalSum = 0    
Value = []                             #values to be added

#Range we got and then comparing the values according to criteria
for i in range(10, 354294): 
    Sum = 0                       #This sum is for getting one single value 
    for x in str(i):
        Sum += int(x) ** 5        #checking for main condition with power 5 
    if Sum == i:                  #If the sum matches with the value 
        Value.append(i)           #The value we are in search for 

# We add those values stored in the list to get total Sum
for i in Value:
    TotalSum += i

print ("Values :" , Value)
print ("TotalSum :" , TotalSum)

Output ->

Values : [4150, 4151, 54748, 92727, 93084, 194979]
TotalSum : 443839

I also tried with other way by defining a function.

Python Code ->

def power_of_digits(n, exp = 5):
    Sum = 0
    while n > 0:
       Sum += (n % 10)**exp
       n //= 10
    return Sum

total = 0
for i in range(10, 10**6):
    if power_of_digits(i) == i:
        total += i
print(total)

Output ->

443839

Happy Coding! 🙂


by samridhiagarwalblog at September 09, 2017 02:55 PM

September 07, 2017

Samridhi Agarwal

Euler Problem no. 4 with Python

I Solved the 4th problem from the Euler’s problem set using python and found that it can be done in multiple ways. The problem is related to palindrome concept.

Problem Statement – 
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.

I first approached the problem statement by thinking that how many maximum digits will a number have so 2 three digits will have max 6 digits number when multiplied and that can be easily achieved by first multiplying the biggest numbers so I took a reverse loop. And then checked the condition of being a palindrome number and displayed the greatest one after comparison .

Python Code ->

palindrome = 0 
# 2 variables to find the biggest palindrome
for a in range(999, 100, -1):       #First factor

#second factor starts from a so that one multiplication does not repeat.  
    for b in range(a, 100, -1): 
        number = a * b  
        if number > palindrome: 

#To check if number is a palindrome. 
            x = str(a * b)   
            if x == x[::-1]:  
                palindrome = a * b  
print(palindrome) 

Output ->

906609 

Trying More Euler’s Problem and the same code with C++. 🙂


by samridhiagarwalblog at September 07, 2017 02:50 PM

Back to Coding Life!

After all this long time I returned back to my hostel (after a lot more traveling and sad days). Everything seems stable now and I wish this remains for a longer time. So today as I returned back there were many things and many tasks to be completed – the internship work (mainly), I missed the dgplug sessions 😦 (reading the logs), Assignments and College.

So Completed with few things now and enjoyed the whole day with my laptop (after 7 days long holiday). First I did the tasks of the internship work (still left with much more). Read the previous 4 logs which i missed (dgplug). There was a session in dgplug where warthog9 was there for the guest session. He was the one who gave us the battle bunnies in the PyCon Pune 2017 and i also wanted to ask him few things about the bunnies but hard luck missed the chance! But the session was great i read the logs and got to learn many things about hardware. 

I think I will take one more day to return to the normal schedule where i can write atleast two codes a day and learn things. Still I tried to complete most of the things (satisfied by myself 😛 ).


by samridhiagarwalblog at September 07, 2017 02:26 PM

August 25, 2017

Samridhi Agarwal

Euler Prolem no. 2

I solved the second question from the euler’s problem set with python first then i tried to do the same with c++ and I realized that it just does the same thing and same logic to be applied just increasing number of lines to code in C++.

Problem Statement – By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.

So I will start with how I first thought of writing a precise and simple code. As the last digit in the Fibonacci series is the sum of all the prior numbers so if we minus all the odd values from last digit that is 4 million, we will get sum of all even numbers. But i went with searching for all the even numbers one by one till 4 million and adding them.

Python Code ->

sum = 0               # Assign variable sum as 0
a, b = 0, 1                # Taking a and b as values in Fibonacci series
while b < 4000000:         # Last value should be 4 million
    if b % 2 == 0:         # Checking if even
        sum += b           # Adding up all even values
    a, b = b, a + b        # swapping first value with second
print(sum)                 # print the sum 

Output ->

 4613732   

C++ Code  ->

#include 
using namespace std;
int main()
{
	int sum = 0;
	
	//3 variables to create the Fibonacci sequence from 0 to 4000000
	int a = 0;
	int b = 1;
	int c = 0;
	
	while (b <= 4000000)
	{
		c = a + b;
		if (b % 2 == 0)      //check for even number
			total += b;
		a = b;
		b = c;
	}
 
	cout << sum <<endl;
	return 0;
}

Output ->

 4613732  

Practicing more Euler’s problem.


by samridhiagarwalblog at August 25, 2017 05:33 AM

August 22, 2017

Samridhi Agarwal

Emacs Lisp

In yesterday’s dgplug session, we were taught the Emacs Lisp programming, something very new for me which I had never done before. I liked the way the code is written because of its simplicity and normal English language but the way in which parenthesis are put is little confusing. That can be actually done by practicing writing code in Emacs Lisp. I was given a link to a video in the session by the mentor which i found really helping. I summarized all the codes with comments we learned in the session. You can have a look for them here .

After the session we also got some work to do – We have to select a problem from the Project Euler  and implement the solution in Emacs Lisp. So I selected the very first problem that is –

Find the sum of all the multiples of 3 or 5 below 1000.

I first wrote the code in python –

sum = 0                           #assigned sum variable as 0
for i in range(0, 1000):          #used range function to iterate from 0,1000 in the for loop
if(i % 3 == 0) or (i % 5 == 0):   #checked the condition
sum += i                          #if true then add with sum 
print (sum)                       #print total sum

Output ->

 233168 

I tried to proceed in the same way for Emacs Lisp programming and i got the output in two ways once defining a function and one without function.

1) Defining the function sum

(defun sum (list)
  (apply '+ (mapcar
	     '(lambda (x) (if (or (eql (% x 3) 0) (eql (% x 5) 0))
			      x 0) )
	     list) ))
(sum (number-sequence 1 999) ) 

Output ->

 233168 (#o707320, #x38ed0, ? ) 

In the first line I defined the function sum with parameter list then I wrote a condition to check and add all the numbers satisfying the condition to give the total. To give the range I used the number-sequence function.

2) Without using function and using loop (do)

 (let ((sum 0))
  (cl-loop for x from 1 to 999
	   do (if (or (zerop(mod x 3 )) (zerop(mod x 5 )))
		  (setq sum (+ x sum))))
 sum)  

Output->

 233168 

Used the same logic but mentioned the range in the loop which is more problem statement oriented result.

I really liked the Euler’s problem statements will try to practice more from them each day.


by samridhiagarwalblog at August 22, 2017 07:42 PM

Anwesha Das

The mistakes I did in my blog posts

Today we will be discussing the mistakes I did with my blog posts.
I started (seriously) writing blogs a year back. A few of my posts got a pretty nice response. The praise put me in seventh heaven. I thought I was a fairly good blogger.But after almost a year of writing, one day I chanced upon one of my older posts and reading it sent me crashing down to earth.

There was huge list of mistakes I made

The post was a perfect example of TLDR. I previously used to judge a post based on quantity. The larger the number of words, the better! (Typical lawyer mentality!)

The title and the lead paragraph were vague.

The sentences were long (far too long).

There were plenty grammatical mistakes.

I lost the flow of thought, broke the logical chain in many places.

The measures I took to solve my problem

I was upset. I stopped writing for a month or so.
After the depressed, dispirited phase was over, I got back up, dusted myself off and tried to find out ways to make be a better writer.

Talks, books, blogs:

I searched for talks, writings, books on “how to write good blog posts” and started reading, and watching videos. I tried to follow those while writing my posts.

Earlier I used to take a lot of time (a week) to write each post. I used to flit from sentence to new sentence. I used to do that so I do not forget the latest idea or next thought that popped into my head.
But that caused two major problems:

First, the long writing time also meant long breaks. The interval broke my chain of thought anyway. I had to start again from the beginning. That resulted in confusing views and non-related sentences.

Secondly, it also caused the huge length of the posts.

Now I dedicate limited time, a few hours, for each post, depending on the idea.
And I strictly adhere to those hours. I use Tomato Timer to keep a check on the time. During that time I do not go to my web browser, check my phone, do any household activity and of course, ignore my husband completely.
But one thing I am not being able to avoid is, “Mamma no working. Let's play” situation. :)
I focus on the sentence I am writing. I do not jump between sentences. I’ve made peace with the fear of losing one thought and I do not disturb the one I am working on. This keeps my ideas clear.

To finish my work within the stipulated time
- I write during quieter hours, especially in the morning, - I plan what to write the day before, - am caffeinated while writing

Sometimes I can not finish it in one go. Then before starting the next day I read what I wrote previously, aloud.

Revision:

Previously after I finished writing, I used to correct only the red underlines. Now I take time and follow four steps before publishing a post:

  • correct the underlined places,
  • check grammar,
  • I read the post aloud at least twice. This helps me to hear my own words and correct my own mistakes.
  • I have some friends to check my post before publishing. An extra human eye to correct errors.

Respect the readers

This single piece of advice has changed my posts for better.
Respect the reader.
Don’t give them any false hopes or expectations.

With that in mind, I have altered the following two things in my blog:

Vague titles

I always thought out of the box, and figured that sarcastic titles would showcase my intelligence. A off hand, humourous title is good. How utterly wrong I was.

People search by asking relevant question on the topic.
Like for hardware () project with esp8266 using micropython people may search with
- “esp8266 projects” - “projects with micropython” - “fun hardware projects” etc. But no one will search with “mybunny uncle” (it might remind you of your kindly uncle, but definitely not a hardware project in any sense of the term).

People find your blogs by RSS feed or searching in any search engine.
So be as direct as possible. Give a title that describes core of the content. In the words of Cory Doctorow write your headlines as if you are a Wired service writer.

Vague Lead paragraph

Lead paragraph; the opening paragraph of your post must be explanatory of what follows. Many times, the lead paragraph is the part of the search result.

Avoid conjunctions and past participles

I attempt not to use any conjunction, connecting clauses or past participle tense. These make a sentence complicated to read.

Use simple words

I use simple, easy words in contrast to hard, heavy and huge words. It was so difficult to make the lawyer (inside me) understand that - “simple is better than complicated”.

The one thing which is still difficult for me is - to let go. To accept the fact all of my posts will not be great/good.
There will be faults in them, which is fine.
Instead of putting one’s effort to make a single piece better, I’d move on and work on other topics.

by Anwesha Das at August 22, 2017 03:18 AM

August 21, 2017

Samridhi Agarwal

PyLadies Pune Workshop

This Weekend was an awesome one, I got the chance this Saturday to take a Workshop on “Python Basics 101” where I and one of my friend taught many girls Python Basics.

Before giving the session I was so tensed because First Anwesha (Organizer of Pyladies Pune) and Kushal (CPython Core Developer) were going to come as guests so that was a big support for us but because of certain health issues they were not able to come. So we were having the thought of postponing the workshop but Anwesha and Kushal gave us confidence to take the whole seminar by ourselves. That gave us a real responsibility to handle the whole session, and we were having the aim of teaching everything we know. We made the Presentation with all the content and examples the whole night and practiced once in front of our own friends a night before and then we were ready to rock the workshop.

The next day, we saw students really came to attend the workshop (we were expecting less students) So there came our responsibility to make the workshop worth. And hopefully we did that, Everyone was satisfied and we checked everyone’s coding skills by giving them questions in last 1 hour of the session and there was the aura of competition at the last( because we were having 2 chocolates by chance and we gave that who solved first). Many students came to ask more about PyLadies Pune and i was so happy to tell them as I can surely say that PyLadies totally turned me into a different person (good according to me). This opportunity taught me many things, Learn by Teaching and handle things. All Thanks to my very good step of joining PyLadies Pune Group.

You all can look at the Presentation and stuff i taught here and tell me changes so that i can learn and improve.

 

 


by samridhiagarwalblog at August 21, 2017 01:25 PM

Nisha Poyarekar

I want 2 do project tell me wat 2 do – the workshop and the book

The first workshop in June was by a friend of reserved-bit, Shakthi Kannan. Shakthi has been one of the leading faces of the FOSS movement in India for some years and we were very excited when he expressed interest in doing a workshop at reserved-bit. His book I want 2 do project tell me wat 2 do is a handbook every student and professional must own. It is a concise guide for people looking to contribute to the Open Source world. It is the answer to the question that is the title of the book, a question the author must have heard enough number of times in his life to motivate him to write a book.

Attending a workshop by an author of a book you enjoyed reading must always be a pleasure and this one was no less. Shakthi talked about everything from the history of the Free Software movement to personal benefits of contributing to source code to the specifics like coding standards and styles, effective programming environments, hardware and public communication in the FOSS world. He even talked about some very useful strategies to planning and organizing one’s work and ensuring personal success as well as success of the FOSS project.

The full day session ended with attendees creating mind maps for their projects and were very happy about having spent the day with the author. We were delighted to be facilitators of such a wonderful workshop and we hope to do this again some time in future.

by Siddhesh Poyarekar at August 21, 2017 12:51 PM