Free Python Course | Programming Tutorials
599 subscribers
9 photos
2 files
6 links
Join Noob to Pro in Python in 100 Days! 🚀 Learn Python with daily lessons, practical examples, free code samples, exercises, and homework. Ideal for beginners and those looking to advance their skills. Start your journey to becoming a Python pro! 🐍
Download Telegram
Welcome to my Noob to Pro in Python Journey 😄

Day 1 :
Click Here
Day 2 : Click Here
Day 3 : Click Here
Day 4 : Click Here
Day 5 : Click Here
Day 6 : Click Here
Day 7 : Click Here
Day 8 : Click Here
Day 9 : Click Here
Day 10 : Click here
Day 11 : Click Here
Day 12 : Click here
Day 13 : Click here
Day 14 : Click here
Day 15 : Click here
Day 16 : Click here
Day 17 : Click here

Join/Share our journey -
@PythonBasicsCourse
103👏2
Introduction to Python
Python is a high-level, interpreted programming language known for its simplicity and readability. It was created by Guido van Rossum and first released in 1991. Python is used in various domains such as web development, data science, machine learning, automation, and more.

Why Learn Python?
Easy to Learn and Use: Python's syntax is straightforward, making it a great choice for beginners.
Versatile: Python can be used for web development, data analysis, artificial intelligence, automation, and more.
Large Community: Python has a vast and active community that provides support, libraries, and frameworks.
Great for Rapid Development: With its simple syntax and powerful libraries, Python enables developers to build applications quickly.

Applications of Python:
Web Development (e.g., Django, Flask)
Data Science and Machine Learning (e.g., Pandas, NumPy, Scikit-Learn)
Scripting and Automation
Game Development
Internet of Things (IoT)
👍154
Setting Up Python Environment
To start coding in Python, you need to install Python and set up an Integrated Development Environment (IDE).

Step-by-Step Guide to Set Up Python:
Download and Install Python:
Go to the official Python website.
Download the latest version of Python for your operating system (Windows, macOS, or Linux).
Follow the installation instructions. Make sure to check the box that says "Add Python to PATH" during installation.

Choose an IDE or Code Editor:
IDEs make coding easier by providing features like syntax highlighting, code completion, and debugging tools.
Popular Python IDEs:
PyCharm: A powerful IDE with many features. Suitable for beginners and professionals.
VS Code: Lightweight and customizable, with excellent Python support.
Jupyter Notebook: Great for data science and interactive coding.
Spyder: Ideal for scientific computing.

Verify Python Installation:
Open a command prompt (Windows) or terminal (macOS/Linux).
Type python --version or python3 --version to check if Python is installed correctly.

Installing Python Packages:
Python has a built-in package manager called pip that allows you to install additional libraries.
Example: To install the requests library, type pip install requests.

Activity: Set Up Your Python Environment
Install Python and an IDE of your choice (VS Code, PyCharm, or Jupyter Notebook).
Open your IDE and create a new Python file.
👍7
Writing Your First Python Program
Let's write our very first Python program!

Hello, World! Program
The "Hello, World!" program is a simple program that prints "Hello, World!" on the screen. It is often the first program beginners write when learning a new programming language.
python :- print("Hello, World!")
Explanation:
print(): This function is used to display output in Python. The text inside the quotation marks (" ") is called a string.

Run Your First Program:
Open your IDE or code editor.
Create a new Python file (e.g., hello_world.py).
Type the above code and save the file.
Run the code by clicking the "Run" button in your IDE or by typing python hello_world.py in your terminal/command prompt.
👍7
Understanding Python Syntax and Basic Commands
Python's syntax is designed to be readable and straightforward. Here are some key elements of Python syntax:

1. Indentation:
Python uses indentation (spaces or tabs) to define the scope of loops, functions, and classes. Unlike many other languages, Python does not use curly braces {} for code blocks.
The standard practice is to use 4 spaces for indentation.
python :-
if 5 > 2:
print("Five is greater than two!") # Correct indentation

# Indentation Error
if 5 > 2:
print("This will cause an error!") # Missing indentation

2. Comments:
Comments are used to explain code and make it more readable. They are ignored by the Python interpreter.
Single-line comments start with
#.
python
:-

# This is a single-line comment
print("Comments are ignored by Python interpreter")

