Python Decorators - 5 - Hands On
Python / Python Classes and Objects
1183
5. Decorators - 5
1. Define a function greet which accepts a string and returns italic HTML tags.
2. Use the Test against custom input box to output the result for debugging.
3. Provide a string (refer test case samples) to display the output/error.
Input:
Hello World! Welcome to Python Programming Language
Output:
<i>Hello World! Welcome to Python Programming Language</i>
Given Input:
Hello World! Welcome to Python Programming Language
Expected Output:
Hello World! Welcome to Python Programming Language
Program:
import os
import sys
def bold_tag(func):
def inner(*args, **kwdargs):
return ''+func(*args, **kwdargs)+''
return inner
def italic_tag(func):
def inner(*args, **kwdargs):
return ''+func(*args, **kwdargs)+''
return inner
#Add greet() function definition
@italic_tag
def greet():
msg=input()
return msg
'''Check the Tail section for input/output'''
if __name__ == "__main__":
with open(os.environ['OUTPUT_PATH'], 'w') as fout:
res_lst = list()
res_lst.append(greet())
fout.write("{}".format(*res_lst))
Output:
Hello World! Welcome to Python Programming Language
This Particular section is dedicated to Programs only. If you want learn more about Python. Then you can visit below links to get more depth on this subject.
# C Tutorials
# JAVA Tutorials
# HTML Tutorials
# Computer Fundamental
# Data Structure
# DBMS Tutorials
SQL
# C# Language
# R Language
# PHP
# Python
# Vue JS
Hello World! Welcome to Python Programming Language
Program:
import os import sys def bold_tag(func): def inner(*args, **kwdargs): return ''+func(*args, **kwdargs)+'' return inner def italic_tag(func): def inner(*args, **kwdargs): return ''+func(*args, **kwdargs)+'' return inner #Add greet() function definition @italic_tag def greet(): msg=input() return msg '''Check the Tail section for input/output''' if __name__ == "__main__": with open(os.environ['OUTPUT_PATH'], 'w') as fout: res_lst = list() res_lst.append(greet()) fout.write("{}".format(*res_lst))
Output:
Hello World! Welcome to Python Programming Language
This Particular section is dedicated to Programs only. If you want learn more about Python. Then you can visit below links to get more depth on this subject.
# C Tutorials
# JAVA Tutorials
# HTML Tutorials
# Computer Fundamental
# Data Structure
# DBMS Tutorials
SQL
# C# Language
# R Language
# PHP
# Python
# Vue JS