Learn to Code via Tutorials on Repl.it!

← Back to all posts
Python Basics tutorial; Session 1
Alice688 (113)

Python Basics

What is Python?
Python is a general-purpose computer language.
Created by Guido van Rossum, and released in 1991.
And it particularly emphasizes code readability.

print("Variables, and escape characters.")

Print() function
The print() function is probably the most used lines of code.
It is used when we want to output a string. A string is a collection of characters, or text.
This function takes in a few different parameters, but we'll talk about that later.

Parameters are pieces of input (information) you give the function to do something.

This function is very helpful in debugging code as well.
You write the print statement by putting what you want to be printed in the parentheses


Quotation marks
In a print statement you have to have quotation marks. You also have to make sure there the same type, ex: ' ' - same type " " - same type
The same goes for parentheses.

Escape characters
Now what if we needed to use quotation marks....let's say on a quote. And you just put quotation marks in quotation marks. Well, this would happen:

A Syntax Error is when you have a problem with your syntax, Syntax Error is basically a language error

So what's the solution? The solution is escape characters. Basically help you escape the problem.

The escape character you would use in this case is a backlash. So your code would look like this:

And your output would be:

But, what if you wanted to use multiple lines? There's a escape character for that, too. All you have to do is put '\n' every time you want it to go to a new line.



Variables are basically labeled boxes in which you store strings and integers in. (You should know what integers are.)
And when you put them in print() functions your telling the computer to print whats in that box.
You write a print statement by giving your string/integer a name then use the = sign. Here's what I mean:

name = 'Coder'
name = label 'Coder' = string/integer

So then you would put your variable (box) in your print statement:



There are many different types of operators, but we'll just focus on three: arithmetic, boolean, and logical operators. A operator is a symbol or function that tells the computer to use a certain operation.
Here is a chart of arithmetic operators, which are basically math operators:
Remember to use order of operations (PEMDAS).

Next, are boolean operators or comparison operators. This operator gives us an True or False output, a.k.a. a boolean type.

Greater Than

This basically asks the computer is this number greater than that one?


And seven is not greater than ten so it is False.

Less Than

Basically the same as greater than, except it checks wether a number is less than another number.


Equal to

This is checking wether something is equal to another thing.


Greater than or equal to and Less than or equal too

This is checking wether something is less/greater than or equal to something.


Not equal

This is checking if something is not equal to something


Remember, that you can use boolean operators with variables as well as numbers!

Finally, logical operators, these help us compare True or False operands. This is good, cause it makes our code smarter. There are three main logical operators:
and, or, and not.


So let's say Maria has multiple friends. And we want to pick the cupcake lovers from the cookie lovers.
The and operator helps us check for two True operands.
Example Input:

This would be checking if Maria's friend is a cookie lover and cupcake lover.


So using the Maria's cookie and cupcake loving friends case again. The or operator would check if her friend was a cookie lover or a cupcake lover.
Example Input:


The not operator would check wether Maria's friend is not a 'something' lover.
Example Input:


That's it for Session 1 (there will be a Session 2).
If you have any questions, advice, or corrections please comment, and I will reply.
Hope this is useful for you!
(Also check out Part 2, I have finally finished it! Here's the link: https://repl.it/talk/learn/Python-Basics-Tutorial-Part-2/55062!")

EpicGamer007 (1794)

Good! In depth explanation, I like it! Just one thing to know. I think it would be better if you made one long tutorial instead of many short ones. It would be more informative and gain more support from other replers(I think). Having "sessions" or a "series" can make it seem like you are cycle farming. Thank you and great job!

gibbsfreenergy (1002)

Nice Job ! You're tutorials are really in depth unlike so many other tutorials! GOOD JOB :)

NamishaKundar (0)

Thank you so much for uploading this tutorial.

AishwaryaGowri (0)

i luved it !!! when will the next part come ???

Alice688 (113)

@AishwaryaGowri Either today or tomorrow. :)


Very good explanation....