Learn Python in 14 DaysGet Certified
Python Introduction
Welcome to the complete Python tutorial from AcademicBlock. This learning path takes you from your first Python statements to functions, data structures, object-oriented programming, algorithms, and scientific computing. You can read the lessons in order or use the menu to jump directly to a topic.
Why Learn Python?
Python is a widely used, general-purpose programming language known for readable syntax and a large ecosystem of libraries. It is used in web development, automation, data analysis, scientific research, artificial intelligence, machine learning, education, and software development.
Python is a practical first programming language because its syntax lets beginners focus on problem-solving rather than complicated punctuation. At the same time, it is powerful enough for professional projects and technical research.
What You Will Learn
- Python syntax, indentation, variables, data types, operators, and input/output.
- Conditions, loops, strings, lists, tuples, sets, and dictionaries.
- Functions, arguments, return values, modules, and packages.
- Exception handling, debugging, file handling, and JSON data.
- Classes, objects, inheritance, and other object-oriented concepts.
- Advanced features such as generators, decorators, type hints, and asynchronous programming.
- Scientific Python tools, including NumPy, Pandas, Matplotlib, and selected machine-learning workflows where browser compatibility permits.
Learn by Writing and Running Code
Reading an example is useful, but programming becomes much easier when you experiment. The code examples on this tutorial page include three tools: Copy Code, Test My Code, and Code Explanation. Copy an example, open the editor to modify and run it, or step through a line-by-line explanation.
Try Your First Python Program
This first example uses Python’s built-in print() function to display a message. Click Test My Code to open the editor. The Python environment begins loading as the page opens; if it is ready by the time you run the program, the result appears immediately.
print() to display the text Hello, World! on the screen. It is the smallest complete Python program: one instruction, one visible result.# Your first Python program
print("Hello, World!")# symbol begins a single-line comment. Python ignores the text after it when executing the program. Comments help explain the purpose of code to people reading it. This comment identifies the example as your first Python program.print() is a built-in Python function that sends text or other values to the program’s standard output. The function name is followed by parentheses, and the value to display is placed inside them."Hello, World!" is a string: a sequence of characters enclosed in matching quotation marks. The string is passed as an argument to print(). Python displays the text without the quotation marks, followed by a newline.Tip: You can edit the example in the live editor. Try changing the message, adding another print() statement, or printing a number. The editor runs Python in your browser through Pyodide; it does not send your program to the AcademicBlock server for execution.
Try It: Variables, Calculations & Loops
The next example introduces variables, arithmetic, a list, a for loop, and formatted output. It calculates the average of three marks. The blank lines are intentional: they separate the program into readable steps.
sum() and len() to work out the total and the average, then prints each mark with a for loop. Finally it prints the total and the average rounded to one decimal place (90.0).# Store three marks in a list
marks = [85, 90, 95]
# Calculate the total and average
total = sum(marks)
average = total / len(marks)
# Display each result
for mark in marks:
print("Mark:", mark)
print("Total:", total)
print(f"Average: {average:.1f}")marks is a variable name. The assignment operator = stores the list on the right in that variable. Square brackets create a list, and commas separate its three integer values: 85, 90, and 95.sum(marks) is a built-in function that adds the numeric items in the list. The result, 270, is assigned to the variable total.len(marks) returns the number of items in the list, which is 3. Dividing the total by this count gives 90.0. The division operator / produces a floating-point result.for mark in marks: begins a loop. Python takes each item from marks in order and assigns it to mark. The colon indicates that an indented block follows.Mark: followed by the current value. The output therefore contains three mark lines.print() displays the label and the value stored in total. Because this statement is not indented, it executes once after the loop.f before the quotation mark creates an f-string. Expressions inside braces are evaluated and inserted into the text. The format specifier :.1f displays the average with one digit after the decimal point.Try It: Getting Input from the User
Python’s input() function reads a line of text supplied by the user. In this browser editor, enter the responses in the Program Input box before clicking Run Code. Each response must be on a separate line and is consumed by the next input() call.
int(), and then prints a greeting plus the age the person will be next year. It shows how a program can take in information and use it in a calculation.name = input("Enter your name: ")
age = int(input("Enter your age: "))
print(f"Hello, {name}!")
print(f"Next year, you will be {age + 1}.")input("Enter your name: ") displays the prompt and reads the next line from the Program Input box. The returned value is text, which is assigned to the variable name.input("Enter your age: ") reads the next supplied line. The int() function converts that text into an integer so it can be used in arithmetic. The converted value is stored in age.f before the quotation mark creates an f-string. Python inserts the value of name inside the braces and displays a personalized greeting.age + 1 adds one to the integer entered by the student. The f-string inserts that calculated value into the output message.Try these inputs: enterAvaon the first line and18on the second line in Program Input. The program should greet Ava and report that she will be 19 next year.
Important Browser Execution Notes
Browser-based execution is convenient for learning, examples, and many scientific-computing exercises, but it is not identical to a full desktop Python installation. Pyodide supports the Python standard library and a selection of packages compiled or adapted for its WebAssembly environment. Package availability and features can differ from desktop Python.
- Programs execute on the student’s device, so execution speed depends on the device and browser.
- Some packages that depend on native operating-system components may not be available or may behave differently.
- Browser code has restricted access to the local file system, operating system, and some network features.
- Long-running or memory-intensive programs can make a browser tab slow or unresponsive. Keep beginner exercises small and bounded.
- The editor supports
input()through a Program Input box. Enter one response per line before running the program; each call toinput()reads the next line. It is not a live, prompt-by-prompt terminal, and a program that requests more lines than supplied will receive an end-of-input error. - Experiment: click Test My Code, edit the code, enter any required responses in Program Input (one line per
input()call), and click Run Code. Prompts and output appear in the console panel.
Prerequisites
No previous programming experience is required. Basic computer skills are sufficient to begin. Familiarity with arithmetic will help with early examples, while basic HTML and CSS knowledge can be useful later when exploring web-related projects. You do not need to install Python to use the browser-based examples on AcademicBlock.
How to Use This Tutorial
The sidebar organizes the lessons into sections, starting with the fundamentals and progressing toward advanced programming and scientific Python. Use the search field to find a topic quickly. Each lesson should combine explanations, runnable examples, and exercises so that you can apply each concept before moving forward.
Start with Python Introduction, then continue to syntax, variables, data types, and control flow. After learning functions and data structures, move on to object-oriented programming, algorithms, and practical projects.
Good luck with your Python journey. The most effective way to learn programming is to write code, run it, examine the result, and experiment with changes.
Frequently Asked Questions
What is Python used for?
Python is a general-purpose programming language used for web development, automation, data analysis, scientific research, artificial intelligence, machine learning, education, and software development. Its readable syntax and large library ecosystem make it suitable for both small scripts and large professional projects.
Is Python a good first programming language?
Yes. Python’s syntax is clean and close to everyday English, so beginners can concentrate on learning how to solve problems instead of memorizing complicated punctuation. It is also powerful enough that you can keep using it as your skills grow.
Do I need to install Python to follow this tutorial?
No. You can run Python examples directly in our website. Click Test My Code on any example to edit and run it. Later, you can install Python on your own computer when you are ready to build larger projects.
Do I need any programming experience before starting?
No previous programming experience is required. Basic computer skills are enough to begin, and familiarity with arithmetic will help with the early examples. The lessons start with the fundamentals and build up step by step.
How long does it take to learn Python?
It depends on how much time you can practice. With regular practice, many learners become comfortable with the fundamentals, such as variables, loops, functions, and data structures, within a few weeks. Becoming confident with advanced topics and real projects takes longer. Writing and running code yourself is the fastest way to improve.
Is Python free to use?
Yes. Python is open-source software that is free to download and use, including for commercial projects. Most of the popular libraries covered in this tutorial, such as NumPy, Pandas, and Matplotlib, are also free and open source.
How is browser-based Python different from Python on my computer?
Browser-based Python runs on your device through WebAssembly and supports the standard library plus a selection of packages. It has restricted access to the local file system and some network features, and packages that depend on native operating-system components may not be available. The input() function reads from a Program Input box before the program runs instead of pausing for live typing. For most learning exercises the behavior is the same as desktop Python.
Can I test my Python skills or get certified?
Yes. AcademicBlock offers free online Python practice exams at three levels: Exam 1 (Level A) for beginners, Exam 2 (Level B) for intermediate learners, and Exam 3 (Level C) for advanced learners. You can also visit the Python certification page to get certified.