Python coding
53 subscribers
24 files
11 links
​A technical hub dedicated to Python programming, web development, and software engineering. Learn core syntax, build full-stack projects, and master backend development.
Download Telegram
Channel created
Channel photo updated
Welcome! This channel is for anyone starting out with Python.
I'm learning too — just sharing what I know and picking up more along the way.
We'll cover the basics step by step, help each other, and have some fun doing it.
One day, we'll grow this into a full community of coders.
No stress. Just learning, curiosity, and progress.
Please open Telegram to view this post
VIEW IN TELEGRAM
Python coding pinned Deleted message
Python coding pinned Deleted message
Python coding
Basic_Python_Intro_Notes.pdf
Introduction to Programming with Python

---

What is Python?

Python is a popular programming language created by Guido van Rossum in 1991.

It is known for:
- Simplicity
- Readability
- Flexibility
- Powerful libraries

Python is beginner-friendly while still being powerful enough for AI, web development, and automation.

---

What is Python Used For?

- Web Development
- Software Development
- Data Science & Mathematics
- Automation & System Scripting

Python works on multiple platforms:
- Windows
- Linux
- Mac
- Raspberry Pi

---

Important Concept: Indentation

Unlike many programming languages that use { }, Python uses indentation (spaces) to define code blocks.

Example:

if 5 > 2:
print("Five is greater than two")

Proper indentation is required in Python.

---

Your First Python Program

print("Hello World")

This prints text to the screen.

---

Reading User Input

Use the input() function to get data from users.

name = input("Please enter your name: ")

print(f"Hi {name}, nice to meet you!")

---

Variables in Python

Variables are containers used to store data.

x = 5
y = "John"

Python automatically detects the data type.

---

Casting

Casting is used to force a variable into a specific data type.

str(3)      # '3'
int(3.8) # 3
float(3) # 3.0

---

Variable Naming Rules

- Must start with a letter or underscore _
- Cannot start with a number
- Can contain letters, numbers, and underscores
- Case-sensitive (age, Age, and AGE are different)
- Cannot use Python keywords like:
- if
- while
- print

---

Naming Conventions

Camel Case:

myVariableName

Pascal Case:

MyVariableName

Snake Case (Recommended in Python):

my_variable_name

---

Built-in Data Types

Python includes several built-in data types:

- Text → str
- Numeric → int, float, complex
- Sequence → list, tuple, range
- Mapping → dict
- Boolean → bool

Check a variable type using type():

print(type(5))

Output:

<class 'int'>

---

Comments in Python

Comments make code easier to understand.

Single-line comment:

# This is a comment

Multi-line comment:

"""
This is a multi-line comment
"""
Python coding
Basic_Python_Control_Structures.pdf
Control Structures and Loops in Python

---

Conditional Statements

Conditional statements allow programs to make decisions based on conditions.

They help control the flow of a program by executing different code depending on whether a condition is True or False.

---

Comparison Operators

| Operator | Meaning |
|----------|----------|
| == | Equal to |
| != | Not equal to |
| < | Less than |
| <= | Less than or equal to |
| > | Greater than |
| >= | Greater than or equal to |

---

If, Elif, and Else

- if → checks the first condition
- elif → checks another condition if previous ones are False
- else → runs if none of the conditions are True

Example:

a = 200
b = 33

if b > a:
print("b is greater than a")

elif a == b:
print("a and b are equal")

else:
print("a is greater than b")

---

Logical Operators

Logical operators combine multiple conditions.

---

AND Operator

Returns True only if both conditions are True.

a = 200
b = 33
c = 500

if a > b and c > a:
print("Both conditions are satisfied")

---

OR Operator

Returns True if at least one condition is True.

if a > b or a > c:
print("At least one condition is True")

---

NOT Operator

Reverses the result.

a = 33
b = 200

if not a > b:
print("a is NOT greater than b")

---

Loops in Python

Loops repeat code multiple times while a condition is met.

Python mainly uses:
- while loop
- for loop

---

The While Loop

Executes repeatedly while the condition remains True.

i = 1

while i < 6:
print(i)
i += 1

Important:
Always update the loop variable to avoid infinite loops.

---

Break Statement

Stops the loop immediately.

i = 1

while i < 6:
print(i)

if i == 3:
break

i += 1

---

Continue Statement

Skips the current iteration and continues with the next one.

i = 0

while i < 6:
i += 1

if i == 3:
continue

print(i)

---

Else with Loops

The else block runs once when the loop condition becomes False.

i = 1

while i < 6:
print(i)
i += 1

else:
print("Loop finished")

---

The For Loop

A for loop is used to iterate through sequences such as:
- Lists
- Tuples
- Strings

Example:

fruits = ["apple", "banana", "cherry"]

for x in fruits:
print(x)

---

Practice Exercises

1. Write a program to check whether a number is positive, negative, or zero.

2. Print all even numbers from 1 to 20 using a loop.

3. Create a loop that stops when the number 5 is reached.

4. Loop through a string and print each character separately.