Page 139 - CodePilot V5.0 C6
P. 139
float: It represents real number, where a fraction is denoted by a decimal point.
For example:
a = 7.5
string: A sequence of one or more characters enclosed in single or double quotes.
For example:
a = "hello"
In Python, the input() function always returns a value as a string. To use the input as a number,
you must convert it into the appropriate data type. This can be done using the following functions:
int(): Converts the input value into an integer.
For example:
a = int(input("Enter a number: "))
This code converts the user’s input into an integer before storing it in the variable a.
float(): Converts the input value into a floating-point number.
For example:
b = float(input("Enter a number: "))
This code converts the user’s input into a floating-point value before storing it in the
variable b.
COMMENTS IN PYTHON
Comments explain code for users and are ignored by Python during execution. They can be
single-line or multiline.
SINGLE-LINE COMMENT
A single-line comment is used to add brief notes or explanations to a single line of code. It starts
with the hash symbol (#).
Syntax of a single-line comment:
# This is a single-line comment
MULTILINE COMMENT
A multiline comment is used when the comment spans more than one line. Python does not have
a specific syntax for multiline comments, but you can use either consecutive single-line comments
or triple quotes (''' or """) to create a multiline comment.
By writing multiple single-line comments one after another:
# This is a multiline comment
# using single-line comment syntax
137
Python–Start to Code

