Answer:
Complete question is:
write the following decorators and apply them to a single function (applying multiple decorators to a single function):
1. The first decorator is called strong and has an inner function called wrapper. The purpose of this decorator is to add the html tags of <strong> and </strong> to the argument of the decorator. The return value of the wrapper should look like: return “<strong>” + func() + “</strong>”
2. The decorator will return the wrapper per usual.
3. The second decorator is called emphasis and has an inner function called wrapper. The purpose of this decorator is to add the html tags of <em> and </em> to the argument of the decorator similar to step 1. The return value of the wrapper should look like: return “<em>” + func() + “</em>.
4. Use the greetings() function in problem 1 as the decorated function that simply prints “Hello”.
5. Apply both decorators (by @ operator to greetings()).
6. Invoke the greetings() function and capture the result.
Code :
def strong_decorator(func):
def func_wrapper(name):
return "<strong>{0}</strong>".format(func(name))
return func_wrapper
def em_decorator(func):
def func_wrapper(name):
return "<em>{0}</em>".format(func(name))
return func_wrapper
@strong_decorator
@em_decorator
def Greetings(name):
return "{0}".format(name)
print(Greetings("Hello"))
Explanation:
Answer:
Program that removes all spaces from the given input
Explanation:
// An efficient Java program to remove all spaces
// from a string
class GFG
{
// Function to remove all spaces
// from a given string
static int removeSpaces(char []str)
{
// To keep track of non-space character count
int count = 0;
// Traverse the given string.
// If current character
// is not space, then place
// it at index 'count++'
for (int i = 0; i<str.length; i++)
if (str[i] != ' ')
str[count++] = str[i]; // here count is
// incremented
return count;
}
// Driver code
public static void main(String[] args)
{
char str[] = "g eeks for ge eeks ".toCharArray();
int i = removeSpaces(str);
System.out.println(String.valueOf(str).subSequence(0, i));
}
}
Answer:
/* C Program to rotate matrix by 90 degrees */
#include<stdio.h>
int main()
{
int matrix[100][100];
int m,n,i,j;
printf("Enter row and columns of matrix: ");
scanf("%d%d",&m,&n);
/* Enter m*n array elements */
printf("Enter matrix elements: \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&matrix[i][j]);
}
}
/* matrix after the 90 degrees rotation */
printf("Matrix after 90 degrees roration \n");
for(i=0;i<n;i++)
{
for(j=m-1;j>=0;j--)
{
printf("%d ",matrix[j][i]);
}
printf("\n");
}
return 0;
}
Answer:
A good design for a portable device to mix paint minimizing the shaking forces and vibrations while still effectively mixing the paint. Is:
The best design is one with centripetal movement. Instead of vertical or horizontal movement. With a container and system of holding structures made of materials that could absorb the vibration effectively.
Explanation:
First of all centripetal movement would be friendlier to our objective as it would not shake the can or the machine itself with disruptive vibrations. Also, we would have to use materials with a good grade of force absorption to eradicate the transmission of the movement to the rest of the structure. Allowing the reduction of the shaking forces while maintaining it effective in the process of mixing.