def Complicated_Greetings(name): h=["H","e","l","l","o"] c="," w=["W","o","r","l","d"] e="!" k="" for i in h: k+=i if name=="": k+=c k+=" " for i in w: k+=i k=k+e+e else: k+=" " k+=name return k
- def Complicated_Greetings(name):
Hello = f'{chr(72)}{chr(101)}{2 * chr(108)}{chr(111)}'comma = f'{chr(44)}{chr(32)}'World = f'{chr(87)}{chr(111)}{chr(114)}{chr(108)}{chr(100)}{2 * chr(33)}'return Hello + " "+ name if name else Hello+comma+World- h=["H","e","l","l","o"]
- c=","
- w=["W","o","r","l","d"]
- e="!"
- k=""
- for i in h:
- k+=i
- if name=="":
- k+=c
- k+=" "
- for i in w:
- k+=i
- k=k+e+e
- else:
- k+=" "
- k+=name
- return k
the input will be a number and you should print a hollow diamond pattern.
example:
input n=5:
*
-
-
-
*
-
*
-
*
-
-
*
input n=7
*
* *
* *
* *
* *
-
*
-
*
-
*
-
*
-
*
-
*
-
-
-
-
-
#include <stdio.h>
int main()
{
int n;
scanf("%d",&n);
for (int i = 0; i < 2 * n - 1; i++) {
int comp;
if (i < n) {
comp = 2 * (n - i) - 1;
}
else {
comp = 2 * (i - n + 1) + 1;
}
for (int j = 0; j < comp; j++) {
printf(" ");
}
for (int k = 0; k < 2 * n - comp; k++) {
if (k == 0 || k == 2 * n - comp - 1) {
printf("* ");
}
else {
printf(" ");
}
}
printf("\n");
}
return 0;
}