Python (ESH)


Kanal geosi va tili: ko‘rsatilmagan, ko‘rsatilmagan
Toifa: ko‘rsatilmagan


📚 Ethio-Study-Hack (ESH): Learn Python 📚
Python learning channel for PC and smartphone users.
What You'll Learn:
- Basics to Advanced Python
- Pydroid 3 tutorials
Why Join Us?
- Step-by-step lessons
- Practical exercise
Start coding with us today!!

Связанные каналы

Kanal geosi va tili
ko‘rsatilmagan, ko‘rsatilmagan
Toifa
ko‘rsatilmagan
Statistika
Postlar filtri


---

📚 Lesson 3: Control Flow 📚

Class 1: Conditional Statements

---

🔹 1. Introduction to Control Flow

Control flow statements are fundamental in programming as they allow you to control the sequence of execution based on conditions or loops. They are crucial for decision-making and repetitive tasks within a program.

---

🔹 2. Conditional Statements

if Statement:
The if statement evaluates a condition and executes the indented code block if the condition is True.

age = 18
if age >= 18:
print("You are an adult.")
else Statement:
The else statement follows an if statement and runs if the condition in the if statement is False.

age = 16
if age >= 18:
print("You are an adult.")
else:
print("You are not an adult.")
elif Statement:
The elif (short for "else if") statement allows you to check multiple conditions sequentially.

age = 20
if age < 13:
print("You are a child.")
elif age < 18:
print("You are a teenager.")
else:
print("You are an adult.")
---

🔹 3. Nested Conditional Statements

Conditional statements can be nested inside one another to handle more complex decision-making.

age = 25
if age > 0:
if age < 18:
print("You are a minor.")
else:
print("You are an adult.")
else:
print("Invalid age.")
---

🔹 4. Logical Operators in Conditions

You can use logical operators (and, or, not) to combine multiple conditions.

age = 30
has_id = True

if age >= 18 and has_id:
print("You can enter.")
else:
print("You cannot enter.")
---

🔹 Practice Exercises:

1. Simple Conditionals:

temperature = 30

if temperature > 25:
print("It's hot outside.")
else:
print("It's not hot outside.")

2. Multiple Conditions:

score = 85

if score >= 90:
print("Grade: A")
elif score >= 80:
print("Grade: B")
elif score >= 70:
print("Grade: C")
elif score >= 60:
print("Grade: D")
else:
print("Grade: F")

3. Nested Conditionals:

username = "admin"
password = "1234"

if username == "admin":
if password == "1234":
print("Access granted.")
else:
print("Incorrect password.")
else:
print("Incorrect username.")

4. Using Logical Operators:

is_raining = False
has_umbrella = True

if not is_raining or has_umbrella:
print("You can go outside.")
else:
print("You should stay inside.")

---

🔹 Exercise:

Create a program that:
- Asks the user for their age and whether they have a driving license.
- Prints whether they are allowed to drive based on their age and possession of a driving license.

# Ask the user for their age
age = int(input("Enter your age: "))

# Ask if they have a driving license
has_license = input("Do you have a driving license? (yes/no): ").lower() == "yes"

# Determine if they can drive
if age >= 18 and has_license:
print("You are allowed to drive.")
else:
print("You are not allowed to drive.")
---

Practice these concepts thoroughly to master control flow in Python! 🚀💪


🔹 4. Type Conversion:

Type conversion allows changing the data type of a value from one type to another.

Type Casting:
# String to Integer
num_str = "123"
num_int = int(num_str)
print(num_int) # Output: 123

# Integer to String
num = 456
num_str = str(num)
print(num_str) # Output: 456
# Float to Integer
num_float = 3.14
num_int = int(num_float)
print(num_int) # Output: 3

# Handling Type Error
user_input = input("Enter a number: ")
try:
user_number = int(user_input)
print("You entered:", user_number)
except ValueError:
print("Invalid input. Please enter a valid number.")
*Explanation:* Type casting converts data from one type to another.

