Python Syntax Rules:
Here are a few things you should know beforehand:
- Python is case-sensitive, which means, for example, Name and name have different meanings
- The standard is to use English names in programming
- All variables should start with a lowercase letter, for example, var = 4
- Functions begin with lowercase
- Classes begin with a capital letter
- There is no command terminator, which means no semicolon “;” or anything.
- Single quotes ‘ ‘, double quotes “” and even triple quotes ”’ “”” can be used to represent string literals.
- In Python, you can include comments in your code by beginning them with a #.
- To write multiline code that does not confuse the Python interpreter, use a backslash at the end of each line to explicitly denote line continuation.
- Python doesn’t use brackets, therefore code indentation is required
Hello World Program:
print ("Hello, World!")
- Write and run this code in IDLE, or you can save it in a python code file called test.py (you can name it anything, just keep the extension of the file as .py).
- Run the test.py python script, open IDLE, use the cd command to navigate to the directory where you saved the file, and then type the following in command prompt or your terminal:
python test.py
Output:
Hello, World!
Note: also read about Python 2 vs. Python 3
Follow Me
Please follow me to read my latest post on programming and technology if you like my post.
https://www.instagram.com/coderz.py/
https://www.facebook.com/coderz.py
Staying up to the mark is what defines me. Hi all! I’m Rabecca Fatima a keen learner, great enthusiast, ready to take new challenges as stepping stones towards flying colors.
Leave a Comment