Learn to Code via Tutorials on Repl.it!

← Back to all posts
Python: A language legacy. Part 1! Variables!

Python is world famous for being an easy to learn, beginners language. That is why I am here to teach it to you. It is a very broad language supporting almost every corner of development! Let us start with a very simple topic if you have done algebra before: Variables!

Variables are very easy in python. Why? The reason why is because python is weakly-typed meaning the variables types are actually dynamic(they can change). This means that instead of the types being figured out at build time (via your code) the types are figured out at runtime (via inference).

To set a variable you do something like this: x = 5
the breakdown of that is:
<name> = <value>

he values can be either integers, strings(multiple letters), floats(floating point numbers), lists(a list of variables), dicts(a list of key-value pairs), and tuples(a list but the values are static). And Bools(True or False values)

I will go more in depth now:

To set a list you go: <name> = [value, value, value...]

Note: a list can contain values or other variables (even other lists!).

To set a Tuple you go <name> = (value, value, value)

Note: a tuple can contain values or other variables (even other tuples!).

To set a Dict you go:
<name> = { key(str): <value> }

Note: a dictionary can contain values or other variables (even other dictionaries!).

To set a integer you go: <name> = <value>
To set a float you go: <name> = <value>
To set a string you go: <name> = "<value>"(Surrounded by " or ')
To set a bool you go: <name> = <value>

That's all for now. Next time we will talk about IO and later we will talk more about variables.


Big oof on that markdown next time I will do better!


@Wuru You can change it, you know.


oh, thanks @aguy11