Basics
Basic syntax from the python programming language
Showing Output To User
The print function is used to display or print output as follows
print("Content that you wanna print on screen")
Taking Input From the User
The input function is used to take input from the user as follows:
var = input("Enter your name: ")
Empty List
This method allows you to create an empty list
my_list = []
Empty Dictionary
By putting two curly braces, you can create a blank dictionary
my_dict = {}
range Function
range function returns a sequence of numbers, eg, numbers starting from 0 to n-1 for range(0, n)
range(int_value)
Comments
Comments are used to make the code more understandable for programmers, and they are not executed by compiler or interpreter.
Single line comment
# This is a single line comment
Multi-line comment
'''This is a
multi-line
comment'''
Escape Sequence
An escape sequence is a sequence of characters; it doesn't represent itself (but is translated into another character) when used inside string literal or character. Some of the escape sequence characters are as follows:
Newline
Newline Character
\n
Backslash
It adds a backslash
\\
Single Quote
It adds a single quotation mark
\'
Tab
It gives a tab space
\t
Backspace
It adds a backspace
\b
Octal value
It represents the value of an octal number
\ooo
Hex value
It represents the value of a hex number
\xhh
Carriage Return
Carriage return or \r will just work as you have shifted your cursor to the beginning of the string or line.
\r
Top comments (2)
Those are really good even if I know a lot of Python. Thanks!!
Thank you for the support