Pythonfundamentals typeAQ
Pythonfundamentals typeAQ
Questions
Question 1
What are tokens in Python ? How many types of tokens are allowed in
Python ? Examplify your answer.
Answer
Question 2
Answer
What are literals in Python ? How many types of literals are allowed in
Python ?
Answer
Literals are data items that have a fixed value. The different types of
literals allowed in Python are:
6. String literals
7. Numeric literals
8. Boolean literals
9. Special literal None
10. Literal collections
Question 4
Answer
Question 5
Answer
Floating constants are represented in Python in two forms — Fractional
Form and Exponent form. Examples:
Question 6
Answer
Question 7
Which of these is not a legal numeric type in Python ? (a) int (b) float (c)
decimal.
Answer
Question 8
Answer
(i) sep
(ii) end
Question 9
Answer
Question 10
Answer
Question 11
Question 12
Answer
if b > 5:
print("Value of 'b' is less than 5.")
print("Thank you.")
Question 13
Answer
Question 14
Answer
Variables are named labels whose values can be used and processed
during program run. Variables are important for a program because
they enable a program to process different sets of data.
Question 15
Answer
The first line of the above code snippet will cause an undefined variable
error as we are trying to use x before assigning a value to it.
Question 16
Answer
x = 10
print(x)
x = "Hello World"
print(x)
Question 17
Answer
Question 18
Answer
The error in the above code is that we have mentioned two variables X,
Y as Lvalues but only give a single numeric literal 7 as the Rvalue. We
need to specify one more value like this to correct the error:
X, Y = 7, 8
Question 19
Answer
Question 20