Multi-line comments can be created using triple quotes ''' .

python
:-
"""
This is a multi-line comment.
It can span multiple lines.
"""
print("Multi-line comments are also ignored")


3. Variables and Data Types:
Variables are containers for storing data values. In Python, you don't need to declare the type of a variable.
Basic data types include:
int (integer), float (floating-point number), str (string), bool (boolean).
python :-
age = 25  # Integer
price = 19.99 # Float
name = "Alice" # String
is_student = True # Boolean

print(age, price, name, is_student)

4. Basic Commands and Functions:
print(): Prints the output to the console.
input(): Reads input from the user.
type(): Returns the data type of a variable.
len(): Returns the length of a string, list, or other collections.
python :-
# Taking user input and printing it
user_name = input("Enter your name: ")
print("Hello, " + user_name)

# Checking data types
print(type(user_name)) # Output: <class 'str'>
👍92
Practice Exercise for Day 1
Exercise 1: Write a Python program that prints your name, age, and favorite hobby on separate lines.

Exercise 2: Write a Python program that takes the user's name and age as input and prints a message saying "Hello [Name], you are [Age] years old!"
👍4
Homework for Day 1
Install Python and set up your development environment.
Complete the exercises given above.
Write a Python program to print the following pattern
*
**
***
****
*****
3👍1
Summary
Today, you've learned about Python, its applications, and set up your development environment. You've written your first Python program and understood the basics of Python syntax, variables, and basic commands.
👍7
Variables in Python
Variables are names that refer to values. They act as containers for storing data. In Python, you don't need to declare the type of a variable; Python automatically infers the type based on the value assigned.

Creating Variables:
Variables are created by assigning a value to a name using the = operator.
Syntax :-
variable_name = value
Examples:-
age = 30          # An integer variable
price = 19.99 # A float variable
name = "Alice" # A string variable
is_student = True # A boolean variable

Variable Naming Rules:
Variable names must start with a letter or an underscore (_), followed by letters, numbers, or underscores.
Variable names are case-sensitive (age and Age are different variables).
Avoid using Python reserved keywords as variable names.

Examples of Valid Variable
Names:
first_name = "John"
age_25 = 25
_total_amount = 100

Examples of Invalid Variable Names:
2nd_place = "Invalid"   # Starts with a number
my-variable = "Error" # Contains a hyphen
👍51
Data Types in Python
Python supports several data types, including:

1. Numeric Types:
Integer
(int): Whole numbers without a fractional part.
age = 25

Float (float): Numbers with a decimal point.
price = 19.99

String (str):
Strings are sequences of characters enclosed in quotes. They can be single quotes ('), double quotes ("), or triple quotes (''' or """) for multi-line strings.
message = "Hello, World!"
name = 'Alice'
multi_line_str = """This is a
multi-line string."""

Boolean (bool):
Boolean values represent True or False. They are often used in conditional statements and logic operations.
is_sunny = True
has_ticket = False

Typecasting and Type Function:
Typecasting: Converting from one data type to another.
int(): Converts to integer
float(): Converts to float
str(): Converts to string
bool(): Converts to boolean
Examples:-
number = int("10")        # Converts string to integer
price = float("19.99") # Converts string to float
text = str(123) # Converts integer to string

type() Function: Returns the data type of a variable.
print(type(age))       # Output: <class 'int'>
print(type(price)) # Output: <class 'float'>
print(type(name)) # Output: <class 'str'>
print(type(is_student))# Output: <class 'bool'>
👍3
Working with Strings
Strings in Python have various built-in methods for manipulation and formatting:


String Methods:
.upper(): Converts all characters to uppercase.
.lower(): Converts all characters to lowercase.
.capitalize(): Capitalizes the first character.
.replace(old, new): Replaces occurrences of a substring with another substring.
.strip(): Removes whitespace from the beginning and end of a string.
.split(separator): Splits the string into a list based on the separator.
Examples:-
text = "   Python Programming   "
print(text.upper()) # Output: " PYTHON PROGRAMMING "
print(text.lower()) # Output: " python programming "
print(text.strip()) # Output: "Python Programming"
print(text.replace("Python", "Java")) # Output: " Java Programming "
print(text.split()) # Output: ['Python', 'Programming']

String Formatting:
Using % Operator:
name = "Alice"
age = 30
print("Name: %s, Age: %d" % (name, age))

Using .format() Method:
print("Name: {}, Age: {}".format(name, age))

Using f-strings (Python 3.6+):
print(f"Name: {name}, Age: {age}")
Practice Exercises for Day 2

Exercise 1: Variable Assignment
Create variables for your name, age, height, and whether you are a student. Print each variable with a descriptive message.

Exercise 2: String Operations
Write a Python program that:
Takes a string input from the user.
Prints the string in uppercase and lowercase.
Replaces a word in the string with another word.
Strips any leading or trailing whitespace.

Exercise 3: Typecasting
Write a program that:
Takes a number as a string input from the user.
Converts the string to an integer and a float.
Prints the type of each converted value.
Homework for Day 2

Variable Creation:
Write a Python program that calculates the area of a rectangle. Use variables to store the length and width. Print the area with a descriptive message.

String Manipulation:
Write a Python program that reads a full name from the user. Then, split the name into first and last names and print them separately. Also, print the total number of characters in the full name (excluding spaces).
Summary
Today, you've learned about variables, data types, and basic string operations in Python. Understanding these concepts will help you manage and manipulate data effectively in your programs.