A.
Write the output for the following code of statements.
a. >>>print('India', 'Delhi')
b. >>>print('India', '\t', 'Delhi')
C. >>>print('India', '\n', 'Delhi')
d. >>>a=10
>>>b=20
>>>C=(a+b)*4
> > >print(c)
e. > > > a='10'
>>> b='20'
>>>print(a+b)
f.
>>> a=10
>>> b=20
>>>print(a+b)
Answers
a. print('India', 'Delhi')
Output
India Delhi
b. print('India', '\t', 'Delhi')
Output
India Delhi
c. print('India', '\n', 'Delhi')
Output
India
Delhi
d. a = 10
b = 20
c = (a+b)*4
print(c)
Output
120
e. a = '10'
b = '20'
print(a+b)
Output
1020
f. a = 10
b = 20
print(a+b)
Output
30
Explanation
In this one
a='10'
b='20'
print(a+b)
The output is 1020 because values of a and b are strings and they are joined together in the print statement.
Extra Information
Escape characters are those characters in Python which help us in representing whitespace characters.
There are various other types of escape characters such as
\' for Single Quote
\\ for Backslash
\n for New Line
\r for Carriage Return
\t for Tab
\b for Backspace
\f for Form Feed
\ooo for Octal value
\xhh for Hex value
Python is created by Guido van Rossum and came into existence in 1991. It is a high-level and general programming language. It is a very lucid programming language as it has a good language construct and object-oriented approach. It is dynamically typed and garbage-collected.