Input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Input

Why do we have to write the inputs just before the program runs?

28th Mar 2018, 1:57 PM
Al_
Al_ - avatar
5 Answers
+ 2
Inputs from user are required to be done all at once just before running the code, due to how codes are handled in code playground (except for web project) : code are running on server side, not locally, so in/output are buffered... inputs need to be collected at start to be send with code on server side, and outputs are collected on server side during code execution and returned to user side for displaying after code end ;) For web project, code is first send to server side, but then executed on user side after reloaded as normal http request (because that's the usual way to handle web code, without requiring compiler/interpreter to be installed and able to be handled from app' or browser)...
28th Mar 2018, 3:53 PM
visph
visph - avatar
28th Mar 2018, 2:48 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 1
No you can write them anywhere as per your need.
2nd Apr 2018, 10:36 AM
Mitali
Mitali - avatar
0
I think it's the fault of the in-built python console of SoloLearn. Because the same line of code with an IDE works fine. I mean after defining a variable which need an input, the running of the code stops and wait for this input before go further. Is it correct?
28th Mar 2018, 2:00 PM
Al_
Al_ - avatar
0
No! Even if you put the inputs at the end you will get the popup before the code runs.
28th Mar 2018, 3:09 PM
Ulisses Cruz
Ulisses Cruz - avatar