🖱️Basics of Python-Part 1


 In this blog , you will learn about some basic concepts of Python Programming.

INTRODUCTION TO PYTHON

Python is a strong and adaptable programming language that is extensively used for web development, data analysis, AI, and scientific computing. It was created by Guido Van Rossum at CWI(Centrum Wiskunde & Informatica) - a national Research Institute for Mathematics and Computer Science in Netherlands. For more related information regarding Introduction to Python, refer to our post:

--

Installation of Python IDE

For installing python on your device, refer to: How to Install Python on Device?
--

Using Python

To use Python on your Windows:
--

Writing Programs using Different Modes

Python IDLE is an IDE  where user can write codes, debug it and see the output of the program or script.
Python IDLE has two modes:
When you open IDLE, it runs in Interactive mode by default.

Interactive Mode

  • A command line shell that gives immediate results for each statement
  • default mode of python
  • in this mode, you find '>>>' symbol to type and execute each statement
You can observe the '>>>' symbol in the Python IDLE window. It is called Python Prompt.
You can see that you get immediately output after you type the statement.
You can try various other statements on interactive mode for practice. Try doing:
  • >>> print(2*5), Output:10
  • >>>"python"*4, Output: 'pythonpythonpythonpython'
  • >>>45*3, Output: 135
  • >>>67-17, Output: 50

--

Script Mode

Script Mode enables  you to write block of code or multiple lines of code known as script or Python Program. The file is saved with .py extension.
To open Script Mode:
  • Open Python IDLE, Interactive mode is opened by default
  • Click on File>New File(or press Ctrl +N)
  • A blank file named untitled will be opened
  • Write the script or code then save it as "Filename.py" 
  • To run it, select Run>Run Module or press F5 key
  • Output will be displayed in the python shell

Python File Menu



--

Interactive Mode vs Script Mode

Feature 🟢 Interactive Mode 🟠 Script Mode
How You Run It Type directly into Python shell or terminal (>>>) Write code in a .py file and run it using python filename.py
Used For Quick testing, calculations, trying out ideas Writing full programs, automation, reusability
Execution Style Line-by-line (immediate execution) Entire script runs at once
Output Instant—each line shows output right after execution Output appears when you run the script
Best For Learning, debugging, math operations, quick testing Full-fledged applications, large projects
Saved Code Nah fam, gone when you close the shell unless copied Stored permanently in a .py file
Speed Slower for big tasks Faster and optimized for larger tasks
Editor Requirement None, just the shell or terminal Needs a code editor (like VS Code, PyCharm, etc.)
Variables Persistence Lives as long as the session Only exists during script execution
Typical Use Case >>> print("Hello World") print("Hello World") in hello.py then python hello.py
--
**This is part 1 , it will be continued in upcoming posts.**
---

✨Closing up!

Thanks for reading. I hope you found this post helpful, feel free to:
Share with friends
Leave a comment
Explore more  content on CodeCrafted
---



Post a Comment

0 Comments