2.1.1. Understanding Python Comments
# This is my first program
print("I am a Python Guru")
#print("Python is not cool")
# print() is used to print the message on console
2.1.2. Problem Solving in Comments
print("1")
# print("2")
print("3")
# print("4")
print("5")
# print("6")
print("7")
# print("8")
print("9")
# print("10")
print("11")
# print("12")
print("13")
2.1.3. Understanding Docstring in Python
def add(a, b):
"""Return sum of given arguments."""
return a + b
def power(b, e):
"""Return the power value.
b -- is the base
e -- is the exponent
"""
return b ** e
# print docstring of add method
print(add.__doc__)
# print docstring of power method
print(power.__doc__)
2.2.1. Understanding Identifiers in Python
(a) Identifiers are used for identifying entities in a program/
(d) string_1 is valid identifier.
(e) Identifiers can be of any length.
2.2.2. Understanding Python Keywords
(a) Python version 3.5 has 33 keywords.
(c) The keyword nonlocal does not exist in Python 2.
(d) Interpreter raises an error when you try to use keyword as a name of an entity.
2.2.3. Fill in the missing code
import keyword
print('and is a keyword :', keyword.iskeyword('and'))
#Fill in the missing code in the below lines
print('exec is a keyword :', keyword.iskeyword('exec'))
print('nonlocal is a keyword :', keyword.iskeyword('nonlocal'))
print('False is a keyword :', keyword.iskeyword('False'))