Page 132 - Trackpad_V4.0_c6_Flpbook
P. 132
Topic Flashback 21 st Century #Critical Thinking
Skills
Circle the incorrect variable in the following code.
Roll no = 201 Student Name = "Chirag" Section = 'A'
DATA TYPES
A data type specifies the type of value a variable can contain. For example, a person’s name must be
stored as a string value, whereas the person’s age must be stored as an integer.
Data types in Python are:
int: Positive or negative whole numbers (without any fractions). Example: a = 3, b= -5
float: Any positive or negative real number in which a fraction is denoted by a decimal number.
Example: a = 3.5
string: A string value is a collection of one or more characters enclosed in single or double quotes.
Example: a="hello"
COMMENTS IN PYTHON
Comments in Python can be used to explain parts of the code. It can also be used to hide the code as
well. Comments enable us to understand the way a program works. In Python, any statement starting
with the # symbol is known as a comment. Python does not execute comments. Comments are not a
part of the program, but they do enhance the interactivity of the program and make it readable. Python
supports two types of comments: single-line comments and multiline comments.
Single-line Comment
In case a user wants to specify a single-line comment, then the comment must start with the symbol #.
Example:
Program: Output:
# printing a string Hello World
print("Hello world")
Multiple-line Comment
Python does not have a dedicated syntax for multiline comments. To add a multiple-line comment, you
could insert a # for each line. Example:
Program : Output :
#printing a string Rakesh
#print two names Rachna
print("Rakesh")
print("Rachna")
However, the text written inside triple quotes (''' or ''"") is also considered a comment. You can use the
triple quotes to write multiline comments. For example:
'''This is """This is
Multiline OR Multiline
Comment''' Comment"""
130 Premium Edition-VI

