-1

How to read or use inputs given by stdin. For example, there are n poles with different heights. From these n poles, I have to determine whether a square will form or not using any 4 poles.I am provided with inputs of 2 line strings. 1st line gives the number of poles, 2nd line gives the height of poles. like below Inputs

8

2 4 3 2 2 4 2 2

output

YES

explanation: there are 4 poles with same height so square can be formed.

if I have to define function which takes 1 parameter as input. How should use this parameter eg. def Determinesquare(parameter):

jay
  • 29
  • 5

1 Answers1

1

Here's how you do it in python.

no_of_poles=int(input())

#store all the heights into a list for easy access
heights=list(map(int,input().split()))

and then proceed with solving the problem.

  • I am new to programming. My question is if we have only 1 parameter given for function. does the argument or parameter of function plays no role in taking input? Why are we defining 2 variables no_of_poles and heights? Does stdin automatically detects number of variables? – jay Oct 25 '20 at 04:00