You are on page 1of 1

Chapter 2:

My first program in python.


1. Write a program to to print a sample text as shown,

This is Python
and hope you are a programmer.
Who wants to learn me?

2. Write a program to get the following output?


w w
www
w
www
w w
The first and last lines have tab as space between them.

3.How to write multiple statements on a single line?

4.Write a program to provide following output


hello 'hi' bye 'why'

5.Write a program to show documented comments in the Program.

Answers:

1.
#!/usr/bin/python
print """This is Python
and hope you are a programmer.
Who wants to learn me?"""

2.
#!/usr/bin/python
print "w\tw"
print " w w w"
print " w"
print " w w w"
print "w\tw"

3.
By seperating them with ";"

4.
#!/usr/bin/python
print "hello \'hi\' bye \'why\'"

5.
#!/usr/bin/python
print __doc__

You might also like