Computer Science, asked by ayushkhaitan21, 5 months ago

write a program in python A B C D E A B C D A B C​

Answers

Answered by nisha02345
2

Answer:

Input : n = 5

Output :

ABCDEDCBA

ABCD DCBA

ABC CBA

AB BA

A A

Input : n = 8

Output :

ABCDEFGHGFEDCBA

ABCDEFG GFEDCBA

ABCDEF FEDCBA

ABCDE EDCBA

ABCD DCBA

ABC CBA

AB BA

A A

Explanation:

For a given value N, reflect the number of characters taking part in the pattern, starting from A. For N = 5, Participating character would be A B C D E.

By using a nested for loop we would compute the logic. Where the outer loop of ‘i’ would range from 0 to N and the inner loop of ‘j’ would range from 65(Start) to 64 + 2*N.

Under which we would check the required condition for the pattern design. For all the values of j which are less than ((64+n)+ i) it would print the (char)((64 + n)-( j % (64+n))) and for all the values of j <= ((64+n) -i) it would print (char)j.

Answered by Anonymous
0

Answer:

For a given value N, reflect the number of characters taking part in the pattern, starting from A. For N = 5, Participating character would be A B CDE.

By using a nested for loop we would compute the logic. Where the outer loop of 'i' would range from 0 to N and the inner loop of i' would range from 65(Start) to 64 + 2*N.

Under which we would check the required condition for the pattern design. For all the values of j which are less than (64+n)+ i) it would print the (char)((64 + n)-(j % (64+n))) and for all the values of j <= ((64+n) -i) it would print (char)j.

Similar questions