Homework Discussions for the Basic Python Workshop

These are the results I have obtained, although I think words like ‘us’ are not included in the stopwords list. ‘brutus.’ is the most used word in the text.

image

Also, I think there are punctuations being mixed with the words, as there is a ‘brutus.’ and ‘brutus’

1 Like

python_homework_GHF_class 1

I cleaned the string from punctuations and got this plot

2 Likes

Nice Job, folks! @adityadoomra10 great job on removing punctuations! Do share your strategy for this removal so we can all learn.

Everyone, that was not part of the homework but I want to complement @adityadoomra10 on his attention to detail, always a good thing for us data scientist sorts…

fd = open("data/JuliusCaesar.txt")
word_string = fd.read().lower()
punctuation = '!()-[]{};:"\,<>./?@#$%^&*_~'
for element in word_string:
    if element in punctuation:
        word_string = word_string.replace(element, "")

I did not remove apostrophe as that would cause words like won’t to change into wont and that would cause problems in removing the stop words
Hope this helps everyone!

3 Likes

Histogram with few tweaks in color, positioning, etc.
HW_2

You can visit the notebook here.

2 Likes

Great job @uzairk ! It’s commendable that you went ahead and explored the Seaborn library, its color schemes, and also annotated your bars in the plot.

It’s also worth mentioning that you are maintaining a Github profile which helps you in showcasing your skills and stay organized. I would encourage other community members to do the same. It is one of the tools you can keep in your arsenal of self-branding as a programmer to give you that extra edge.

And do share your cool projects related to ML and Data Science in the Your Portfolio section.

Where should we submit our homework?

2 Likes

Can you share JuliusCaesar.txt file with us. I am unable to find it online.

Hi @ch14d016 ! You can find all the datasets that we have used in our Basic Python Exercises and Homeworks at https://github.com/univai-ghf/PythonWorkshop/tree/main/data

Where and how should I submit my homework? I haven’t received any mails regarding that.

Where and how should we submit our homework?

Ankit

We’ll put a link at the top of this thread soon and send an email out with that link as well!

@ch14d016 @melvinsamv @tejas55 We appreciate your enthusiasm and patience. The homework submission link is active now and you can find it at the top of this thread here.

We hope to see your submission soon!

i think this is it

Good evening!
How can I watch the recording of the ‘Basic Python Workshop’?
I have a trouble loading the recordings of all of the workshops I have attended.
I would be greatly helped if you could guide me on it.

Sincerely,
Raj

plot_jc

Great job @sanjay_ug_s . You can go a step further by cleaning the punctuations so that words like “brutus.”, “brutus,”, “brutus” etc. are treated as one word “brutus”.

You can refer to the strategy shared by @adityadoomra10 here or to the notebook shared by @uzairk here.

yeah surely thanks for the review


Hi everyone!
From the code i am able to figure out that after every character there is a colon printed, but i am unable to figure out why does before the line starts there is a colon similarly for the case of last line(there is a colon for friends , why is there a another colon) .
Can anyone please help out

Screenshot 2022-02-20 022850

@yeskaydeee To demonstrate what is happening behind the scenes, I have inserted ‘A’ at the start and ‘B’ at the end of the same string.

You can observe from my output that we do not have a colon at the start and also we do not have a colon in the next line when ‘B:’ ends. So, what’s happening?

A string is a list. In your case, the very first character (at index 0) and the very last character stored in the string is not ‘H’ and ‘s’ respectively, but a newline character\n’. So, what does a newline character do? As its name suggests it takes the cursor to a new line. Our program will treat it as a character just like it treats ‘a’, ‘b’, ‘c’ or ‘d’. The difference comes when it will be printed. You can see ‘a’ but you can’t see a newline character unless you have a frame of reference.

So, in your program, a newline character is printed first which essentially means your print cursor moves to a new line, then a colon is printed as we have explicitly mentioned that after printing each character, end with a colon (end=’:’). After that ‘H’ is printed and ends with a colon. Therefore, we get ‘:H:’. The same process repeats till we print ‘s:’. After that our program encounters a newline character again which is the last character in our string, prints that (takes us to a new line) and then prints the colon and finally comes out of the loop.

In my case, ‘A’ and ‘B’ are respectively the very first and very last characters in the string. Now, you can make out the difference.

I hope it helps!

1 Like