window. 12th Computer Chapter - - Figure . – To create new File . An untitled blank script text editor will be displayed on screen as shown in Figure .
(a) Figure . (a) Untitled, blank Python script editor . Type the following code in Script editor a = b = c = a+b print ("The Sum=", c) a = b = c = a+b print ("The Sum=", c) Figure . – Python Sample code 12th Computer Chapter - - Python – Variables and Operators (ii) Saving Python Script ( ) Choose File → Save or Press Ctrl + S Figure .
– To Save the file First time ( ) Now, Save As dialog box appears on the screen as shown in the Figure . File Location File Name (demo1) File Type (Python file (.py)) Figure . – Save As Dialog Box 12th Computer Chapter - - ( ) In the Save As dialog box, select the location where you want to save your Python code, and type the file name in File Name box. Python files are by default saved with extension .py.
Thus, while creating Python scripts using Python Script editor, no need to specify the file extension. ( ) Finally, click Save button to save your Python script. (iii) Executing Python Script ( ) Choose Run → Run Module or Press F5 a= b= c=a+b print ("The Sum=", c) Figure . – To Execute Python Script ( ) If your code has any error, it will be shown in red color in the IDLE window, and Python describes the type of error occurred.
To correct the errors, go back to Script editor, make corrections, save the file using Ctrl + S or File → Save and execute it again. ( ) For all error free code, the output will appear in the IDLE window of Python as shown in Figure . Output Figure . –Python Script Output Window 12th Computer Chapter - - Python – Variables and Operators .
Input and Output Functions A program needs