100 Days of Python - Day 1
Table of contents
100 Days of Code
Today I will start my 100 days of code journey!
For this journey I have decided to learn Python with Replit.com.
During this journey I will write daily blog articles with my progress and will explain what I've learned so far.
Goal of this Blog
The main goal of writing this daily blog is to solidify the knowledge that I've learned so far by explaining it to my readers.
While I am doing this mostly for myself, this blog is also for reaching out to people that are starting out with coding to motivate you to keep on going and to reach your goal whatever it may be.
Topics that I will cover today.
- Print Statement
- Common coding errors
Print Statement print()
The first things you will learn in most coding language courses is how to print
"Hello World" out to the screen.
By doing so you feel that you are actually achieving something from the first line of code you have written.
In Python you can achieve this by writing a print statement:
Code:
print("Hello World")
Output:
Whatever goes between the brackets ()
of print
will be displayed into your console
.
And Hello World is being written between these "
double quotes because it's our way of telling the computer that this is text also called a String
.
Also every-time you write a print statement, you will have a new line which is a way to let you control how it looks.
So to revise, first we write print()
and then inside of print we put some double quotes ""
and in-between those quotes we can write whatever we would like to print to the console.
Code:
print("My name is JavaUwU") print("I just started my 100 days of code journey")
Output:
There is 1 more way to utilise the print statement.
If you would like to write something and you want it to be shown exactly the way you've written it, all spaces, newlines and tabs included then you can do so by using triple double quotes! print(""" Anything you want """)
.
Code:
print("""I Would like my code to show Like this""")
Output:
Common coding errors
Debugging code is one of the most if not the most important aspect of programming. Therefor it is crucial that you know how to do this. I will now present some examples of incorrect code and what the error message will be.
Name Error
code:
// Incorrect Print("What's wrong with this code") // Correct print("I have fixed the code")
output: We get a Name Error and it is saying that
If you look closer you can see that we wrote Print with a capital P which is what caused the NameError. In python you have to be careful as code is case sensitive.
Syntax Error ()
Code:
// incorrect print"This will result in a syntax error" // correct print("I have fixed the syntax error")
Output: Here we get a Syntax Error and it uses the little upwards
^
key to show us where the problem lies. In this case the Syntax Error is telling us that we forgot to put the brackets()
in there and that is why our print statement is unable to execute.
Syntax Error ""
Code:
// incorrect print(This will also result in a syntax error) // correct print("I have fixed this syntax error as well")
Output: Another example of a Syntax Error and once more it uses the little upwards
^
key to show us where the problem lies.
In this case the Syntax Error points to where the problem lies but you need to figure out yourself what might be wrong.
Seeing that the text is not between double quotes" "
the computer does not know what you have put into the print statement and that is why we have a Syntax error.
My Final Thoughts
If you read this all the way to the end then you have my utmost gratitude!
At first I thought this post would take a few minutes but I ended up spending a lot more time on it ^_^.
I truly hope that this Blog-post was helpful to you and that you wish to follow along with the journey.
See you on Day 2!
Subscribe to my newsletter
Read articles from JavaUwU directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by