---

🔹 Practice Exercises:

1. Write code snippets to:
- Perform arithmetic operations on variables.
- Manipulate strings using various operations and methods.
- Evaluate boolean expressions and logical operations.
- Convert between different data types and handle type errors.


---

Conclusion:
Congratulations on completing Lesson 2! You've mastered essential operations and conversions in Python. Practice regularly to solidify your understanding.

---


---

Python (ESH):

📚 Lesson 2: Basic Data Types and Variables

Class 2: Basic Operations and Type Conversion

---

Introduction:
Welcome to Lesson 2 of Python Basics! In this lesson, we will dive into fundamental operations on basic data types and explore type conversions in Python.

Objectives:
- Understand arithmetic operations (+, -, *, /, %, **, //) and their applications.
- Learn about string operations like concatenation, slicing, and methods.
- Explore boolean operations (AND, OR, NOT) and comparison operators.
- Master type casting and handling type errors effectively.

---

🔹 1. Arithmetic Operations:

Arithmetic operations are fundamental in programming and Python provides several operators for these tasks.

Addition (+):
a = 5
b = 3
result = a + b
print(result) # Output: 8
*Explanation:* Addition combines values to produce a new value.

Subtraction (-):
a = 10
b = 4
result = a - b
print(result) # Output: 6
*Explanation:* Subtraction subtracts one value from another.

Multiplication (*):
a = 7
b = 6
result = a * b
print(result) # Output: 42
*Explanation:* Multiplication creates a product of two values.

Division (/):
a = 20
b = 5
result = a / b
print(result) # Output: 4.0
*Explanation:* Division divides one value by another, returning a float.

Modulus (%):
a = 13
b = 5
result = a % b
print(result) # Output: 3
*Explanation:* Modulus returns the remainder of a division.

Exponentiation () and Integer Division (//):**
a = 2
b = 3
result_exp = a ** b
print(result_exp) # Output: 8

result_int_div = a // b
print(result_int_div) # Output: 0
*Explanation:* Exponentiation raises a value to the power of another. Integer Division returns the quotient without the remainder.

---

🔹 2. String Operations:

Strings are sequences of characters, and Python offers various operations to manipulate them.

Concatenation:
first_name = "John"
last_name = "Doe"
full_name = first_name + " " + last_name
print(full_name) # Output: John Doe
*Explanation:* Concatenation combines strings to create a new string.

String Length:
message = "Hello, World!"
length = len(message)
print(length) # Output: 13
*Explanation:* len() calculates the length of a string.

String Slicing:
greeting = "Hello, World!"
part = greeting[0:5]
print(part) # Output: Hello
*Explanation:* Slicing extracts a part of the string based on indices.

String Methods:
message = " Hello, World! "
print(message.lower()) # Output: hello, world!
print(message.upper()) # Output: HELLO, WORLD!
print(message.strip()) # Output: Hello, World!
*Explanation:* String methods modify or analyze strings.

---

🔹 3. Boolean Operations:

Boolean operations deal with true/false values and are crucial for decision-making in programs.

Logical AND:
a = True
b = False
result = a and b
print(result) # Output: False
*Explanation:* Logical AND returns true only if both operands are true.

Logical OR:
a = True
b = False
result = a or b
print(result) # Output: True
*Explanation:* Logical OR returns true if at least one operand is true.

Logical NOT:
a = True
result = not a
print(result) # Output: False
*Explanation:* Logical NOT negates the operand's value.

Comparison Operators:
a = 10
b = 5
print(a == b) # Output: False
print(a != b) # Output: True
print(a > b) # Output: True
print(a < b) # Output: False
print(a >= b) # Output: True
print(a


🔹Reviews and updated lessons🔹


📚 Advanced Python Notes: Lists 📚

---

1. Introduction to Lists

Lists are versatile data structures in Python that can store multiple items of different data types. They are mutable, meaning you can modify them after creation.

2. Creating Lists

You can create a list using square brackets [] and separating items with commas. Lists can contain elements like integers, strings, floats, or even other lists.

Example:

my_list = [1, 2, 'hello', 3.14, [4, 5]]

3. Accessing Elements

- Indexing: Use square brackets with the index to access elements. Indexing starts from 0.

print(my_list[0]) # Output: 1

- Slicing: Extract a portion of the list using a start and end index.

print(my_list[1:3]) # Output: [2, 'hello']

4. List Methods

- append(): Adds an element to the end of the list.
- insert(): Inserts an element at a specified position.
- remove(): Removes the first occurrence of a specified element.
- pop(): Removes and returns the element at a specified index.
- clear(): Removes all elements from the list.

Example:

my_list.append('new item')
my_list.remove('hello')

5. List Comprehensions

List comprehensions offer a concise way to create lists based on existing lists. They are powerful and efficient.

Example:

squares = [x**2 for x in range(1, 6)]

6. Nested Lists

Lists can be nested within each other to create multidimensional structures. This is useful for handling complex data.

Example:

matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

7. Advanced Techniques

- List unpacking: Assign multiple variables from a list in a single line.

a, b, c = [1, 2, 3]

- List copying: Be cautious with copying lists to avoid unexpected behavior due to references.

copy_list = original_list.copy() # Shallow copy

- List comprehension with conditionals: Create filtered lists based on conditions.

even_numbers = [x for x in range(10) if x % 2 == 0]

8. Common Pitfalls

- Modifying a list while iterating over it can lead to unexpected results.
- Be mindful of references when copying lists, especially with nested structures.

9. Practice Exercises

- Create a list of integers and perform various operations like appending, inserting, removing, and using list comprehensions.
- Experiment with nested lists and list unpacking.
- Solve problems using list-related operations to reinforce your understanding.

---

Mastering lists opens up a wide range of possibilities in Python programming. Practice regularly to strengthen your skills! 🚀💪


---

📚 Lesson 4: Functions 📚

Class 3: Functions

---

🔹 1. Introduction to Functions

- Functions are reusable blocks of code that perform a specific task.
- They help in organizing code, reducing repetition, and improving readability.

Defining a Function:

- Use the def keyword followed by the function name and parentheses.
- The code block within the function is indented.

Syntax:

def function_name(parameters):
# Code to execute
return result
Example:

def greet(name):
return f"Hello, {name}!"
Calling a Function:

- To use a function, call it by its name followed by parentheses.
- Pass arguments inside the parentheses if the function requires them.

message = greet("Alice")
print(message) # Output: Hello, Alice!
---

🔹 2. Parameters and Arguments

- Functions can take parameters to process inputs.
- Arguments are the actual values passed to the parameters when calling the function.

Example:

def add(a, b):
return a + b

result = add(3, 5)
print(result) # Output: 8
Default Parameters:

- You can define default values for parameters.

def greet(name="Guest"):
return f"Hello, {name}!"

print(greet()) # Output: Hello, Guest!
print(greet("Bob")) # Output: Hello, Bob!
---

🔹 3. Return Statement

- The return statement is used to return a value from a function.
- If no return statement is used, the function returns None.

Example:

def square(x):
return x * x

print(square(4)) # Output: 16
---

🔹 4. Scope and Lifetime of Variables

- Variables defined inside a function are local to that function.
- Global variables can be accessed anywhere in the program.

Example:

def local_example():
local_var = "I am local"
print(local_var)

global_var = "I am global"

def global_example():
print(global_var)

local_example() # Output: I am local
global_example() # Output: I am global
---

🔹 Practice Exercises:

1. Define and Call a Function:

# Define a function to calculate the area of a rectangle
def area_of_rectangle(length, width):
return length * width

# Call the function
print(area_of_rectangle(5, 3)) # Output: 15
2. Function with Default Parameters:

# Define a function with default parameter
def greet(name="Guest"):
return f"Hello, {name}!"

# Call the function with and without an argument
print(greet()) # Output: Hello, Guest!
print(greet("Eve")) # Output: Hello, Eve!
3. Using Return Statement:

# Define a function to calculate the factorial of a number
def factorial(n):
result = 1
for i in range(1, n + 1):
result *= i
return result

# Call the function
print(factorial(5)) # Output: 120
4. Understanding Scope:

# Define a function to demonstrate local and global variables
def scope_example():
local_var = "I am local"
print(local_var)
print(global_var)

global_var = "I am global"
scope_example()
# Output:
# I am local
# I am global
---

🔹 Exercise:

Create a program that:
- Defines a function is_even that takes a number as an argument and returns True if the number is even, False otherwise.
- Uses this function to print all even numbers from 1 to 20.

def is_even(number):
return number % 2 == 0

for i in range(1, 21):
if is_even(i):
print(i)
---

Master these concepts to effectively use functions in Python! 🚀💪

---


---

📚 Lesson 3: Control Flow 📚

Class 2: Loops

---

🔹 1. Introduction to Loops

- Loops allow you to execute a block of code multiple times.
- Useful for iterating over sequences (e.g., lists, strings) or repeating tasks until a condition is met.

---

🔹 2. The for Loop

- The for loop iterates over a sequence (e.g., list, string, range) and executes a block of code for each item in the sequence.

Syntax:

for item in sequence:
# Code to execute
Example:

# Iterating over a list
fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
print(fruit)

# Iterating over a string
for char in "hello":
print(char)
Using range():

- The range() function generates a sequence of numbers.
- Commonly used with for loops.

# Iterating over a range of numbers
for i in range(5):
print(i)
---

🔹 3. The while Loop

- The while loop executes a block of code as long as a condition is True.

Syntax:

while condition:
# Code to execute
Example:

# Counting down from 5 to 1
count = 5
while count > 0:
print(count)
count -= 1
---

🔹 4. Controlling Loop Execution

break Statement:

- Exits the loop immediately when encountered.

for i in range(10):
if i == 5:
break
print(i)
continue Statement:

- Skips the current iteration and moves to the next iteration.

for i in range(10):
if i % 2 == 0:
continue
print(i)
---

🔹 Practice Exercises:

1. Using for Loop:
# Print each letter in the word "Python"
for letter in "Python":
print(letter)
2. Using while Loop:
# Print numbers from 1 to 5
num = 1
while num


Video oldindan ko‘rish uchun mavjud emas
Telegram'da ko‘rish


Video oldindan ko‘rish uchun mavjud emas
Telegram'da ko‘rish
Practice with help of video


---

📚 Lesson 3: Control Flow 📚

Class 1: Conditional Statements

---

🔹 1. Introduction to Control Flow

- Control flow statements allow you to control the execution of code based on conditions or loops.
- They are essential for making decisions and repeating actions in a program.

---

🔹 2. Conditional Statements

if Statement:

- The if statement evaluates a condition and executes the indented code block if the condition is True.

age = 18
if age >= 18:
print("You are an adult.")
else Statement:

- The else statement follows an if statement and runs if the condition in the if statement is False.

age = 16
if age >= 18:
print("You are an adult.")
else:
print("You are not an adult.")
elif Statement:

- The elif (short for "else if") statement allows you to check multiple conditions sequentially.

age = 20
if age < 13:
print("You are a child.")
elif age < 18:
print("You are a teenager.")
else:
print("You are an adult.")
---

🔹 3. Nested Conditional Statements

- Conditional statements can be nested inside one another to handle more complex decision-making.

age = 25
if age > 0:
if age < 18:
print("You are a minor.")
else:
print("You are an adult.")
else:
print("Invalid age.")
---

🔹 4. Logical Operators in Conditions

- You can use logical operators (and, or, not) to combine multiple conditions.

age = 30
has_id = True

if age >= 18 and has_id:
print("You can enter.")
else:
print("You cannot enter.")
---

🔹 Practice Exercises:

1. Simple Conditionals:

temperature = 30

if temperature > 25:
print("It's hot outside.")
else:
print("It's not hot outside.")
2. Multiple Conditions:

score = 85

if score >= 90:
print("Grade: A")
elif score >= 80:
print("Grade: B")
elif score >= 70:
print("Grade: C")
elif score >= 60:
print("Grade: D")
else:
print("Grade: F")
3. Nested Conditionals:

username = "admin"
password = "1234"

if username == "admin":
if password == "1234":
print("Access granted.")
else:
print("Incorrect password.")
else:
print("Incorrect username.")
4. Using Logical Operators:

is_raining = False
has_umbrella = True

if not is_raining or has_umbrella:
print("You can go outside.")
else:
print("You should stay inside.")
---

🔹 Exercise:

Create a program that:
- Asks the user for their age and whether they have a driving license.
- Prints whether they are allowed to drive based on their age and possession of a driving license.

# Ask the user for their age
age = int(input("Enter your age: "))

# Ask if they have a driving license
has_license = input("Do you have a driving license? (yes/no): ").lower() == "yes"

# Determine if they can drive
if age >= 18 and has_license:
print("You are allowed to drive.")
else:
print("You are not allowed to drive.")
---

Practice these concepts to master control flow in Python! 🚀💪

---


---

Python (ESH):
---

📚 Lesson 2: Basic Data Types and Variables 📚

Class 2: Basic Operations and Type Conversion

---

🔹 1. Arithmetic Operations

Addition (+):
a = 5
b = 3
result = a + b
print(result) # Output: 8
Subtraction (-):
a = 10
b = 4
result = a - b
print(result) # Output: 6
Multiplication (*):
a = 7
b = 6
result = a * b
print(result) # Output: 42
Division (/):
a = 20
b = 5
result = a / b
print(result) # Output: 4.0
Modulus (%):
a = 13
b = 5
result = a % b
print(result) # Output: 3
Exponentiation ():**
a = 2
b = 3
result = a ** b
print(result) # Output: 8
Integer Division (//):
a = 15
b = 4
result = a // b
print(result) # Output: 3
---

🔹 2. String Operations

Concatenation:
first_name = "John"
last_name = "Doe"
full_name = first_name + " " + last_name
print(full_name) # Output: John Doe
String Length:
message = "Hello, World!"
length = len(message)
print(length) # Output: 13
String Slicing:
greeting = "Hello, World!"
part = greeting[0:5]
print(part) # Output: Hello
String Methods:
message = " Hello, World! "
print(message.lower()) # Output: hello, world!
print(message.upper()) # Output: HELLO, WORLD!
print(message.strip()) # Output: Hello, World!
---

🔹 3. Boolean Operations

Logical AND:
a = True
b = False
result = a and b
print(result) # Output: False
Logical OR:
a = True
b = False
result = a or b
print(result) # Output: True
Logical NOT:
a = True
result = not a
print(result) # Output: False
Comparison Operators:
a = 10
b = 5
print(a == b) # Output: False
print(a != b) # Output: True
print(a > b) # Output: True
print(a < b) # Output: False
print(a >= b) # Output: True
print(a




# Ask the user for their age
user_age = int(input("Enter your age: "))

# Calculate birth year
current_year = 2024 # Update with the current year
birth_year = current_year - user_age

# Get user's name
user_name = input("Enter your name: ")

# Personalized greeting
greeting_message = f"Hello, {user_name}! You are {user_age} years old and were born in {birth_year}."

# Display the message
print(greeting_message)


---

Python Practice 🐍

1. Declaring Variables:

# Integer variable
age = 25

# Float variable
pi = 3.14159

# String variable
name = "John Doe"

# Boolean variables
is_student = True
is_teacher = False
2. Arithmetic Operations:

# Addition
sum_result = 10 + 5

# Subtraction
difference = 20 - 8

# Multiplication
product = 6 * 4

# Division
quotient = 15 / 3

# Modulus (remainder)
remainder = 17 % 4

# Exponentiation
squared = 5 ** 2
3. String Operations:

# Concatenation
greeting = "Hello, " + name + "!"

# String length
name_length = len(name)

# String slicing
first_name = name[:4] # Extracts "John"

# String methods
uppercase_name = name.upper()
4. Boolean Operations:

# Boolean AND
both_true = is_student and is_teacher

# Boolean OR
either_true = is_student or is_teacher

# Boolean NOT
not_teacher = not is_teacher
5. Type Conversion and Handling Type Error:

# Integer to String
num_string = str(123)

# Float to Integer
float_num = 3.5
int_num = int(float_num)

# Handling Type Error
user_input = input("Enter a number: ")
try:
user_number = int(user_input)
print("You entered:", user_number)
except ValueError:
print("Invalid input. Please enter a valid number.")
---

Exercise:

Create a program that:
- Asks the user for their age.
- Calculates their birth year using arithmetic.
- Displays a message with their name, age, birth year, and a personalized greeting.

Practice these concepts to strengthen your Python skills! 💪🏼🚀

---


----

Lesson 1: Introduction to Python

Class 2: Basic Data Types and Variables

---

1. Variables and Data Types

Variables:
- Definition: Variables are used to store data values in Python.
- Declaration: How to declare variables using the assignment operator (=).
- Variable Naming Rules: Start with a letter or underscore, case-sensitive, cannot be a keyword.

Data Types:
1. Integers (int): Whole numbers without decimals.
2. Floats (float): Numbers with decimals or in exponential form.
3. Strings (str): Ordered sequence of characters, enclosed in single or double quotes.
4. Booleans (bool): Represents True or False values.

2. Basic Operations

Arithmetic Operations:
- Addition (+), subtraction (-), multiplication (*), division (/), modulus (%), exponentiation (**).
- Integer Division (//): Returns the integer part of the division result.

String Operations:
- Concatenation: Combining strings using the + operator.
- String Methods: len(), lower(), upper(), strip(), etc.
- Indexing and Slicing: Accessing characters or substrings in a string.

Boolean Operations:
- Logical Operators: and, or, not.
- Comparison Operators: == (equal), != (not equal), < (less than), > (greater than), etc.

3. Variable Naming and Conventions

Variable Naming Rules:
- Should be descriptive and meaningful.
- Use lowercase with underscores for readability (e.g., my_variable).
- Avoid using reserved keywords as variable names.

Python's Naming Conventions (PEP 8):
- Follow PEP 8 guidelines for naming variables, functions, and classes.
- Consistent and readable code enhances maintainability.

4. Type Conversion

Type Casting:
- Converting between data types using built-in functions (int(), float(), str()).
- Automatic Type Conversion: Python dynamically converts data types as needed.

5. Practice Exercises

- Write code snippets and small programs to practice:
- Declaring variables of different data types.
- Performing arithmetic, string, and boolean operations.
- Converting between data types and handling type errors.

---


---

📱 Using Pydroid 3 for Python Programming on Your Smartphone 📱

---

🔹 What is Pydroid 3?
- Pydroid 3 is a Python 3 IDE for Android.
- Allows you to write, run, and debug Python code directly on your smartphone.

---

🔹 Installing Pydroid 3:
1. Open the Google Play Store on your Android device.
2. Search for "Pydroid 3" or use [this link](https://play.google.com/store/apps/details?id=ru.iiec.pydroid3).
3. Tap "Install" and wait for the installation to complete.

---

🔹 Setting Up and Using Pydroid 3:

1. Open Pydroid 3:
- After installation, open the app from your app drawer.

2. Writing Your First Python Program:
- Tap the code editor area.
- Type the following code:

print("Hello, World!")

3. Running Your Code:
- Tap the "Run" button (▶️) at the bottom of the screen.
- Your output will appear in the console below the code editor.

4. Using the Python Shell (REPL):
- Tap the "Terminal" icon (⚙️) at the bottom.
- You can type Python commands interactively here.
- For example, type print("Hello from REPL!") and press enter.

5. Saving Your Work:
- Tap the menu icon (☰) in the top-left corner.
- Select "Save" or "Save As" to save your file with a .py extension.

---

🔹 Additional Features:

1. Installing Libraries:
- Tap the "Terminal" icon.
- Use pip to install libraries. For example, pip install numpy.

2. Project Management:
- Organize your files into projects using the file manager in Pydroid 3.

3. Code Completion and Suggestions:
- Pydroid 3 offers basic code completion and suggestions to help you write code faster.

---

🔹 Practice:
1. Install Pydroid 3 on your smartphone.
2. Write and run your first Python program: print("Hello, World!").
3. Experiment with using the REPL for interactive coding.

---

Pydroid 3 is a powerful tool that brings Python programming to your fingertips, making it easy to learn and code on the go!

---


---

📚 Lesson 1: Introduction to Python 📚

Class 1: Introduction to Programming

---

🔹 1. Introduction to Programming

What is Programming?
- Programming is the process of writing instructions for a computer to perform specific tasks.
- Programs are written in programming languages, which are designed to be understood by both humans and machines.

Why Learn Programming?
- Develop problem-solving skills.
- Automate repetitive tasks.
- Create software, websites, and applications.
- Programming is a valuable skill in many careers.

---

🔹 2. Introduction to Python

What is Python?
- Python is a high-level, interpreted programming language.
- Known for its simplicity and readability, making it ideal for beginners.

Why Python?
- Easy to learn and use.
- Extensive libraries and frameworks.
- Versatile: used in web development, data analysis, AI, scientific computing, etc.
- Large and supportive community.

---

🔹 3. Setting Up Python

Installing Python:

Windows:
1. Download the Python installer from the [official Python website](https://www.python.org/).
2. Run the installer and follow the instructions. Make sure to check the box that says "Add Python to PATH."

macOS:
1. macOS comes with Python 2.x pre-installed. To install Python 3, use Homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install python

Linux:
1. Use your distribution's package manager:

sudo apt-get update
sudo apt-get install python3

Using Pydroid (for Android users):
1. Download Pydroid 3 from the [Google Play Store](https://play.google.com/store/apps/details?id=ru.iiec.pydroid3).
2. Open the app and you can start writing and running Python code directly on your phone.

Setting Up an IDE:

IDLE:
- Comes bundled with Python. Simple to use for beginners.

VS Code:
1. Download and install from [Visual Studio Code website](https://code.visualstudio.com/).
2. Install the Python extension for better support.

PyCharm:
1. Download and install from the [JetBrains website](https://www.jetbrains.com/pycharm/).

---

🔹 4. Basic Syntax and Structure

Writing Your First Python Program:
1. Open your IDE, text editor, or Pydroid app.
2. Type the following code:

print("Hello, World!")

3. Save the file with a .py extension (e.g., hello.py).
4. Run the script:
- Command Line: Navigate to the file location and run python hello.py.
- Pydroid: Tap the "Run" button in the app.

Understanding the Python Shell:
- The Python shell is an interactive mode where you can execute Python code line by line.
- To open the Python shell, type python in your command line or terminal.
- In Pydroid, you can use the REPL (Read-Eval-Print Loop) feature for interactive coding.

Running a Python Script:
- Write your Python code in a .py file.
- Run the file from the command line using python filename.py.
- In Pydroid, save your file and tap the "Run" button.

---

Practice:
1. Install Python or Pydroid on your device.
2. Write and run your first Python program: print("Hello, World!").

---
https://t.me/pythonESH

17 ta oxirgi post ko‘rsatilgan.

104

obunachilar
Kanal statistikasi