My Authors
Read all threads
DAY 2: Python Training on Twitter
Topic: Python Syntax
Day 1, we talked about how to set up Python environment on your computer. 👉()
After today thread, you should be able to identify and debug Python syntax
Let Go 👇

#Python #twitterpython #Syntax
What is Python Syntax?

It is referred to a set of rules and principles that describes the structure of a language (i.e. what constitutes a correctly-formed program).
The Python syntax defines all the set of rules that are used to create sentences in Python programming
#Python3
Eg: we have to learn grammar when we want to learn the English language.

In the same way, you will need to learn & understand the Python syntax in order to learn the Python language.

Python syntax is more like English language unlike other programming lang.
Example of Python Syntax

Let’s take a look at a simple Python program and you will get an idea of how programming in Python looks like.

See attached image...!

#Python #TwitterPython
Now let talk about Types of Syntax Structures in #Python:

1 Line Structure
2 Multiline Statements
3 Comments
4 Docstrings
5 Indentation
6 Multiple Statements in One Line
7 Quotations
8 Blank Lines
9 Identifiers
10 Variables
11 String Formatters

👿Hey, fear not its easy.....
1. Python Line Structure
A Python program comprises logical lines. A NEWLINE token follows each of those. The interpreter ignores blank lines.
Note: Semicolon at end of script is not necessary in python, every NEWLINE is seen as a new line of code.
2. Python Multiline Statements

In Python a new line means a new statement.
But sometimes, you may want to split a statement over two or more lines. It may be to aid readability. You can use following ways

>>>print("Hello\
How are day?")

>>> print("""Hi
how are you?""")
3 Comments
The interpreter ignores comments. Declare a comment using an octothorpe (#).
>>> #This is a comment

4 Docstrings
A docstring is a documentation string

def function(a, b):
"""Do X and return a list."""
5 Indentation

Since Python doesn’t use curly braces to delimit blocks of code, this Python Syntax is mandatory.
You can indent code under a function, loop, or class.

Indentation can be really frustrating in python esp when copy and paste code
Every space, tab, matters in Python
6. Python Quotations
Python supports the single quote and the double quote for string literals. But if you begin a string with a single quote, you must end it with a single quote. Same goes for double-quotes.

>>> print('We need a chaperone');
>>> print("We need a 'chaperone'");
7 Python Identifiers
A Python identifier is a name used to identify a variable, function, class, module or other object. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores and digits (0 to 9)
You cant use @, $, %
8 Python Variables

In Python, you don’t define the type of the variable. It is assumed on the basis of the value it holds.

>>> x=21
>>> print(x)
Output:
21

>>> x='Hello'
>>> print(x)
Output:
Hello
Today, we learned about the basic Python syntax. We learned about its line structure, comments and docstrings, indentation. We also learned about blank lines, identifiers, variables

Thanks for reading But remember the best way to learn is by "Practicing"
Don't just read Practice
Tomorrow we will look at
* Python Variables and
* Data Types
Missing some Tweet in this thread? You can try to force a refresh.

Enjoying this thread?

Keep Current with Oladeji Stephen

Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!