Python Basics
Python Basics
Comments- Comments are used to add a remark or a descriptive note in the source code.
They are not executed by interpreter. They are added with the purpose of making the
source code easier for humans to understand. In Python, a comment starts with # (hash sign).
The input function : It is used to take input from the user. The input given by the user is
collected in a variable on LHS of = sign before the input function. The input function
returns a string by default. We can provide a string message as a prompt inside the
brackets. Eg.
Name= input(‘Enter your name’)
If we want numeric input, the function name should be preceded by int or float as required.
Eg. A = int(input(‘Enter age’)
M = float(input(“Enter marks”))
The print function(): The print function is used to print output on screen. You may use a
combination of variables, literals (fixed value) or string constants separated y comma.
Eg. print(“your age is – “, N)
print(Name, A)
print(M * 2)
print(‘Double of marks = ‘, M*2)
---------