100 Days of Python — Day 1

H Dev
4 min readJun 18, 2021

New beginnings are always challenging as they are exciting. I am super thrilled to embark on this journey.

Photo by Clément Hélardot on Unsplash

Topics I’ve covered: printing, commenting, debugging, string manipulation, variables.

Along with that, I’ve also read through the documentation available for python. I’ve linked below all the necessary links.

https://docs.python.org/3.9/contents.html

This has the complete contents page, which literally consists of everything that you can imagine or think of. Literally, everything that constitutes the python language.

https://docs.python.org/3.9/tutorial/index.html

This is python tutorial, that is it consists of in-depth and step by step explanation of various topics/subjects of the python programming language.

https://docs.python.org/3.9/reference/index.html

This gives you a broad idea about python as a programming language. All of its core semantics are mentioned here.

https://docs.python.org/3.9/library/index.html

This is the most intriguing part of the documentation for me. It consists of every single build-in function, modules and everything else that you need to know about the standard library.

I suggest that every time you come across a new keyword or a function or module, go ahead and skim its documentation, you will be amazed by its functionalities.

Let’s dive right in…

So the first piece of code that we would be learning is obviously… hello world!

print("hello, wolrd!")

Debugging tips: if you don’t figure out what the error is by skimming through the code or by reading the error and understanding it, then always copy the error and Google it. More times than less, people would have faced the same error and others might have posted the solution or way around it. So don’t be reluctant to google your way out of your errors.

Debugging tips: Most editors have color highlighting. Try paying more attention to that, literals are given different colors, keywords their own, and so on.. so when you find a discrepancy in the color scheme, you will be one step closer to finding your bug.

The print function is pretty straightforward. It takes an argument and prints it on the screen. But could there be more to it than just that? Let’s head over to its documentation and learn its other wonderful features.

https://docs.python.org/3.9/library/functions.html#print

So now we can see that python’s print function can take 4 more arguments.

Let’s explore them…

sep=’ ‘

So by default, if two print statements are printed next to each other, the token that divides it would be a space ie: ‘ ‘. But we can change that, by calling this argument while printing a statement.

These arguments can come in handy when you are trying out input and output formatting questions in python.

next, end=’\n’

by default, all the print statements end with a ‘\n’, but we can change it to whatever we desire. For example: if we do not want two lines to print in two different lines but in the same one then all you’ve got to do is end=”” this would not add a new line token to the statement printed and the execution will continue from the same line.

next, file=sys.stdout

this is by default, everything that we try to print gets printed into the console (ie: sys. stdout) but instead if we want to print the content into another file, we could always call this argument and provide the file name as the value.

finally, flush …

And the next function that we can cover is the — — input() function

https://docs.python.org/3.9/library/functions.html#input

By default, the input function takes up a string, but we can always convert it before we store it into a variable.

and in order to do that, we can convert that to an int like so,

var a = int(input("Enter a number: "))

Next, before ending today’s learning, let’s check out another build-in function: len()

So what does this function do?

It returns the number of items/chars in the object that is provided to it as an argument.

That is if we say

len(string) →it would return the number of chars in the string

len(number) →/ ERROR!!! instead, we can do this…

len(str(number)) → number of elements in the number

len(array) → number of elements

. . . and so on.

Another important concept to learn while learning how to code is commenting.

This is important because code although typed in English isn’t plain English. We write it with logic in our heads, and sometimes the owner of the code might get confused as to why or how the code solves its purpose. And also, the code can be used by millions and thus should be understandable. And to facilitate this, we add comments to our code. Thus helping others (or future us) to understand why or how the code works.

So in Python, we can comment code by adding a ‘#’ in the beginning, for single-line comments

We can also have multiple line comments by adding ‘#’ before each line, or we can use ‘’’ ‘’’ — triple apostrophes.

#single line comment#multi 
#line
#comment
#using hash
""" or this can be used to type out
multiple line comments as well"""

Also, the best way to learn and keep things exciting is by practicing alongside learning. So I’ve created my HackerRank account. I would be starting the Python -Language Proficiency. There are about 115 challenges there. Let’s see how long it would take me to get through with those.

--

--

H Dev

just another X-shaped personality, love to learn and tinker with new tech.