Introduction to Python
Introduction to Python
Class -9
Unit -5
1. Python Modes
Ans : input() function is used to take input from the user. It allows the user to type something on the
console, and the program stores that input as a string. The input() function always returns the input
as a string (even if you enter numbers, they are treated as strings unless converted).
1. Installing Python:
To start programming in Python, you need to have Python installed on your computer.
In Interactive Mode, you can write and execute Python code directly.
python
CopyEdit
>>> print("Hello, World!")
Hello, World!
This code will immediately display the output in the same window.
In Script Mode, you can write a complete Python program in a text file and save it with a .py
extension, then run it as a script.
python
CopyEdit
print("Hello, World!")
IDLE and other IDEs (like PyCharm, VS Code, or Jupyter Notebook) are environments that
provide tools like syntax highlighting, auto-completion, debugging, etc., making it easier to write
Python code.
1. Open IDLE:
o After installing Python, you can open IDLE (comes bundled with Python).
o It has an interactive shell, but you can also write scripts by selecting File > New
File.
2. Write Your Code:
You can write your Python program in the opened file, just like in Script Mode.
3. Run the Program:
To run the program, click Run > Run Module or press F5.