3. CREATING FIRST PYTHON PROGRAM

To Learn how to write Python code in interactive mode and script mode...Please watch the video by clicking 

Python Interactive Mode and Script Mode


Setting path at Windows

To add the Python directory to the path for a particular session in Windows −
At the command prompt − type path %path%;C:\Python and press Enter.
Note − C:\Python is the path of the Python directory

Python code in interactive mode and script mode:


  • Interactive mode is used when the user wants to run one single line or one block of code. It runs very quickly and gives the output instantly.​​​​​​​

  • Script Mode is used when the user is working with more than one single code or a block of code.

Creating First Program in PyCharm:

Step 1: Open PyCharm Editor. You can see the introductory screen for PyCharm. To create a new project, click on “Create New Project”.

Creating Your First Python Program

Step 2: We need to select a location to store our python programs.
  1. You can select the location where you want the project to be created. If you don’t want to change location than keep it as it is but at least change the name from “untitled” to something more meaningful, like “FirstProject".
  2. PyCharm should have found the Python interpreter you installed earlier.
  3. Next Click the “Create” Button.
Creating Your First Python Program

Step 3: Now Go up to the “File” menu and select “New”. Next, select “Python File”.
Creating Your First Python Program
Step 4: A new pop up will appear. Now type the name of the file you want (Here we give “HelloWorld”) and hit “OK”.
Creating Your First Python Program
Step 5: Now type a simple program - print (‘Hello World!’).
Creating Your First Python Program

Step 6: Now Go up to the “Run” menu and select “Run” to run your program.
Creating Your First Python Program
Step 7: You can see the output of your program at the bottom of the screen.
Creating Your First Python Program
Step 8:  If you don't have Pycharm Editor installed, don't worry, you can still run the code from the command prompt. Enter the correct path of a file in command prompt to run the program.
Creating Your First Python Program

The output of the code would be

Creating Your First Python Program


No comments:

Post a Comment