Introduction
Are you new to Python programming? If so, you’ve come to the right place! Python is one of the most beginner-friendly programming languages due to its simple syntax, versatility, and wide range of applications in web development, data science, AI, and automation.
In this guide, we’ll cover the fundamental concepts of Python that every beginner should know:
✅ Variables and Data Types
✅ Operators in Python
✅ Loops and Conditional Statements
✅ Functions and Modules
Let’s dive in! 🚀
1️⃣ Variables and Data Types in Python
A variable is a name that refers to a value stored in memory. In Python, you don’t need to declare the data type explicitly; it is assigned automatically.
📌 Declaring Variables in Python
# Assigning values to variables
name = "TechGyan"
age = 25
height = 5.8
is_coder = True
print(name, age, height, is_coder)
📌 Common Data Types in Python
Data Type | Example | Description |
int | age = 25 | Integer values |
float | height = 5.8 | Decimal values |
str | name = "John" | String (text) |
bool | is_coder = True | Boolean values (True/False) |
list | numbers = [1,2,3] | Ordered collection |
tuple | coordinates = (4,5) | Immutable collection |
dict | person = {"name": "Alice", "age": 30} | Key-value pairs |
2️⃣ Operators in Python
Operators in Python allow you to perform different operations on variables and values.
📌 Arithmetic Operators
x = 10
y = 5
print(x + y) # Addition
print(x - y) # Subtraction
print(x * y) # Multiplication
print(x / y) # Division
print(x % y) # Modulus (Remainder)
print(x ** y) # Exponentiation
📌 Comparison Operators
print(10 > 5) # True
print(10 < 5) # False
print(10 == 10) # True
print(10 != 5) # True
📌 Logical Operators
x = True
y = False
print(x and y) # False
print(x or y) # True
print(not x) # False
3️⃣ Loops and Conditional Statements
Loops and conditional statements help control the flow of the program.
📌 If-Else Statements
age = 18
if age >= 18:
print("You are eligible to vote!")
else:
print("You are not eligible to vote yet.")
📌 For Loop
for i in range(1, 6):
print("Iteration:", i)
📌 While Loop
x = 1
while x <= 5:
print("Count:", x)
x += 1
4️⃣ Functions and Modules in Python
Functions help organize code into reusable blocks.
📌 Defining a Function
def greet(name):
return "Hello, " + name + "!"
print(greet("TechGyan"))
📌 Importing and Using Modules
Python has built-in modules that provide extra functionalities.
import math
print(math.sqrt(16)) # Square root function
Conclusion 🎯
Congratulations! You’ve covered the fundamentals of Python:
✅ Variables and Data Types
✅ Operators Operator by TechGyan
✅ Loops and Conditional Statements
✅ Functions and Modules
The next step? Start coding! Try building small projects like a calculator, to-do list, or a simple chatbot.
💡 Did you find this tutorial helpful? Let us know in the comments and share it with fellow beginners! 🚀