Why, when I write this code:

pervoe=input("Input first number") vtoroe=input("Input second number") print(pervoe+vtoroe) 

the program reads lines 1 and 2, and then closes without reading line 3. Why?

  • one
    Why did you decide that line 3 is unreadable? How and where do you run the program? Maybe everything is displayed, just because there are no further instructions, then the program ends? Insert 4 lines of another input, anyway you will see the output to the screen. - BOPOH
  • Thank you very much everything worked for me! Only here it is not very convenient and I can not guess what to write in the 4th line. Maybe you know some command to delay my program? For example, in QBasic, such a command is written like this - sleep 1000. It means that the program will be delayed for 1 second, and then shut down itself. Tell me, please, if you know. And thank you so much! - Imao
  • one
    @ Bear google.com/search?q=python+sleep import time timeleath (0.5) // fall asleep for half a second - etki
  • 2
    And you can open the command line ( cmd ) and run the script already inside. Then, you will always see her output. - eigenein

1 answer 1

As an answer, you get string data, you need to convert them to integers or fractional numbers.

In your case:

 pervoe=int(pervoe) #если подразумевается ввод целых чисел или vtoroe=float(vtoroe) #если подразумевается ввод дробных чисел 

You can immediately get the user's numerical response by nested method:

 pervoe=int(input("Input first number")) 

To prevent the program from closing right away, insert the following line:

 input("\n\nНажмите Enter чтобы выйти .")