Computer Science, asked by shubhsinghal974, 2 days ago

Write a python program to get the following output
1-----99
2-----98
3-----97
. .
. .
. .
98-----2
99-----1

Answers

Answered by anindyaadhikari13
3

Solution:

The given c‎ode is written in Python.

1. Using loop.

for i in range(1,101):

 print(i,100-i,sep="-----")

2. One line c‎ode.

print("\n".join(f"{i}-----{100-i}" for i in range(1,101)))

Logic:

  • Logic is very simple. Here, the loop iterates in the range i = 1 to 100. After each iteration, we have to display the values of i and 100 - i with dash '-' as separator.

See the attachment for output.

Attachments:
Answered by crazysanthu98
0

Answer:For I in range(1,100)

. Print(i,"----",100-i)

Explanation:

Similar questions