Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Guys, can you please share me some sites where we can practice python programs for beginners and Intermediate.

99 views
Skip to first unread message

Pushpanth Gundepalli

unread,
Jun 21, 2016, 7:03:28 AM6/21/16
to
Guys, can you please share me some sites where we can practice python programs for beginners and Intermediate.

Rick Johnson

unread,
Jun 21, 2016, 1:14:15 PM6/21/16
to
On Tuesday, June 21, 2016 at 6:03:28 AM UTC-5, Pushpanth Gundepalli wrote:
> Guys, can you please share me some sites where we can practice python programs for beginners and Intermediate.

Have you tried googling for "python interactive tutorial"? Someone had created one similar to Ruby's, but i cannot remember the site. The python.org website has an interactive shell you can play around with online, but it's no different than using Python on your machine -- not much advantage anyway.

jf...@ms4.hinet.net

unread,
Jun 21, 2016, 9:36:56 PM6/21/16
to
Pushpanth Gundepalli at 2016/6/21 7:03:28PM wrote:
> Guys, can you please share me some sites where we can practice python programs for beginners and Intermediate.

Is this you want? http://pythontutor.com/

--Jach

Miki Tebeka

unread,
Jun 22, 2016, 4:39:05 AM6/22/16
to
On Tuesday, June 21, 2016 at 2:03:28 PM UTC+3, Pushpanth Gundepalli wrote:
> Guys, can you please share me some sites where we can practice python programs for beginners and Intermediate.

IMO you can do that at https://www.codecademy.com/learn/python

Nick Sarbicki

unread,
Jun 22, 2016, 4:46:00 AM6/22/16
to
On Wed, Jun 22, 2016 at 9:42 AM Miki Tebeka <miki....@gmail.com> wrote:

> IMO you can do that at https://www.codecademy.com/learn/python
>

Some people might think differently but I wouldn't recommend a python
course which teaches 2.7 over 3.x.

It bugs me that learnpythonthehardway and codecademy - probably 2 of the
biggest platforms for learning python at the moment - both refuse to move
to python 3.

John Wong

unread,
Jun 22, 2016, 4:51:41 AM6/22/16
to
On Wed, Jun 22, 2016 at 4:45 AM, Nick Sarbicki <nick.a....@gmail.com>
wrote:

> On Wed, Jun 22, 2016 at 9:42 AM Miki Tebeka <miki....@gmail.com> wrote:
>
> > IMO you can do that at https://www.codecademy.com/learn/python
> >
>
> Some people might think differently but I wouldn't recommend a python
> course which teaches 2.7 over 3.x.
>
>
pythontutor does support Python 3. Haven't tried CA for a while.

Pushpanth Gundepalli

unread,
Jun 23, 2016, 1:35:45 AM6/23/16
to
On Tuesday, June 21, 2016 at 4:33:28 PM UTC+5:30, Pushpanth Gundepalli wrote:
> Guys, can you please share me some sites where we can practice python programs for beginners and Intermediate.

Thank you for ur valuable suggestions.. Actually i have done practising the exercises on codeacademy, codingbat. But the thing is that i want to do a live project which wil help me to enchance my skills more.. I'm happy tht I'm able to understand and write small lines of code(i think it is a small achivement for me and it boost my confidence).. but i need to improve more on programming.. Also pls help me out on how I can get some real time projects to practice!!

DFS

unread,
Jun 23, 2016, 2:36:11 AM6/23/16
to
Here's a fun one: scraping data off a website, and storing it in a
SQLite database file.

First you need to install the requests and lxml packages.

-----------------------------------------------------------------
import requests, sqlite3
from lxml import html

dbName = "TECHTERMS.sqlite"
conn = sqlite3.connect(dbName)
db = conn.cursor()
db.execute("CREATE TABLE If Not Exists TECHTERMS (Term,Category, PRIMARY
KEY (Term));")

techterms = 'http://techterms.com/techfactor/4'
page = requests.get(techterms)
tree = html.fromstring(page.content)
terms = tree.xpath('//a[@href]/text()')
category = tree.xpath('//td/text()')

print terms; print
print category; print

