Are you interested in learning Python?

A thread on Python's basic syntax 🧵

P/S: If you liked this thread, please retweet.
VARIABLES
- Variable names are case sensitive (name and NAME are
different variables)
- Must start with a letter or an underscore
- Can have numbers but must not start with one
- Python is loosely-typed (you don’t specify the type when
declaring a variable.
FUNCTIONS

- In python, functions are defined with the def keyword.
- Indentation is used instead of curly braces.
- A colon is placed after the parameters.
- No semi-colons.
STRINGS

- Strings in python are surrounded by either single or double quotation marks
- F-Strings enable you easily concatenate two different types without having to cast it first
TUPLES

- These are data collections which are ordered, unchangeable and can have duplicate members.
SETS

- These are data collections which are unordered and doesn’t allow duplicate members
DICTIONARY

- These are data collections which are unordered, changeable and indexed. Similar syntax to objects in Javascript.
LOOPS

- Loops are mechanisms for iterating over a list of items while performing a consistent action on each of them
CONDITIONALS

- If/else expressions are used to execute a set of instructions based on whether a statement is true or false.
MODULES

- A module is a file containing a set of functions to include in your application. There are core python modules which are part of the Python environment, modules you can install using the pip package manager as well as custom modules
CLASSES.
A class is like a blueprint for creating objects. An object has properties and methods associated with it.

- Like with functions, all fields inside a class must be indented.
- Use def keyword to define a method
- self keyword is used to refer to the current class.
You can follow @UbahTheBuilder.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled:

By continuing to use the site, you are consenting to the use of cookies as explained in our Cookie Policy to improve your experience.