Back to Home
Free Programming Course

Python ProgrammingFrom Basics to Advanced Concepts

A beginner-friendly Python course covering setup, syntax, data structures, control flow, functions, files, exceptions, generators, OOP and modern Python patterns.

6 hrs self-paced
Beginner → Intermediate
Placement Ready
6
Modules
52
Topics
6
Quizzes
32
Practice Drills
6h
Self-paced

Your Learning Progress

Modules complete
0 / 6
Drills done
0 / 32
Remaining items
38
Completion
0%

Module 1 – Python Basics

Understand what Python is, how to install and run it, and how to work with variables, data types, casting, comments and I/O.


1. Introduction to Python

Definition: Python is a high-level, interpreted programming language known for its clear syntax, readability, and wide use in web development, automation, data science, scripting, artificial intelligence, and general-purpose programming.

Why Python is popular

  • Easy to read and write.
  • Great for beginners.
  • Large standard library.
  • Huge ecosystem of third-party packages.
  • Useful in many domains.

Example use cases

  • Building websites
  • Data analysis
  • Automation scripts
  • Machine learning
  • File processing

2. Installing Python and Running Code

Python can be installed from the official Python website. Once installed, you can run code in the interactive shell,

code
1.py
script files, notebooks, or IDEs such as VS Code or PyCharm.

Running a script:

bash
1python hello.py

Example file:

python
1print("Hello, World!")

3. Hello World

python
1print("Hello, World!")

Explanation

  • code
    1print()
    displays output on the screen.
  • The text inside quotes is a string.
  • This is the simplest Python program.

4. Syntax and Indentation

Python uses indentation to define code blocks instead of braces.

python
1if 5 > 2:
2 print("Five is greater than two")
  • The colon
    code
    1:
    starts a block.
  • The indented line belongs to that block.
  • Indentation is mandatory in Python.
  • Do not mix tabs and spaces in the same block.

5. Variables

Definition: A variable is a named container used to store a value.

python
1age = 18
2name = "John"
3print(name)
  • code
    1age
    stores an integer.
  • code
    1name
    stores a string.
  • Python does not require explicit type declarations.

Variable naming rules

ValidInvalid
code
1age
code
11age
code
1my_name
code
1my-name
code
1total1
code
1class
code
1is_active

Use meaningful names, prefer lowercase with underscores, and avoid reserved words.


6. Basic Data Types

Python has several built-in types.

TypeMeaning
strtext
intinteger
floatdecimal number
complexcomplex number
booltrue / false
listordered, mutable collection
tupleordered, immutable collection
setunordered unique collection
dictkey-value mapping
rangenumeric sequence

7. Strings, Numbers, Booleans

python
1hello = "Hello World"
2multi_string = """Multiline
3Lorem ipsum dolor sit amet,
4consectetur adipiscing elit"""
5
6x = 1 # int
7y = 2.8 # float
8z = 1j # complex
9
10my_bool = True
11print(bool(0)) # False
12print(bool(1)) # True

8. Type Checking and Casting

python
1x = 1
2print(type(x)) # <class 'int'>
3
4x = int("3")
5y = float("4.2")
6z = str(2)
  • Type checking helps you understand what kind of value a variable contains.
  • Casting converts one data type into another.

9. Comments

python
1# This is a single-line comment
2print("Hello World") # inline comment
3
4"""
5This is a multi-line comment
6used for documentation.
7"""

10. Input and Output

python
1name = input("Enter your name: ")
2print("Hello,", name)
  • code
    1input()
    waits for user input.
  • The returned value is always a string.

11. Arithmetic Operations

python
1result = 10 + 30 # 40
2result = 40 - 10 # 30
3result = 50 * 5 # 250
4result = 16 / 4 # 4.0 (floating-point division)
5result = 16 // 4 # 4 (floor division)
6result = 25 % 2 # 1 (remainder)
7result = 5 ** 3 # 125 (exponent)

Compound assignment:

python
1counter = 0
2counter += 10
3message = "Part 1."
4message += "Part 2."

12. Formatted Output

python
1name = "John"
2age = 23
3
4# %-style
5print("%s is %d years old." % (name, age))
6
7# .format()
8print("My name is {}, I'm {}".format(name, age))
9
10# f-strings (preferred)
11print(f"My name is {name}, I'm {age}")
12num = 10
13print(f"{num} + 10 = {num + 10}")

Module Recap

  • What Python is and why it is used.
  • How to write and run a simple Python program.
  • How indentation controls structure.
  • How variables, data types and casting work.
  • How to print output and accept input.
  • How basic arithmetic and formatting work.

Practice Drill

Module 1 Quiz

1. Which of these is a valid Python variable name?
2. What is the output of `print(16 // 4)`?
3. How do you check the type of `x = 10`?

Practice Drill Bank

Every practice drill from the course, organised by module. Rehearse these until they feel automatic.

Final Revision Checklist

Tick items as you master them — progress saves automatically.

Module 1Python Basics, Setup, Syntax, Variables & Data Types

Module 2Strings, Lists, Tuples, Sets & Dictionaries

Module 3Control Flow, Conditions & Loops

Module 4Functions, Modules & Advanced Concepts

Module 5File Handling, Exceptions & Generators

Module 6Classes, Objects, Inheritance & Advanced Python

Congratulations!

You've finished the CodeStudio Python Programming course. Revise, drill, and keep building.

Back to Home