Practice questions for the basic syntax in python

Source code here are from the activity questions of basic syntax in python.ppt

  1. Using print() function, write a program describing yourself.

Code:

print("""
Name: Dawa Penjor
Job: Teacher
School: High School
Hobby: Programming
""")

Output:

Name: Dawa Penjor
Job: Teacher
School: High School
Hobby: Programming

2. Using print() function, write a program to display the following person.

Code:

print("""
        \|||||/
        ( 0 0 )
|--oo0----( )---------|
|                     |
       Hello Dawa
|                     |
|---------------0oo---|
        |__||__|
         ||  ||
        oo0  0oo         
""")

Output:

        \|||||/
        ( 0 0 )
|--oo0----( )---------|
|                     |
       Hello Dawa
|                     |
|---------------0oo---|
        |__||__|
         ||  ||
        oo0  0oo      

3. Write three different ways to print the same output as given below. Include comments in all the method you used.

Code:

# Method 1 - print() statement
print("Covid-19 Protocol")
print("--------------------")
print("Practice social distancing.")
print("Wear face mask.")
print("Wash your hand.")
print("Stay home.")
print("Stay safe.")

# Method 2 - a print statement with Tripple quote
print("""
Covid-19 Protocol
--------------------
Practice social distancing.
Wear face mask.
Wash your hand.
Stay home.
Stay safe.
""")

# Method 3 - Using newline (\n)
print("Covid-19 Protocol\n-------------------- \nPractice social distancing. \nWear face mask. \nWash your hand.\nStay home.\nStay safe.")

Output:

Covid-19 Protocol
--------------------
Practice social distancing.
Wear face mask.
Wash your hand.
Stay home.
Stay safe.

Covid-19 Protocol
--------------------
Practice social distancing.
Wear face mask.
Wash your hand.
Stay home.
Stay safe.

Covid-19 Protocol
-------------------- 
Practice social distancing. 
Wear face mask. 
Wash your hand.
Stay home.
Stay safe.