Robotics & Artificial Intelligence
Write Python code to display the following pattern:
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5
Python Control Flow
2 Likes
Answer
for i in range(1, 6):
for j in range(5, i - 1, -1):
print(j, end=" ")
print()Output
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5
Answered By
1 Like
Related Questions
Write a Python code to accept any 20 numbers and display only those numbers which are prime.
[Hint: A number is said to be prime, if it is divisible by 1 and the number itself.]
A number is said to be 'Happy number' if eventual sum of the square of its digits results in 1. Write a Python code to input a number and check whether it is a Happy Number or not.
Sample Input: 31
Sample Output: 31 = 32 + 12 = 10 = 12 + 0 = 1
Hence, it is a Happy Number
Write Python code to display the following pattern:
1 3 5 7 9 1 3 5 7 1 3 5 1 3 1Write Python code to display the following pattern:
5 5 4 5 4 3 5 4 3 2 5 4 3 2 1