This beginner tutorial packs Python's foundations into 30 minutes: print, variables, all 8 data types, functions, loops, decisions, error handling and imports — ending with a working chatbot project. These notes follow the video in order with timestamps, so you can revise the whole video in minutes or jump straight to the topic you need.
✎ Before you startYou only need 2 things before starting (video @ 0:19): Python installed + a code editor installed. The teacher uses PyCharm (free, from JetBrains).
1. print() — Your Very First Script
print() tells Python to display something in the console. Text always goes inside quotation marks — single ' ' or double " " both work, pick one style and stay consistent.
print('Hello, World!')
print('Hello, Bob!') Output → 'Hello, World!' then 'Hello, Bob!' — each print() appears on its own line.
Run the script with the green arrow in PyCharm (or set your own Run shortcut: Settings → Keymap → Run). Change the text to anything you like — the output changes with it. That is your first program, done!
2. Variables — Give Your Data a Name
A variable stores a value under a name, so you can reuse it everywhere instead of typing the value again and again.
name = 'Bob'
print('Hello, ' + name + '!') Output → 'Hello, Bob!'
That + joining of strings is called string concatenation — 'Hello, ' + name + '!' are glued into one string.
Now change only one line — name = 'James' — and every place that uses name updates automatically:
name = 'James'
print('Hello, ' + name + '!') # Hello, James! ★ Golden tipVariables = reusability. Define once, use everywhere. This one idea comes back in every single topic below.
3. Data Types — The 8 Kinds of Data
Until now we used text. Python has many data types — learn to recognise each one by its brackets and shape:
| Type | Looks like | Remember |
|---|---|---|
| str (string) | 'Apple' | Plain text, inside quotes. |
| int (integer) | 10 or -10 | Whole numbers — no decimal point. |
| float | 10.5 or 10.123 | Numbers WITH a decimal point. |
| bool (Boolean) | True / False | Only 2 states. Capital T and F! |
| tuple | (2.5, 1.5) | List-like, round brackets — IMMUTABLE: cannot change after creation. |
| list | ['Agneta', 'Bea', 'Benny', 'Anifred'] | Square brackets — MUTABLE: add & remove items freely. |
| set | {1, 2, 3, 4, 5} | Curly brackets — NO duplicates allowed (a second 4 simply disappears). |
| dict (dictionary) | {'Bob': 1, 'James': 2} | KEY : VALUE pairs — each key is linked to a value, like name → ID. |
⚠ RememberMutable = can change (list). Immutable = locked forever (tuple). And in a set, duplicates vanish automatically — {1, 2, 3, 4, 4, 5} prints as {1, 2, 3, 4, 5}.
4. Type Conversion — Changing One Type Into Another
Data often arrives in the wrong type — e.g. a number scraped from the internet arrives as a string '100'. You cannot do maths with it: 10 + '100' gives an error, because an int can only be added to numbers, and a string only to strings.
Fix it with a type constructor — write the target type + parentheses around the value:
number = '100'
print(10 + int(number)) # 110 ✔ works!
print(float('123.456')) # 123.456
print(int('ten')) # ValueError ✘ — 'ten' is a word, not digits! Works with any type: int(), float(), str(), set()… You can convert a variable or a value written directly. The conversion only succeeds if the value genuinely represents that type — digits can become an int, the word 'ten' cannot.
5. Type Annotations — A Label That Protects You
A type annotation is you declaring what type a variable should be, using a colon:
age: int = 10
first_name: str = 'Bob' Python itself ignores annotations — the code runs exactly the same even if you break your own rule. So why bother? Your editor / static type checker reads them and warns you the moment you do something silly, like assigning text to a variable declared as int:
age: int = 'ten' # ⚠ editor warns you instantly — before you run anything! ★ Golden tipAnnotations are optional but professional. The teacher uses them in every lesson — learn this habit now, it will save you hours of debugging later.
6. f-Strings — The Clean Way to Build Strings
Joining with + is painful: you must convert every number with str() by hand. An f-string (f = formatted string) lets you drop variables directly inside the text using curly brackets { }:
name: str = 'Bob'
age: int = 10
# ✘ old way — long, error-prone
print('Name: ' + name + ', Age: ' + str(age))
# ✔ f-string way — short & readable
print(f'Name: {name}, Age: {age}') Output → 'Name: Bob, Age: 10' — identical result from both lines.
★ Golden tipUse f-strings whenever you can. You will rarely see a professional Python developer concatenating with + .
7. Functions — Write Once, Reuse Forever
A function packages code so you can reuse it anywhere, as many times as you like. Create one with the def keyword (= define):
def add(a: float, b: float) -> float:
print(f'Adding {a} + {b}')
return a + b
print(add(10, 15)) # Adding 10 + 15 → 25.0
print(add(15, 30)) # Adding 15 + 30 → 45.0 Anatomy: a and b are parameters (inputs) • -> float declares the return type • return sends the answer back • the values you pass in, like 10 and 15, are the arguments.
Why not just write 10 + 15 twice? Because if the behaviour must change, you edit one function and every call updates — the 'Adding…' line above was added once, and both calls printed it.
Default values — make an argument optional:
def greet(name: str, greeting: str = 'Hi') -> None:
print(f'{greeting}, {name}!')
greet('Bob', 'Hello') # Hello, Bob!
greet('James') # Hi, James! ← default 'Hi' used -> None means the function returns nothing — it only does something (prints). A function may also have zero parameters: write def say_hello(): and simply call say_hello() whenever you want that code to run.
8. Loops — Repeat Without Copy-Pasting
Python has 2 loops: for for a finite (countable) number of repeats, and while for looping until a condition changes.
The for loop:
for i in range(3):
print('Hello') # Hello Hello Hello (3 times!)
names: list[str] = ['Agneta', 'Bea', 'Benny', 'Anifred']
for name in names:
print(f'Hello, {name}!') range(3) produces 3 numbers (0, 1, 2), so the loop body runs 3 times. Looping over a list visits each item once — 4 names = 4 greetings. Everything indented under the loop runs on every round.
The while loop:
i: int = 0
while i < 3:
print(i)
i += 1 # i = i + 1 — move one step closer to the end! Output → 0 1 2 — then i becomes 3, 3 < 3 is False, loop stops.
Dry run — watch i change:
| Round | i at start | i < 3 ? | Prints | i after i += 1 |
|---|---|---|---|---|
| 1 | 0 | True ✔ | 0 | 1 |
| 2 | 1 | True ✔ | 1 | 2 |
| 3 | 2 | True ✔ | 2 | 3 |
| — | 3 | False ✘ → STOP | — | — |
⚠ Rememberwhile True: with no way to stop runs forever — True is always true! A while loop needs a condition that will eventually become False, like the counter above reaching 3.
9. Comparison Operators — Asking Yes/No Questions
Comparisons always answer with a bool — True or False. Memorise all 6 (a = 1, b = 2):
| Operator | Meaning | Example | Result |
|---|---|---|---|
| > | greater than | a > b | False |
| >= | greater than OR equal | a >= b | False (True if a == b) |
| < | less than | a < b | True |
| <= | less than OR equal | a <= b | True |
| == | equal to — DOUBLE equals! | a == b | False |
| != | not equal to | a != b | True |
⚠ Remember= assigns a value (name = 'Bob'). == compares two values. Mixing them up is the most common beginner mistake in all of Python!
10. if / elif / else — Making Decisions
Your program checks conditions from top to bottom and runs the first block whose condition is True. elif = 'else if' (add as many as you want). else = everything else — the fallback.
user_input: str = 'hello'
if user_input == 'hello':
print('Bot: Hello!')
elif user_input == 'how are you':
print('Bot: Good, how about you?')
elif user_input == 'bye':
print('Bot: Goodbye!')
else:
print('Bot: Sorry, I did not understand that.') Now add just 2 things — a while True: loop around it and input() to read real typing — and this becomes a working chatbot: type 'hello' → it greets you, 'bye' → goodbye, anything else → it politely says it didn't understand. (The final project in chapter 13 builds exactly this!)
11. Exceptions — When Things Go Wrong, Don't Crash
An exception is an error that stops your whole program — e.g. printing an undefined name gives a NameError, and adding a string to an int gives a TypeError:
a: int = 10
b = '15' # ← user typed text instead of a number!
print(a + b) # TypeError: int and str do not go together ✘ CRASH Protect risky code with try / except — 'try this; if it fails, do that instead' — and your program keeps running:
try:
print(a + b)
except TypeError:
print('Please enter a number as an integer or float.')
print('Program continues...') # ✔ we still reach here! - Catch the SPECIFIC error (TypeError, ValueError…) and give the user a message that tells them how to fix it.
- Multiple except blocks are allowed — one per kind of error you expect.
- Catching plain Exception swallows every error silently — the teacher calls this bad practice. Use it only as a last resort: errors during development are your teachers, they show you what can go wrong.
12. Imports — Borrow Ready-Made Superpowers
Don't reinvent maths! import brings a ready-made module into your script. Python's built-in math module even has a square-root function:
import math
print(math.sqrt(3)) # 1.7320508...
import math as m # alias — a shorter nickname
print(m.sqrt(4)) # 2.0
from math import sqrt, tan # import only what you need
print(sqrt(5)) # 2.2360679...
print(tan(2)) # -2.1850398... 3 styles, same result: import math (use math.sqrt) • import math as m (use m.sqrt) • from math import sqrt (use sqrt directly, and you can import several names at once).
13. FINAL PROJECT — Your First Chatbot (Everything Combined!)
This one project uses almost everything from these notes: variables, annotations, f-strings, loops, if/elif/else, the in operator, lists, input, .lower() and try/except.
bot_name: str = 'Bob'
print(f'Hello, I am {bot_name}. How can I assist you today?')
while True:
user_input: str = input('You: ').lower()
if user_input in ['hi', 'hello', 'hey']:
print(f'{bot_name}: Hi there! How can I help you?')
elif user_input in ['bye', 'see you']:
print(f'{bot_name}: Goodbye, have a great day!')
elif user_input in ['+', 'add']:
print(f'{bot_name}: Sure, let us do some addition!')
try:
num1: float = float(input('First number: '))
num2: float = float(input('Second number: '))
print(f'{bot_name}: The sum is {num1 + num2}')
except ValueError:
print(f'{bot_name}: Oops, that is not a valid number. Try again!')
else:
print(f'{bot_name}: I am sorry, I do not understand that.') Output → You: Hi → Bob: Hi there! • You: add → 10, 20 → Bob: The sum is 30.0 • You: blah → Bob: I am sorry… • You: bye → Bob: Goodbye, have a great day!
3 clever details to notice:
- .lower() — Python is case-sensitive: 'Hello' ≠ 'hello'. Lowercasing the user's input first makes comparisons reliable.
- in [ ... ] — checking membership in a list understands many forms of the same intent ('hi', 'hello', 'hey') in one line, instead of one elif per word.
- float(input(...)) + except ValueError — the annotation warned the editor that input() gives a string; converting inside try means a letter typed as a 'number' gets a friendly message instead of a crash.
14. Golden Advice — How Real Programmers Learn
- The best way to learn is to BUILD apps. Decide what you want to make, start coding, and Google what you need as you go — even after 5 years, the teacher Googles constantly. That IS the job.
- Start SMALL. Don't try to build Facebook on day one — it is hundreds of concepts combined, and starting too big is how beginners give up.
- Grow this chatbot: teach it new replies, add subtraction/multiplication, let it scrape information from the internet. Small improvements, one at a time.
Notes generated from: 'Learn Python in Only 30 Minutes (Beginner Tutorial)' by Indently — youtube.com/watch?v=Ro_MScTDfU4. Watch the video alongside these notes for the full explanations. All code examples are the video's own, checked line by line.