Python TCS
Python TCS
def inner():
print("Accessing :",
func.__name__)
return func()
return inner
def greet():
return 'Hello!'
wish = outer(greet)
wish()
def outer(func):
def inner():
print("Accessing :",
func.__name__)
return func()
return inner
def greet():
return 'Hello!'
greet = outer(greet) # decorating 'greet'
greet() # calling new 'greet'
def outer(func):
def inner():
print("Accessing :",
func.__name__)
return func()
return inner
@outer
def greet():
return 'Hello!'
greet()
------------------------------
fp = io.StringIO(zenPython)
zenlines = fp.readlines()
print('Yes')
#Add portions implementation here
return portions
---------------------------
# Define the abstract class 'Animal' below
# with abstract method 'say'
class Animal(ABC):
def __init__(self):
super().__init__()
@abstractmethod
def say(self):
return "I speak Cooooo"
class Celsius:
class Temperature:
celsius = Celsius()
self.fahrenheit = fahrenheit
t1=Temperature(32)
t1.celsius=0
---------------------------------------------
class Employee:
self.celsius = fahrenheit
def getCelsius(self):
return self.__celsius
self.__celsius = value
t1=Temperature(32)
print(t1.fahrenheit,t1.celsius)
t1.celsius=95
print(t1.fahrenheit,t1.celsius)
-----------------------------------------------
class Circle:
no_of_circles = 0
def __init__(self,radius):
self.radius = radius
Circle.no_of_circles+=1
def area(self):
return (3.14)*(self.radius**2)
-----------------------------------------------
#Add Circle class implementation here
class Circle:
no_of_circles = 0
def __init__(self,radius):
self.radius = radius
Circle.no_of_circles+=1
def area(self):
return (3.14)*(self.radius**2)
@classmethod
def getCircleCount(self):
return Circle.no_of_circles
-------------------------------------------
#Add circle class implementation here
class Circle(object):
no_of_circles=0
self.__radius = radius
Circle.no_of_circles+=1
@staticmethod
def getPi():
return 3.14
def area(self):
return self.getPi()*(self.__radius**2)
@classmethod
def getCircleCount(self):
return Circle.no_of_circles
--------------------------------------------------
# Complete the function below.
fp.write(str(input_text))
fp.close()
-------------------------------------------------
# Define 'writeTo' function below, such that
# it writes input_text string to filename.
def writeTo(filename, input_text):
with open(filename, 'w') as fp:
fp.write(str(input_text))
fp.close()
def run_process(cmd_args):
with subprocess.Popen(cmd_args, stdout=subprocess.PIPE) as p:
r = p.communicate()[0]
return (r)
------------------------------------------
def detecter(element):
def isIn(sequence):
#return(type(element),type(sequence))
if str(element) in str(sequence):
return(True)
else:
return(False)
return isIn
print(detect30 (30))
print(detect45(45))
---------------------------------------------
----------------------------------------------
def factory(n):
#n=0
#n=int(input())
def current():
return str(n)
def counter():
return str(n+1)
return current,counter
f_current,f_counter=factory(int(input()))
-------------------------------------------
# Complete the function below.
content = fp.write(input_text)
-------------------------------------------
import gzip
import shutil
# Define 'writeTo' function below, such that
# it writes input_text string to filename.
def writeTo(filename, input_text):
with open(filename, 'w') as fp:
content = fp.write(input_text)
def run_process(cmd_args):
with subprocess.Popen(cmd_args, stdout=subprocess.PIPE) as p:
return (b'Hello')
------------------------------------------------------
# Define the coroutine function 'linear_equation' below.
c = coroutine_func(*args, **kwdargs)
next(c)
return c
return wrapper
c = coroutine_func(*args, **kwdargs)
next(c)
return c
return wrapper
return new_address