Ques&Ans Notes For Python Chapter
Ques&Ans Notes For Python Chapter
B. True or False:
1. You can save the file in Interactive mode. False (We can save the file only in
Script mode.)
2. Float () function is used to convert the entered data into a float or decimal
number. True
3. “input” is a key word in Python. True
4. In Python, a string can be entered either in single or double quotes. True
5. Character data type is available in Python. False (Not available only string is
available)
6. To run a Python module, press the F6 key. False (Press F5)
7. A variable has a fixed value. False (not fixed. It can be changed)
C. Write whether the following variable names are valid or invalid. If it is invalid,
write the reason for it:
1. Employee_Code - Valid
2. Employee Code - Invalid since space is not allowed.
3. 9Star - Invalid since it can not start with a numeric value.
4. print - Invalid since print is a keyword in Python.
5. Class8.A - Invalid since special characters are not allowed.
6. ABC@Ltd -Invalid since special characters are not allowed.
11. What is the use of print( ) function? Explain the three separators used with
the print( ) function.
Ans: Print( ) function is used to print a message or value.
The three separators used are:
(i) Using (,) operator: when (,) separator is used, the values are displayed with a
space between them.
(ii) Using tab space(‘\t’): When (‘\t’) separator is used, the values are displayed
with a tab space between them.
(iii) Using newline character (‘\n’): A newline character in Python is used to end
a line and start a new line. This can be used with both input( ) and print( )
functions.
C. Write Python programs for the following:
1. To print “Hello World”.
Ans:
print(“Hello World”)
2. To initialise a variable ‘b’ with the value of 50 and print it:
Ans:
b = 50
print(“The value of b is:”,b)
3. To add two numbers 250 and 300 by assigning the values to the variables..
Ans:
a=250
b=300
Print(“The sum of two numbers is:”, a+b)
4. Write a program to get the values of three numbers during the run time and
display its sum value.
a=int(input(“Enter the First number:”))
b=int(input(“Enter the Second number.”))
c=int(input(“Enter the Third number:”))
print(“The sum of the values is:”, a+b+c)
5. Print the three values a=10, b=56 and c=87,using the three separators-‘,’ ,’\t’
and ‘\n’:
Ans:
a=10
b=56
c=87
print(a,b,c)
print(‘\n’)
print(a, ‘\t’, b, ‘\t’, c)
print(‘\n’,a, ‘\n’, b, ‘\n’, c)