alternative
  • Home (current)
  • About
  • Tutorial
    Technologies
    C#
    Deep Learning
    Statistics for AIML
    Natural Language Processing
    Machine Learning
    SQL -Structured Query Language
    Python
    Ethical Hacking
    Placement Preparation
    Quantitative Aptitude
    View All Tutorial
  • Quiz
    C#
    SQL -Structured Query Language
    Quantitative Aptitude
    Java
    View All Quiz Course
  • Q & A
    C#
    Quantitative Aptitude
    Java
    View All Q & A course
  • Programs
  • Articles
    Identity And Access Management
    Artificial Intelligence & Machine Learning Project
    How to publish your local website on github pages with a custom domain name?
    How to download and install Xampp on Window Operating System ?
    How To Download And Install MySql Workbench
    How to install Pycharm ?
    How to install Python ?
    How to download and install Visual Studio IDE taking an example of C# (C Sharp)
    View All Post
  • Tools
    Program Compiler
    Sql Compiler
    Replace Multiple Text
    Meta Data From Multiple Url
  • Contact
  • User
    Login
    Register

Python - Things to know before proceed - Syntax ( Indentation, Comments ) Tutorial

Python syntax can be executed directly in

  • Command-line prompt
  • Python IDLE
  • Python Script mode

 

For command prompt

You have to invoke the interpreter without passing the script file, by simply typing python in the prompt, it will open the python command prompt-

After that type –

print(“Hello Fresherbell”)

to print “Hello Fresherbell”

 

For Python IDLE

You can directly use it, by opening Python IDLE from the start menu

 

Python Script Mode

You have to invoke the interpreter bypassing the script file.

To create a script file simply create a new file with an extension .py

Eg- create a file on the desktop with the name 1stprogram.py, having a simple script like- print("Hello Fresherbell") in it.

 

We assume you have a python interpreter set in the Path variable. Now, try to run the following command

i.e

C:\Users\lenovo>python Desktop/1stprogram.py

 

Python indentation

Most programming languages like C, C++, and Java use braces {  } to define blocks of code. However, Python uses indentation to define the block of code.

Indentation is used for code readability. Indentation is very important in python.

Indentation is used to indicate a block of code.

Run Program

 

Incorrect indentation will give the below IndentationError-

 

For indentation, you have to create the same space (tabs) in the same block of code. It should be simple & consistent throughout the block.

Below is a good example of using for under for loop

Run Program

Output-

 

Python Comments

Comment in Python is used to give messages in code. It starts with # and then the python will render the rest line of the code.

A comment is used in code for a better understanding of large code. It will not affect the main code.

Single Line comment ( using # )

Run Program

Output-

 

Multi-Line Comment ( using """ or ''' )

Run Program

Output-

 

Expression and Statement

An expression is a combination of values, variables, and operators. the expression will always return some value.

For example:-

5 + 12

A statement is a unit of code that a python interpreter can execute. the statement will produce the output if there is one example print statement. Otherwise, the assignment statement is another example, which does not produce output.

For example:-

a = 10 #does not produce any output
print(a) # produce the output

 

Python

Python

  • Introduction
  • Installation and running a first python program
    • How to install Python ?
    • Running 1st Hello World Python Program
    • How to install Pycharm ?
  • Things to know before proceed
    • Escape Characters/Special Characters
    • Syntax ( Indentation, Comments )
    • Variable
    • Datatype
    • Keyword
    • Literals
    • Operator
    • Precedence & Associativity Of Operator
    • Identifiers
    • Ascii, Binary, Octal, Hexadecimal
    • TypeCasting
    • Input, Output Function and Formatting
  • Decision control and looping statement
    • if-else
    • for loop
    • While loop
    • Break Statement
    • Continue Statement
    • Pass Statement
  • Datatype
    • Number
    • List
    • Tuple
    • Dictionary
    • String
    • Set
    • None & Boolean
  • String Method
    • capitalize()
    • upper()
    • lower()
    • swapcase()
    • casefold()
    • count()
    • center()
    • endswith()
    • split()
    • rsplit()
    • title()
    • strip()
    • lstrip()
    • rstrip()
    • find()
    • index()
    • format()
    • encode()
    • expandtabs()
    • format_map()
    • join()
    • ljust()
    • rjust()
    • maketrans()
    • partition()
    • rpartition()
    • translate()
    • splitlines()
    • zfill()
    • isalpha()
    • isalnum()
    • isdecimal()
    • isdigit()
    • isidentifier()
    • islower()
    • isupper()
    • isnumeric()
    • isprintable()
    • isspace()
    • istitle()
  • Python Function
    • Introduction
  • Lambda Function
    • Lambda Function
  • Python Advanced
    • Iterators
    • Module
    • File Handling
    • Exceptional Handling
    • RegEx - Regular Expression
    • Numpy
    • Pandas

About Fresherbell

Best learning portal that provides you great learning experience of various technologies with modern compilation tools and technique

Important Links

Don't hesitate to give us a call or send us a contact form message

Terms & Conditions
Privacy Policy
Contact Us

Social Media

© Untitled. All rights reserved. Demo Images: Unsplash. Design: HTML5 UP.