Python Forum
Unable to understand how given code takes a fixed input value, without inputting.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to understand how given code takes a fixed input value, without inputting.
#1
I got code via link in a post at stackoverflow, but unable to understand how in the code there is a fixed value taken as input, while the code asks none.

Code is at: https://ideone.com/nj4CF as given in the answer at the link on (https://stackoverflow.com/a/10907207/3693431
).

Here, fixed value of 6 is taken up.
I tried to look and found that ideone takes prog (program name: prog.py) as single parameter each time. But that means there should be 4 characters not 6. So, is the parameter stored as 'prog' and not prog.
Reply
#2
There is nothing strange here. Suppose that you write in C
int n;
scanf("%d", &n);
this code doesn't ask anything but it reads an integer in standard input. So does the C++ code
int n;
cin >> n;
or the Python 3 code
n = int(input())
Reply
#3
Gribouillis: sorry that just changed text while you answered.
Reply
#4
(Jan-28-2021, 03:22 PM)jahuja73 Wrote: Gribouillis: sorry that just changed text while you answered. To provide link to the Cpp code, it is at :

https://ideone.com/OR4VZ.

I concur with your answer for the cpp code. Please answer the changed post for python code.
Reply
#5
(Jan-28-2021, 11:35 AM)jahuja73 Wrote: Here, fixed value of 6 is taken up.
I tried to look and found that ideone takes prog (program name: prog.py) as single parameter each time. But that means there should be 4 characters not 6. So, is the parameter stored as 'prog' and not prog.
The code is meant to be run from command line and not as a script.
Then 6 is given as argument from command line.
C:\Python27
λ python prog.py 6
Output:
6 5 1 4 2 4 1 1 3 3 3 2 1 3 1 2 .....
As of 2020 is Python 2.7 officially dead💀
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to understand the meaning of the line of code. jahuja73 0 274 Jan-23-2024, 05:09 AM
Last Post: jahuja73
Question in this code, I input Key_word, it can not find although all data was exact Help me! duchien04x4 3 973 Aug-31-2023, 05:36 PM
Last Post: deanhystad
  How to do "fixed size" (wrapping) math in Python? AlexanderWulf 13 1,735 Jul-19-2023, 04:13 PM
Last Post: deanhystad
  Fixed colum width for rowLabels i Matplotlib pandabay 0 400 Jun-10-2023, 03:40 PM
Last Post: pandabay
  Code won't break While loop or go back to the input? MrKnd94 2 908 Oct-26-2022, 10:10 AM
Last Post: Larz60+
  Help Switching between keyboard/Mic input in my code Extra 1 1,046 Aug-28-2022, 10:16 PM
Last Post: deanhystad
Photo Visual studio code unable to color syntax on python interpreter tomtom 4 6,690 Mar-02-2022, 01:23 AM
Last Post: tomtom
  Encrypt and decrypt in python using own fixed key SriRajesh 3 4,626 Feb-20-2022, 01:18 PM
Last Post: dboxall123
  Unable to access the user input value given to daterangepicker klllmmm 1 2,269 May-26-2021, 09:16 PM
Last Post: nilamo
  Unable to execute input(). jahuja73 5 4,373 Feb-18-2021, 07:41 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020