dropwords = ['Advanced Search', 'Browse', 'Quizzes', 'Help', 'Home',
'Browse', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Terms of
Use', 'Privacy Policy', 'About', 'Contact']
terms = [x for x in terms if x not in dropwords]

p = []
if len(terms) == len(category):
for i in range(0,len(terms)):
p.append((terms[i],category[i]))

for term, category in p:
print "%s, %s" % (term, category)
db.execute("INSERT OR IGNORE INTO TECHTERMS VALUES (?,?)",(term,category))
conn.commit()

db.close()
conn.close()
print "Finished"
-----------------------------------------------------------------

Joe Gulizia

unread,
Jun 23, 2016, 6:29:10 AM6/23/16
to

________________________________________
From: Python-list <python-list-bounces+jrgulizia=scol...@python.org> on behalf of Pushpanth Gundepalli <pushpa...@gmail.com>
Sent: Thursday, June 23, 2016 12:35 AM
To: pytho...@python.org
Subject: Re: Guys, can you please share me some sites where we can practice python programs for beginners and Intermediate.

On Tuesday, June 21, 2016 at 4:33:28 PM UTC+5:30, Pushpanth Gundepalli wrote:
> Guys, can you please share me some sites where we can practice python programs for beginners and Intermediate.

Thank you for ur valuable suggestions.. Actually i have done practising the exercises on codeacademy, codingbat. But the thing is that i want to do a live project which wil help me to enchance my skills more.. I'm happy tht I'm able to understand and write small lines of code(i think it is a small achivement for me and it boost my confidence).. but i need to improve more on programming.. Also pls help me out on how I can get some real time projects to practice!!

--
https://mail.python.org/mailman/listinfo/python-list

Computer Science Circles - University of Waterloo

http://cscircles.cemc.uwaterloo.ca

Almost any open source project welcomes volunteers....I'd start with FSF.org (Free Software Foundation) or EFSF (European FSF) https://fsfe.org/

Joe

Cousin Stanley

unread,
Jun 23, 2016, 11:11:54 AM6/23/16
to
DFS wrote:

> Here's a fun one: scraping data off a website,
> and storing it in a SQLite database file.
> ....

After testing your example code here I found
that the length of the categories list
was 1 less than the terms list after applying
dropwords in the terms list comprehension ....

The subsequent len comparison then failed
and no data was inserted into the data base ....

As a fix I added an extra category ....

category.append( 'didly' )

Subsequently, data was inserted
with a single extra category
for the last term in terms ....


Thanks for posting the example code ....


--
Stanley C. Kitching
Human Being
Phoenix, Arizona

DFS

unread,
Jun 23, 2016, 12:22:41 PM6/23/16
to
On 6/23/2016 11:11 AM, Cousin Stanley wrote:
> DFS wrote:
>
>> Here's a fun one: scraping data off a website,
>> and storing it in a SQLite database file.
>> ....
>
> After testing your example code here I found
> that the length of the categories list
> was 1 less than the terms list after applying
> dropwords in the terms list comprehension ....
>
> The subsequent len comparison then failed
> and no data was inserted into the data base ....
>
> As a fix I added an extra category ....
>
> category.append( 'didly' )
>
> Subsequently, data was inserted
> with a single extra category
> for the last term in terms ....


Strange! After dropwords, the list lengths match for me (both are 152).

So in your table, is 'didly' now the category for the last term
'Rendering'? Mine is 'Technical', as it is on the source webpage.

I usually put list length tests in place, not sure what happened here.




> Thanks for posting the example code ....

Sure thing.

DFS

unread,
Jun 23, 2016, 12:23:10 PM6/23/16
to
On 6/23/2016 2:36 AM, DFS wrote:
> On 6/23/2016 1:35 AM, Pushpanth Gundepalli wrote:
>> On Tuesday, June 21, 2016 at 4:33:28 PM UTC+5:30, Pushpanth
>> Gundepalli wrote:
>>> Guys, can you please share me some sites where we can practice
>>> python programs for beginners and Intermediate.
>>
>> Thank you for ur valuable suggestions.. Actually i have done
>> practising the exercises on codeacademy, codingbat. But the thing is
>> that i want to do a live project which wil help me to enchance my
>> skills more.. I'm happy tht I'm able to understand and write small
>> lines of code(i think it is a small achivement for me and it boost my
>> confidence).. but i need to improve more on programming.. Also pls
>> help me out on how I can get some real time projects to practice!!
>
>
>
> Here's a fun one: scraping data off a website, and storing it in a
> SQLite database file.

For additional learning/practice, figure out how to adopt the code to
loop thru all the webpages (there are 10).

http://techterms.com/techfactor/1
http://techterms.com/techfactor/2
http://techterms.com/techfactor/3
http://techterms.com/techfactor/4
http://techterms.com/techfactor/5
http://techterms.com/techfactor/6
http://techterms.com/techfactor/7
http://techterms.com/techfactor/8
http://techterms.com/techfactor/9
http://techterms.com/techfactor/10

Hint:

for i in range(1,11):
techterms = 'http://techterms.com/techfactor/' + str(i)


Note: when I first coded it, I ran it too fast (no sleep() between
loops), and after a few times the site responded with something like:

Browse site
Contact webmaster

and wouldn't return any data.

So in your programming, you probably want to put a 2-second break before
going to the next page:

import time
time.sleep(2)



DFS

unread,
Jun 23, 2016, 12:24:23 PM6/23/16
to
On 6/23/2016 1:35 AM, Pushpanth Gundepalli wrote:
Here's another interesting one: count the number of posts made by nyms
on a Usenet group. usage (Windows) is python filename.py last N


import sys as y,nntplib as t
s='news.eternal-september.org'
g='comp.lang.python'
n=t.NNTP(s,119,'<usr>','<pw>')
r,a,b,e,gn=n.group(g)
r,d=n.xhdr('From','%s-%s'%(int(e)-int(y.argv[2])+1,int(e)))
p=[]
for i in range(len(d)):p.append(d[i][1])
x=[(i,p.count(i)) for i in set(p)]
x.sort(key=lambda s:(-s[1],s[0].lower()))
print('Posts %s %s'%(len(set(p)),'Posters'))
print('----- ---------------------------------------------')
for v in x: print(' %s %s'%(v[1],v[0]))
print('----------------------------------------------------')
n.quit()


As you can see I've shortened and 'obfuscated' it by using tiny variable
names - so it's more fun for you to figure out.

Start at: https://docs.python.org/2/library/nntplib.html


Cousin Stanley

unread,
Jun 23, 2016, 12:40:03 PM6/23/16
to
DFS wrote:

> On 6/23/2016 11:11 AM, Cousin Stanley wrote:
>> DFS wrote:
>>
>>> Here's a fun one: scraping data off a website,
>>> and storing it in a SQLite database file.
>>> ....
>>
>> After testing your example code here I found
>> that the length of the categories list
>> was 1 less than the terms list after applying
>> dropwords in the terms list comprehension ....
>>
>> The subsequent len comparison then failed
>> and no data was inserted into the data base ....
>>
>> As a fix I added an extra category ....
>>
>> category.append( 'didly' )
>>
>> Subsequently, data was inserted
>> with a single extra category
>> for the last term in terms ....
>
>
> Strange! After dropwords, the list lengths match
> for me (both are 152).
>

Found 153 for terms and 152 for categories,
so I appended 1 to categories ...

> So in your table, is 'didly' now the category for the last term

> 'Rendering'? Mine is 'Technical', as it is on the source webpage.

Last 5 printed from the final loop
just before the db insert ....

....
Passphrase , Technical
Passcode , Technical
Touchpad , Hardware
Rendering , Technical
Terms of Use , didly

>
> I usually put list length tests in place,
> not sure what happened here.

Possibly a copy/paste difference
on my end ....

DFS

unread,
Jun 23, 2016, 1:03:21 PM6/23/16
to
On 6/23/2016 12:39 PM, Cousin Stanley wrote:

> Terms of Use , didly
>
> Possibly a copy/paste difference on my end ....


'Terms of Use' isn't being removed like it should. When I pasted the
code into Thunderbird, it put a line break after 'Terms of'. Fix that
and the code will run fine.

But it still needs minor tweaks:

* should have a list length test in it
* the last for loop should be indented under the last if statement

Regardless, hope you learned something from it.


The biggest pain when writing it was probably figuring out how to
extract data from the HTML:

Sayth Renshaw

unread,
Jun 24, 2016, 7:43:51 PM6/24/16
to
On Tuesday, 21 June 2016 21:03:28 UTC+10, Pushpanth Gundepalli wrote:
> Guys, can you please share me some sites where we can practice python programs for beginners and Intermediate.

Here are some good beginner projects https://knightlab.northwestern.edu/2014/06/05/five-mini-programming-projects-for-the-python-beginner/

Also a community on reddit and github are trying to acheive this.

https://learnprogramming.github.io/

https://github.com/LearnProgramming

Sayth

Umar Yusuf

unread,
Jun 28, 2016, 10:04:26 PM6/28/16
to
0 new messages