For installing PyCharm in your System go through the following steps:
Open a web browser (e.g., Google Chrome, Firefox, or Edge).
Click on first link as shown in web browser ,go to the official JetBrains PyCharm website,or click Here .
Visit the official PyCharm website at JETBRAINS and this web page will appear
Once the page loads, you’ll see options for different editions of PyCharm.
Professional Edition: Paid version with advanced features.
Community Edition: Free version, ideal for Python programming.
Click the Download button under the Community Edition section.
You’ll be redirected to the download page.The website should automatically detect your operating system (Windows) and provide the correct installer.
If not, ensure Windows is selected in the operating system dropdown or button.
Click the Download button to start downloading the PyCharm Community Edition .exeinstaller.
The installer file will begin downloading. Its name will look something like pycharm-community-<version>.exe.Wait for the download to finish. The file size is usually around 300–400 MB.
Locate the downloaded .exe file (usually in your Downloads folder).
Double-click the file to start the installation process.
A setup wizard will appear. Follow these steps:
Welcome Screen: Click Next.
Choose Installation Path: Select or confirm the default location where PyCharm will be installed (e.g., C:\Program Files\JetBrains\PyCharm Community Edition). Then, click Next.
Installation Options:
Check Create Desktop Shortcut (optional).
Check Update PATH variable (optional but recommended for easy access to PyCharm from the command line).
Check Add Open Folder as Project (optional).
Click Next.
Choose Start Menu Folder: Leave the default or choose a custom folder for shortcuts. Click Install.
The installation will begin. This might take a few minutes.
Once the installation is complete, check Run PyCharm Community Edition if you want to open it immediately.
Open desktop and click on PyCharm Logo.
This Dialogue Box will appear, when you click on desktop Shortcut .
After PyCharm opens, create a new project:
Click New Project.
Choose a location and name for the project.
If everything works as expected, your PyCharm setup is complete.
Right Click on your project name and select new.
In New select for New file Python file.
Name your Python file , here “Trial”.
Write a Trial program of printing a “Hello World” ,and to run that script right click on screen & select Run and Debug.
This Will be the output of the “Trial”. # printing “Hello World “
Navigate to the Downloads section and select the latest stable release for Windows.Choose the appropriate installer based on your system architecture:
For 64-bit systems: “Windows installer (64-bit)”
For 32-bit systems: “Windows installer (32-bit)”
Locate the downloaded installer file (e.g., python-3.x.x-amd64.exe) and double-click to run it.
Check the box labeled “Add Python to PATH” to ensure you can run Python from the command line.Click on “Install Now” to proceed with the default installation.
In the “Optional Features” section, you can select additional components like:
Documentation
pip (Python package installer)
tcl/tk and IDLE (Python’s Integrated Development and Learning Environment)
Python test suite
py launcher
Click “Next” and in the “Advanced Options” section, you can:
Choose the installation location
Add Python to environment variables
Install for all users
After selecting the desired options, click “Install” to begin the installation.
Verify the Installation:
Open the Command Prompt:
Press Win + R, type cmd, and press Enter.
pip --version run in command prompt and python --version.
BeginnerLesson 3 of 478 min read1 runnable examples
To write your own Python programs you need the Python interpreter on your computer. This lesson installs it on Windows, macOS or Linux, checks that it works, and runs your first script.
In this lesson
Install Python 3 on your OS
Check the installed version
Use the interactive shell
Run a .py file from the terminal
Check whether Python is already installed
Open a terminal (Command Prompt or PowerShell on Windows, Terminal on macOS and Linux) and run:
Terminal
$ python--versionPython 3.15.1
If you see a version number that starts with 3, Python is ready and you can skip to the interactive shell.
Note
On macOS and Linux the command may be python3 instead of python. On Windows, the py launcher (py --version) is installed alongside Python and picks the newest version for you.
Install Python on Windows
Go to python.org, open Downloads and download the latest Python 3 installer for Windows.
Run the installer. On the first screen tick Add python.exe to PATH. This lets you type python in any terminal.
Click Install Now and wait for it to finish.
Close and reopen your terminal, then run python --version again.
Watch out
If python opens the Microsoft Store instead of printing a version, PATH was not set. Re-run the installer, choose Modify, and tick Add Python to environment variables, or turn off the “App execution aliases” for python.exe in Windows Settings.
Install Python on macOS
Download the macOS installer from python.org and run the .pkg file, or install with Homebrew: brew install python.
Open Terminal and run python3 --version.
Install Python on Linux
Most Linux distributions already include Python 3. If yours does not, install it with the package manager:
Ubuntu or Debian: sudo apt install python3 python3-pip python3-venv
Fedora: sudo dnf install python3
The interactive shell (REPL)
Type python on its own to start the interactive shell. It shows a >>> prompt, runs each line as soon as you press Enter and prints the result:
Python shell
>>> 2+35>>> "py"*3'pypypy'>>> exit()
The shell is perfect for trying one line. For anything longer, write a file.
Run your first Python file
Create a file called hello.py in any folder with this content:
hello.py
print("Hello from a Python file!")print("2 to the power 10 is",2**10)
Output
Hello from a Python file!
2 to the power 10 is 1024
Then run it from a terminal opened in that folder:
Terminal
$ pythonhello.pyHello from a Python file!2 to the power 10 is 1024
Tip
Python files always end in .py. Keep each practice program in its own file with a descriptive name such as list_sum.py, so you can find and re-run it later.
Install packages with pip
pip installs extra packages from PyPI, the Python Package Index. It comes with Python. Check that it works:
Terminal
$ python-mpip--versionpip 26.2.2 from C:\Python3\Lib\site-packages\pip (python 3.15)
You install a package with python -m pip install <name>, for example python -m pip install requests. The Modules & pip lesson covers this in detail, including virtual environments.
Check your understanding
Quick quiz
1. Which installer option lets you type python in any Windows terminal?
PATH is the list of folders Windows searches for commands. Adding Python to it makes python work everywhere.
2. What does the >>> prompt mean?
>>> is the REPL prompt. Each line you type there runs immediately.
3. Which command installs a package?
pip install (run through python -m pip to be sure it uses the right Python) downloads the package from PyPI.
Program Practice
With Python installed, write each basic program in its own .py file and run it from the terminal.
40 Python Basic Programs
Every program has a step-by-step explanation, colour-coded code and its real output.
Install the newest Python 3 release from python.org. Libraries add support for new versions quickly, and every example in this tutorial works on current Python 3.
What is the difference between python and python3?
They are names for the interpreter. On Windows the command is usually python (or py). On macOS and many Linux systems python3 is the Python 3 interpreter and python may not exist.
Do I need an IDE to write Python?
No. Any text editor and a terminal are enough. An IDE such as PyCharm or VS Code adds autocomplete, debugging and a run button. See PyCharm & VS Code Setup.
How do I uninstall Python on Windows?
Open Settings > Apps > Installed apps, find Python 3.x and click Uninstall. Remove the Python Launcher the same way if you want it gone too.
BeginnerLesson 18 of 4712 min read11 runnable examples
A list stores many values in one variable, in order. You will use lists in almost every Python program you write, from a shopping cart to a set of test results.
In this lesson
Create lists of any type
Read items with indexing and slicing
Add, change and remove items
Loop through a list
Sort a list two ways
Avoid the shared-list copy bug
What is a list in Python?
A list is written with square brackets, with items separated by commas. One list can hold numbers, strings, booleans, None and even other lists.
Lists are ordered (items keep their position), mutable (you can change them after creating them) and they allow duplicates.
You can also build a list from any iterable with list(), for example from a string or a range.
Python
print(list("abc"))print(list(range(1,6)))
Output
['a', 'b', 'c']
[1, 2, 3, 4, 5]
Indexing and slicing
Every item has a position, called its index. Counting starts at 0 from the left and at -1 from the right.
index
0
1
2
3
4
nums
10
20
30
40
50
negative
-5
-4
-3
-2
-1
Python
nums=[10,20,30,40,50]print(nums[0])# first itemprint(nums[-1])# last itemprint(nums[1:4])# items at index 1, 2, 3print(nums[::-1])# reversed copy
Output
10
50
[20, 30, 40]
[50, 40, 30, 20, 10]
Tip
A slice nums[start:stop] includes start but stops beforestop. That is why nums[1:4] returns three items. Leave out start or stop to go from the beginning or to the end.
Reading an index that does not exist raises an IndexError. A slice never does: it just returns fewer items.
Python
nums=[10,20,30]print(nums[1:10])print(nums[5])
Output
[20, 30]
Traceback (most recent call last):
File "main.py", line 3, in <module>
print(nums[5])
~~~~^^^
IndexError: list index out of range
cart=["pen","book"]cart.append("bag")# add to the endcart.insert(1,"ink")# add at index 1cart[0]="pencil"# replace an itemprint(cart)last=cart.pop()# remove and return the last itemprint(last,cart)cart.remove("ink")# remove by valueprint(cart)
Output
['pencil', 'ink', 'book', 'bag']
bag ['pencil', 'ink', 'book']
['pencil', 'book']
Python list methods you will use most
Method
What it does
Returns
append(x)
Adds x to the end
None
insert(i, x)
Adds x before index i
None
extend(items)
Adds every item from another iterable
None
remove(x)
Removes the first x; raises ValueError if it is missing
None
pop(i=-1)
Removes the item at index i
the removed item
index(x)
Finds the position of the first x
int
count(x)
Counts how often x appears
int
sort() / reverse()
Reorders the list in place
None
clear()
Removes every item
None
copy()
Makes a shallow copy
a new list
append() adds its argument as one item, while extend() adds each item separately:
dict.fromkeys(emails) builds a dictionary whose keys are the emails. A repeated key is ignored and keeps its first position, so list() of those keys is the unique list in its original order.
Program Practice: Python list programs
Practise what you just learned. Start with the easy programs and work up.
100 Python List Programs
Every program has a step-by-step explanation, colour-coded code and its real output.
What is the difference between a list and a tuple in Python?
A list is mutable, so you can add, change and remove items. A tuple is immutable: once created, its items cannot change. Use a tuple for fixed data such as coordinates. See List vs Tuple.
How do I check if an item is in a list?
Use the in operator: "apple" in fruits returns True or False.
What is the difference between append() and extend()?
append(x) adds x as one item, even if x is a list. extend(items) adds each item of items separately.
How do I remove duplicates from a list and keep the order?
Use list(dict.fromkeys(items)). list(set(items)) also removes duplicates but does not keep the original order.
Can a Python list hold different data types?
Yes. A list can mix integers, strings, floats, booleans, None and other lists, although lists of one type are easier to work with.
BeginnerLesson 16 of 4714 min read11 runnable examples
A string is a piece of text: a name, a URL, a log line, a whole file. Python strings come with dozens of built-in methods, and knowing the common ones will save you from writing loops for everyday text work.
In this lesson
Create strings with any quote style
Index and slice text
Use the most common string methods
Split text into parts and join it back
Create a string
Use single or double quotes; they mean the same thing. Pick the one that avoids escaping quotes inside the text. Triple quotes allow several lines.
Python
a='single quotes'b="double quotes, with an 'apostrophe' inside"c="""Line oneLine two"""print(a)print(b)print(c)print(len(c))
Output
single quotes
double quotes, with an 'apostrophe' inside
Line one
Line two
17
A raw string, written r"...", ignores backslash escapes. It is handy for Windows paths and regular expressions:
Python
print("C:\new\table")# \n and \t become a newline and a tabprint(r"C:\new\table")# printed exactly as written
Output
C:
ew able
C:\new\table
Index and slice
Strings are sequences of characters, so they support the same indexing and slicing as lists.
index
0
1
2
3
4
5
text
P
Y
T
H
O
N
negative
-6
-5
-4
-3
-2
-1
Python
text="PYTHON"print(text[0],text[-1])print(text[0:2],text[2:],text[:-2])print(text[::2])# every second characterprint(text[::-1])# reversed
Output
P N
PY THON PYTH
PTO
NOHTYP
Strings are immutable
You cannot change a character in place. Methods return a new string and leave the original alone.
python PYTHON
Traceback (most recent call last):
File "main.py", line 4, in <module>
word[0] = "P"
~~~~^^^
TypeError: 'str' object does not support item assignment
To “change” a string, build a new one and assign it: word = "P" + word[1:].
log="ERROR 2026-11-02 login failed for user asha"print("failed"inlog)print(log.startswith("ERROR"),log.endswith(".py"))print(log.find("login"))# index of the first matchprint(log.find("logout"))# -1 when not foundprint(log.count("a"))
Output
True
True False
17
-1
3
Tip
find() returns -1 when the text is missing, while index() raises ValueError. Use in when you only need yes or no.
Clean up text
Python
raw=" Pune, Maharashtra \n"print(repr(raw.strip()))print(repr(raw.lstrip()),repr(raw.rstrip()))print("--report--".strip("-"))print("2026-11-02".replace("-","/"))print("aaa".replace("a","b",2))# only the first 2
split() breaks a string into a list. join() does the opposite: it glues a list of strings together with the string you call it on.
Python
csv_line="asha,tester,pune"fields=csv_line.split(",")print(fields)sentence=" learn python step by step "words=sentence.split()# no argument: split on any run of whitespaceprint(words)print(" ".join(words))print("-".join(["2026","11","02"]))print(list("abc"))
Use slicing with a step of -1: text[::-1]. "".join(reversed(text)) also works.
How do I check if a string contains a substring?
Use in: "py" in "python" is True. Use find() when you also need the position.
Are Python strings mutable?
No. Every method returns a new string. To change a variable, assign the new string to it: name = name.strip().
What is the difference between split() and split(” “)?
split() splits on any run of whitespace and ignores leading and trailing spaces. split(" ") splits on every single space, so repeated spaces give empty strings.
BeginnerLesson 15 of 4714 min read12 runnable examples
A loop repeats a block of code. Use a for loop to go through every item in a collection, and a while loop to repeat until a condition changes. Loops are behind almost every practice program on this site.
In this lesson
Loop over lists, strings and dicts with for
Count with range()
Repeat until a condition with while
Control loops with break, continue and else
The for loop
A for loop takes each item from a collection in turn and runs the block once per item.
prices=[120,45,300,80,45]total=0# accumulateforpinprices:total+=pcount_cheap=0# count matchesforpinprices:ifp<100:count_cheap+=1biggest=prices[0]# track the maximumforpinprices[1:]:ifp>biggest:biggest=pprint(total,count_cheap,biggest)print(sum(prices),sum(1forpinpricesifp<100),max(prices))# built-in shortcuts
Output
590 3 300
590 3 300
Tip
Write the loop yourself while learning, because interviewers and practice programs ask for it. In real code, prefer sum(), max(), min() and any() when they fit.
range(1, 10, 2) gives 1, 3, 5, 7, 9. The loop adds 1, 3 and 5, then breaks at 7, so the total is 9.
Quick quiz
1. What numbers does range(3) produce?
range(n) starts at 0 and stops before n.
2. When does a loop’s else block run?
else is skipped if the loop was stopped by break.
3. What does continue do?
continue jumps straight to the next pass.
4. Which loop fits “keep asking until the user types quit”?
You do not know in advance how many times it will run, so use while.
Exercise: digits of a number
Use a while loop to print the sum of the digits of a number and the number reversed.
Input
40721
Expected output
Sum of digits: 14
Reversed: 12704
Hint 1
n % 10 gives the last digit and n // 10 removes it.
Python
n=40721digit_sum=0reversed_n=0whilen>0:digit=n%10digit_sum+=digitreversed_n=reversed_n*10+digitn//=10print("Sum of digits:",digit_sum)print("Reversed:",reversed_n)
Output
Sum of digits: 14
Reversed: 12704
Each pass peels off the last digit with % 10, adds it to the sum, appends it to reversed_n, then drops it with //= 10. The loop stops when no digits are left.
Program Practice
90 Python Loop Programs
Every program has a step-by-step explanation, colour-coded code and its real output.
What is the difference between a for loop and a while loop?
A for loop goes through the items of a collection or a range, so the number of passes is known. A while loop repeats until its condition becomes false.
How do I loop with an index in Python?
Use enumerate(): for i, item in enumerate(items):. Avoid for i in range(len(items)) unless you really need the number alone.
How do I loop backwards in Python?
Use reversed(items) or range(start, stop, -1), for example for i in range(10, 0, -1):.
Does Python have a do-while loop?
No. Write while True: and break at the end of the body when the condition is met.
BeginnerLesson 9 of 4711 min read8 runnable examples
Every value in Python has a type, and the type decides what you can do with it: you can add two numbers, make a string upper case, or append to a list. This lesson is a tour of the built-in types you will use every day.
0.1 + 0.2 is not exactly 0.3 because floats are stored in binary. Use round() for display, or the decimal module for money. The Numbers & Math lesson goes deeper.
Strings
A string is text in single, double or triple quotes. Strings support indexing, slicing and many methods.
name="python"name.upper()# returns a NEW stringprint(name)# the original is unchangedname[0]="P"# strings cannot be changed in place
Output
python
Traceback (most recent call last):
File "main.py", line 5, in <module>
name[0] = "P" # strings cannot be changed in place
~~~~^^^
TypeError: 'str' object does not support item assignment
Watch out
Because lists and dicts are mutable, passing one to a function lets that function change your data. Strings and numbers are safe from that.
Python has about a dozen commonly used built-in types: int, float, complex, bool, str, list, tuple, range, dict, set, frozenset, bytes and NoneType. You can also create your own with classes.
How do I check the data type of a variable?
Use type(x) to see the type, or isinstance(x, int) to test it.
What is the difference between mutable and immutable types?
Mutable objects such as lists and dicts can be changed in place. Immutable objects such as strings, numbers and tuples cannot; operations on them return new objects.
Is a string a sequence in Python?
Yes. A string is an immutable sequence of characters, so it supports indexing, slicing, len() and in.
106 string programs that cover slicing, searching, counting, replacing, splitting and joining text. They are among the most common Python interview questions, and each one has an explained solution with real output.
70 tuple programs: creating, indexing, unpacking, sorting lists of tuples, converting between tuples, lists, strings and dicts, and filtering tuples by their contents. Each solution is explained and shows its real output.
64 if-else programs that practise decisions in Python: comparisons, elif chains, nested conditions and combining tests with and / or. Each solution tests several inputs so you can see every branch run.
Before you start
Read the If…Else and Match Case lesson first if the topic is new to you.