Ch-7 Class - 6
Ch-7 Class - 6
An Introduction to Python
D. Answer the following questions.
Ans. Following are the rules we must remember while giving a name to the variable:
Ans. Tokens are the smallest unit and the basic building block of any programming
language. Following are the different types of tokens in Python:
a. Keywords: These are those words which have a predefined meaning in the
programming language.Eg- print , input.
b. Literals: They are those values which are given to the variables .For Eg- ‘School’ is a
string , 123 is an integer literal.
Ans. / It is used to divide the values in variables. The result is in decimal value. Whereas // It
is called floor division. It is used to divide the two numbers, but the result is the quotient.
4. Explain the print function with the help of an example. How is it different from input
function?
Ans. The print function is used to print the "message" or a "value" of a variable. A message
can be enclosed within a single quote or double quotes.4. The print function is used to
print the “message" or a "value" of a variable. A message can be enclosed within a single
quote or double quotes. For example: >>>print(“Good Day”)
5. How is the int() function different from the float() function? Explain with the help of
an example.
Ans.int() function is used to accept a value as integer, while float() function is used to
accept a value as floating point data.
Ans.When we don’t want a particular part of the program to get executed or we want to
mention the details of a command for our references then we use comments. There are
two types of comment allowed in Python:
A. Single Line Comment: Which is specified executed. Using ‘#’. Anything written after
‘#’ will not be
B. Multi Line Comment: This is specified within opening and closing triple single
quotes.