Multiple commands | Sololearn: Learn to code for FREE!


Multiple commands

can we use multiple commands at once in Python like adding and subtracting will be given in two separate lines but I want the answers after the two commands which I give

11/2/2016 3:26:08 PM

Jude Felix

2 Answers

New Answer


Guesses: 1. Separate same-line commands with semicolon: >>> a,b,c=1,2,3; p,m=a+b,c-b; print(p,m) 3 1 2. Use a script file (saved from a text editor) a=1 b=2 c=3 p=a+b m=c-b print(p, m) Windows/Linux C:\>python / $ python 3 1 3. Use threads for simultaneous execution (Python is not thread-safe by default!) 4. You're asking if Python maintains state. That's what variables do; they store things for later use, so: long as the process doesn't exit.


I don't really understand what you mean. Do you want to split a long statement in two lines while maintaining its integrity? In this case use a backslash like this: print(7+8\ -5)