๐ŸInstall KODO โ€” Learn Python offline
0% Complete
Part 2 โ†’
Module 1 of 30

Python Basics & Data Types

The foundation of every Python program โ€” variables, data types, and output.

What is Python?

Python is a high-level, interpreted programming language created by Guido van Rossum in 1991. It emphasizes code readability with its use of indentation. Python is used in web development, data science, artificial intelligence, automation, and more.

Your First Python Program

Every programmer starts here. The print() function displays output to the console.

PYTHON
print("Hello, World!") print("Welcome to KODO") print(2026)
Output
Hello, World!
Welcome to KODO
2026

Python Data Types

Every value in Python has a type. Here are the 4 fundamental types:

TypeExampleDescription
int42, -7, 0Whole numbers
float3.14, -0.5Decimal numbers
str"Hello"Text (in quotes)
boolTrue, FalseBoolean logic
PYTHON
# Check types with type() print(type(42)) # <class 'int'> print(type(3.14)) # <class 'float'> print(type("Hi")) # <class 'str'> print(type(True)) # <class 'bool'>
Output
<class 'int'>
<class 'float'>
<class 'str'>
<class 'bool'>

Knowledge Check โ€” Module 1 (Q1)

Q1: What does print(type(42)) output?

Knowledge Check โ€” Module 1 (Q2)

Q2: Which is a valid Python variable name?

Module 2 of 30

Arithmetic Operators

Python can be your calculator. Master the 7 arithmetic operators.

PYTHON
a, b = 17, 5 print(a + b) # 22 print(a / b) # 3.4 print(a // b) # 3 print(a % b) # 2 print(a ** b) # 1419857
Module 3 of 30

Comparison & Logical Operators

Make decisions by comparing values.

PYTHON
x = 10 print(x > 5 and x < 20) # True print(not x == 10) # False
Module 4 of 30

Assignment Operators

Shorthand to modify variables.

PYTHON
x = 10 x += 5 # x = 15 x *= 2 # x = 30 print(x) # 30
Module 5 of 30

String Indexing & Slicing

Access characters and substrings.

PYTHON
text = "Python" print(text[0]) # P print(text[-1]) # n print(text[0:3]) # Pyt print(text[::-1]) # nohtyP
Module 6 of 30

If/Elif/Else Statements

Control program flow with conditions.

PYTHON
score = 85 if score >= 90: print("A") elif score >= 80: print("B") else: print("F")
Output
B
Module 7 of 30

Loops (For & While)

Automate repetition.

PYTHON
for i in range(5): print(i) count = 0 while count < 3: print(count); count += 1
Module 8 of 30

Lists & Dictionaries

Store collections of data.

PYTHON
fruits = ["apple", "banana"] student = {"name": "Alice", "age": 21} print(fruits[0], student["name"])
Module 9 of 30

Functions

Reusable blocks of code.

PYTHON
def add(a, b): return a + b print(add(5, 3)) # 8
Module 10 of 30

Practice Exercises

Apply everything from Modules 1-9.

10 Practice Problems

Write functions to: calculate factorial, count vowels, build a calculator, find max in a list, check palindrome, merge dictionaries, guessing game, Fibonacci sequence, remove duplicates, and build a to-do list.