Python Basics

Akhila
2 min readNov 21, 2020

Input/Output, Comments, Variables, Rules for variables.

***********************

Input/Output are used to take input from the user and print the output

Syntax: variable_name = input()

Ex: a = input(a)

For best practice use message ex: a = input(“Enter your name : “)

Rules:

  1. By default the input() type is string.
  2. In order to take different types of input, below is the syntax.

syntax : a = int(input(a)), a = float(input(a)) etc..

For output we use print() keyword to display messages, variable values etc

Syntax: print(a)

Ex:print(“Hello world”)

print(“The value of a is : “)

Comments

In python we have two type of comments.

  1. Single line comments
  2. Multiline comments

Syntax:

Single line comments : # is used to make single line comment

Multipline comments : ‘’’ 3 quotes are used to make multiline comments

Best practice: Comments make code easy to read. Try to include comments in every peice of code.

Example: # This is a single line comment

“”” This is a multiline comments

We can use second line aslo “””

Variables

Variables are used to store values.

Example : a = 10

Here ‘a’ is a variable which store value 10.

Variables can store any type of data.

Variables Rules

  1. Variable should start with a alphabet and underscore(_)
  2. Variable should not start with special characters, keywords,numbers, double underscore.

Example: a, _a

Best Practice: Start variable with alphabet and use underscore in between for bet understanding

Hope, this piece of document helps with the python basics.

--

--