Beginner Roadmap to Python: Part 1

In this guide, I’m going to skip the fluff and dive straight into Python syntax.
It’s perfect if you already have some programming background — maybe in C, Java, or JavaScript — and just want to see how Python works differently.
Let’s start with a small example:
cash = 0
print(cash)
# adding 4 to count
cash = cash + 4
if cash > 0:
print("I am getting rich")
multiply_cash = "Cash " * cash
print(multiply_cash)
Output:
0
I am getting rich
Cash Cash Cash Cash
Here’s what’s happening:
We first assign
0
to the variablecash
.Then we increment it by 4.
Since
cash > 0
, theif
condition runs, printing "I am getting rich".Finally,
"Cash "
is multiplied bycash
, resulting in"Cash Cash Cash Cash"
.
Key differences you might notice if you’ve used other languages like C or Java:
No need to declare variable types — Python figures it out automatically.
print()
is a built-in function, and comments start with the#
symbol.if
statements end with a colon (:
) and the indented block defines the scope (no curly braces).Strings can be enclosed in single or double quotes.
Operators can behave differently — for example, multiplication can also be used with strings.
Before We Jump Into Data Types
Before exploring Python’s data types, it’s important to understand that Python is dynamically typed. This means you don’t need to tell Python what kind of data a variable will hold — it decides at runtime. You can even reassign a variable from a number to a string without errors.
Data Types & Operations in Python
Python works with different types of data, and you can perform various operations on them.
1. Common Data Types
Type | Example | Description |
int | 10 , -3 | Whole numbers |
float | 3.14 , -0.5 | Numbers with decimal points |
str | "hello" | Text data (strings) |
bool | True , False | Logical values |
You can check a variable’s type with type()
:
x = 42
print(type(x)) # <class 'int'>
2. Arithmetic Operators
Operator | Name | Description |
a + b | Addition | Adds two numbers |
a - b | Subtraction | Difference between a and b |
a * b | Multiplication | Product of a and b |
a / b | True Division | Quotient of a and b (returns a float) |
a // b | Floor Division | Quotient without the fractional part |
a % b | Modulus | Remainder after division of a by b |
a ** b | Exponent | a raised to the power of b |
-a | Negation | Negates the value of a |
True division vs Floor division:
print(5 / 2) # 2.5 (True division)
print(5 // 2) # 2 (Floor division)
3. Order of Operations (PEMDAS)
Python follows Parentheses → Exponents → Multiplication/Division → Addition/Subtraction:
print((3 + 5) * 5 - 5) # 35
# Parentheses first → multiplication → subtraction
4. Useful Built-in Functions
print(min(1, 2, 3)) # 1 → minimum value
print(abs(-32)) # 32 → absolute value
# Type conversion
print(float(10)) # 10.0
print(int(3.33)) # 3
print(int('807') + 1) # 808
💡 int()
and float()
can be used to convert between numbers and numeric strings.
Functions in Python
In Python, functions are blocks of reusable code that perform specific tasks.
You’ve already used built-in functions like print()
to display output and abs()
to get the absolute value of a number.
If you ever want to learn how a function works, use the help()
function:
help(print)
This shows you how to use print()
, the parameters it accepts, and what each does.
For example:
print()
can take multiple values.You can change how it separates them using
sep
.You can change what it prints at the end using
end
.
Using help()
is a quick way to understand any function without searching online.
1.Common Pitfall with help()
When using help()
, always pass the function name without parentheses:
help(round) # ✅ Correct — shows info about the function
help(round(3.6)) # ❌ Incorrect — shows info about the result (int), not the function
Why?
round
→ refers to the function itself.round(3.6)
→ calls the function and returns a value (4
).So
help(round(3.6))
is reallyhelp(4)
, which shows documentation for integers.
2.Defining Your Own Functions
Example — calculating the area of a square:
def area_of_square(side_length):
"""Calculate the area of a square given the side length."""
return side_length * side_length
print(area_of_square(5)) # 25
print(area_of_square(10)) # 100
How it works:
def
starts the function definition.area_of_square
is the function name.side_length
is the parameter.Inside the function, we multiply the side length by itself.
return
sends the result back.
3.Default Arguments
You can set default values for parameters:
def apply_discount(price, discount=10):
return price - (price * discount / 100)
print(apply_discount(100)) # 90.0 (default 10% discount)
print(apply_discount(100, 20)) # 80.0 (20% discount)
If you don’t provide a discount, it defaults to 10%
.
4.Higher-Order Functions
Some functions take other functions as inputs. Example:
def mod_5(x):
"""Return remainder when dividing x by 5."""
return x % 5
print(max(100, 51, 14)) # 100
print(max(100, 51, 14, key=mod_5)) # 14
Here, max
returns the number whose remainder when divided by 5 is largest.
Booleans and Conditionals
1.Booleans
Booleans represent True or False.
You can convert values to booleans using bool()
:
print(bool(1)) # True (all numbers except 0 are truthy)
print(bool(0)) # False
print(bool("Hi")) # True (non-empty strings are truthy)
print(bool("")) # False (empty strings are falsey)
Empty sequences (""
, []
, ()
) are falsey; everything else is truthy.
You can even use non-boolean values in if
statements:
if 0:
print(0)
elif "spam":
print("spam") # This prints because "spam" is truthy
2.Conditionals (if
, elif
, else
)
Conditionals let your program choose which code to run:
weather = "sunny"
if weather == "sunny":
print("Go outside!")
elif weather == "rainy":
print("Take an umbrella.")
else:
print("Stay home.")
3.Comparison Operators
Operator | Meaning | Example |
== | equal to | 5 == 5 |
!= | not equal to | 3 != 4 |
> | greater than | 10 > 8 |
< | less than | 2 < 5 |
>= | greater or equal | 7 >= 9 |
<= | less or equal | 4 <= 4 |
4.Combining Conditions (and
, or
, not
)
Logical operators combine or invert conditions:
age = 20
has_ticket = True
if age >= 18 and has_ticket or age == 16:
print("You can enter!")
Here, and
is checked before or
, so age >= 18 and has_ticket
runs first.
Wrapping Up – Part 1
We’ve covered the Python basics — variables, data types, operators, and type conversions. These are your building blocks for any Python program.
Next, we’ll move on to working with collections like lists, tuples, strings, and dictionaries to store and manipulate data more effectively.
Subscribe to my newsletter
Read articles from Krupa Sawant directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
