0% found this document useful (0 votes)
66 views2 pages

Ch-7 Class - 6

Uploaded by

Pooja Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views2 pages

Ch-7 Class - 6

Uploaded by

Pooja Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Ch-7

An Introduction to Python
D. Answer the following questions.

1. Give the rules for naming a variable.

Ans. Following are the rules we must remember while giving a name to the variable:

a. A variable name can only start with an alphabet.


b. A variable name can contain numbers but not at the first position.
c. A variable name allows only one special character called underscore, which can
come at the first position.
d. No spaces are allowed in a variable name.
e. A variable cannot be a keyword, which already has a predefined meaning in the
program.
f. Since Python is a case sensitive language so variable “One” is different from “one”

2. Explain any two Python Tokens.

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.

3. Differentiate between / and // operators.

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”)

Output: Good Day


To accept the value in a variable during the execution of our program, we use input ()
function. We can specify the type of value we wish to accept. The default value accepted is
in the form of the string.

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.

6. Give the two ways to give comments in a program.

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.

You might also like