one can install python using package manager depending upon the operating system you are using. As I have a windows machine and ubuntu using linux on windows subsystem. I can install python from https://python.org. And Ubuntu I can use below command to install python.
To run python you would call python3 which open Python interpreter. On that you can type print(“Hello World”) to run your first python code which would print Hello World in next line.
To run python code from a file I would need to below text into a file, save suppose as hello.py
The file “hello.py” needs to be executable to be run the code. If file is not executable we can do it by
chmod +x hello.py
then we can run file by calling it as
White space and indentation
Whitespace and indentation should be perfect for python. If a line is not correctly indented python interpreter would Indentation error. There are few basic rule to follow,
- Use 4 spaces for indentation
- Never mix tab and spaces
- One line blank after functions
- two lines blank after classes.
- add a space after “,” in dicts, lists, tuples and argument list and after “:” in dicts
- Spaces around assignments and comparers
- no spaces after starting and before ending () brackets/parentheses
In python on can write comments starting with ‘#’ Still gonna check whether to use “’ for multiline comments or not. links:
Modules are link library which you can in import and run function from it.
Keywords and Indentifier
As any other language there are reserved keywords in python which cannot be used as ordinary identifiers. Below is the list of identifiers. Note: Identifiers are case sensitive they should be used with same casing.