#Python #Py #py #python
Variables: Variables are one kind of a bag or store room that only stores something from your given input or given text or anything.
Assign: The thing you want to store on a variable should be assigned by a assign mark ( = ), remember you are in coding world, so here equal and assign mark are different, equal mark is ( ==) and assign mark is ( = )
Example:
Noted: Here I assigned "Rohim" text on the "name" variable, variables must be without double quote but any text should be inside double quote
Variables: Variables are one kind of a bag or store room that only stores something from your given input or given text or anything.
Assign: The thing you want to store on a variable should be assigned by a assign mark ( = ), remember you are in coding world, so here equal and assign mark are different, equal mark is ( ==) and assign mark is ( = )
Example:
name = "Rohim"Noted: Here I assigned "Rohim" text on the "name" variable, variables must be without double quote but any text should be inside double quote
โค2
#html #HTML #htm
HTML is nothing just a text formating language and its only useful to create a normal webpage interface and also helpful for texts style formats like bold, underline, italic, monospace, deleted etc. Html usage is only the tags which can immersive your text with different styles.
Web Example:
This is a small website make example, just a basic take idea from this
HTML is nothing just a text formating language and its only useful to create a normal webpage interface and also helpful for texts style formats like bold, underline, italic, monospace, deleted etc. Html usage is only the tags which can immersive your text with different styles.
Web Example:
<!DOCTYPE html>
<html>
<head>
<title>Your Page Title</title>
</head>
<body>
<HERE OTHER TAGS WITH USE>
</body>
</html>This is a small website make example, just a basic take idea from this
#php #serverside #dynamic #PHP
Php is a language mainly for server-side operations i mean for websites mainly, but you also can use that on terminal too. Php has a tag to start with and end with, inside that tag the code will be executed if calls.
Basics:
Noted: On PHP, to print a output on your site or terminal, the keyword is "echo". And here you have to declare the variables same as python but only add the "$" sign before and then assign it with its value and print it. And the starting and closing tags used in example which is mandatory for php. Tags should be inside "< >" marks
Php is a language mainly for server-side operations i mean for websites mainly, but you also can use that on terminal too. Php has a tag to start with and end with, inside that tag the code will be executed if calls.
Basics:
<?php
$name = "John";
echo $name;
?>Noted: On PHP, to print a output on your site or terminal, the keyword is "echo". And here you have to declare the variables same as python but only add the "$" sign before and then assign it with its value and print it. And the starting and closing tags used in example which is mandatory for php. Tags should be inside "< >" marks
#Python #Py #py #python
Simple Maths that can be helpful for you in different operations in any python scripts. And you can see the output by direct use these examples given below.
Addition:
Output: 8
Subtraction:
Output: 8
Multiplication:
Output: 8
Division:
Output: 8.0
Integer Division:
Output: 8
Mod:
Output: 2
Power:
Output: 8
Simple Maths that can be helpful for you in different operations in any python scripts. And you can see the output by direct use these examples given below.
Addition:
result = 5 + 3
print(result)Output: 8
Subtraction:
result = 10 - 2
print(result)Output: 8
Multiplication:
result = 4 * 2
print(result)Output: 8
Division:
result = 16 / 2
print(result)Output: 8.0
Integer Division:
result = 16 // 2
print(result)Output: 8
Mod:
result = 17 % 3
print(result)Output: 2
Power:
result = 2 ** 3
print(result)Output: 8
#html #HTML #htm
Let's learn some HTML tags for use in website, another scripts, telegram bots for make your text much cool and good.
Bold:
Italic:
Monospace:
Underline:
Paragraph/Normal:
Heading:
Group:
Image:
Some Common Tags for website:
Noted: These tags are useful in your webpages and telegram bots as well as on more scripts. Remember to use the tag short name inside "< >" and must be use a opening tag inside "< >" and closing tag where includes extra slash(/) inside the tag like this "</ >".
Let's learn some HTML tags for use in website, another scripts, telegram bots for make your text much cool and good.
Bold:
<b>Here Your Text</b>Italic:
<i>Here Your Text</i>Monospace:
<code>Here Your Text</code>Underline:
<u>Here Your Text</u>Paragraph/Normal:
<p>Here Your Text</p>Heading:
<h1>Here Your Text</h1>Group:
<div>Here Your Element</div>Image:
<img src=[IMAGE_PATH]>Some Common Tags for website:
<html> </html><title> </title><head> </head><body> </body>Noted: These tags are useful in your webpages and telegram bots as well as on more scripts. Remember to use the tag short name inside "< >" and must be use a opening tag inside "< >" and closing tag where includes extra slash(/) inside the tag like this "</ >".
#Python #Py #py #python
๐ด What is Python?
Python is a popular and versatile programming language. It's known for its simplicity, readability, and ease of use, which makes it a great choice for beginners and experienced programmers alike. Python can be used for a wide variety of tasks, such as web development, data analysis, scientific computing, automation, artificial intelligence, and more.
๐ด How to install Python?
To use python programming language, you need to install the Python interpreter on your operating system.
For windows: You can download Python from the official website https://www.python.org/downloads/
For VPS: You can install by command:
Open a text editor on your computer. You can use Notepad (Windows), TextEdit (macOS), or any code editor you prefer (e.g., Visual Studio Code, Sublime Text). Write the following code:
๐ด How to run the code?
Open a terminal or command prompt. Go to the folder where you saved your hello.py file. Run the program by typing:
๐ด What is Python?
Python is a popular and versatile programming language. It's known for its simplicity, readability, and ease of use, which makes it a great choice for beginners and experienced programmers alike. Python can be used for a wide variety of tasks, such as web development, data analysis, scientific computing, automation, artificial intelligence, and more.
๐ด How to install Python?
To use python programming language, you need to install the Python interpreter on your operating system.
For windows: You can download Python from the official website https://www.python.org/downloads/
For VPS: You can install by command:
apt install python3 && apt install python3-pip
For Termux: You can install by command: pkg install python3
๐ด How to make python code?Open a text editor on your computer. You can use Notepad (Windows), TextEdit (macOS), or any code editor you prefer (e.g., Visual Studio Code, Sublime Text). Write the following code:
print("Hello, World!")
Save the file with a .py extension, for example, hello.py.๐ด How to run the code?
Open a terminal or command prompt. Go to the folder where you saved your hello.py file. Run the program by typing:
python hello.pyYou should see the output: Hello, World!
โค1
๐ด PYTHON BASICS KNOWLEDGE
Python has a simple and readable syntax. Here are some basic concepts you should start learning:
Variables: Used to store data. Example: name = "John"
Data Types: Python has various data types, including integers, floats, strings, lists, dictionaries, and more.
Control Structures: Learn about if statements for conditional execution and loops like for and while for repetition.
Functions: Functions allow you to group code into reusable blocks. You can define your own functions and use built-in functions.
Lists and Dictionaries: These are data structures used to store collections of values.
Classes: These are updated form of functions. There would be 2 or more functions defined in a class for use the individual functions in future through the class
Python has a simple and readable syntax. Here are some basic concepts you should start learning:
Variables: Used to store data. Example: name = "John"
Data Types: Python has various data types, including integers, floats, strings, lists, dictionaries, and more.
Control Structures: Learn about if statements for conditional execution and loops like for and while for repetition.
Functions: Functions allow you to group code into reusable blocks. You can define your own functions and use built-in functions.
Lists and Dictionaries: These are data structures used to store collections of values.
Classes: These are updated form of functions. There would be 2 or more functions defined in a class for use the individual functions in future through the class
๐ด Variables and Data Types
name = "Alice" #Data Type: String
age = 25 #Data Type: Integer
height = 5.7 #Data Type: Float
is_student = True #Data Type: Boolean
print(name)
print(age)
print(height)
print(is_student)
All Default Data Types used in Pythonโ
Numeric Types:
int: Integer type, e.g., 5, -10
float: Floating type, e.g., 3.14, -0.25
complex: Complex number type, e.g., 2 + 3j
Sequence Types:
str: String type, e.g., "Hello, World!"
list: List type, e.g., [1, 2, 3]
tuple: Tuple type, e.g., (1, 2, 3)
Mapping Type:
dict: Dictionary type, e.g., {'key': 'value'}
Set Types:
set: Unordered set type, e.g., {1, 2, 3}
frozenset: Immutable set type, e.g., frozenset([1, 2, 3])
Boolean Type:
bool: Boolean type, either True or False
NoneType:
None: Represents the absence of a value or a null value
Binary Types:
bytes: Immutable sequence of bytes, e.g., b'hello'
bytearray: Mutable sequence of bytes, e.g., bytearray([65, 66, 67])
memoryview: Provides a view on memory buffers
name = "Alice" #Data Type: String
age = 25 #Data Type: Integer
height = 5.7 #Data Type: Float
is_student = True #Data Type: Boolean
print(name)
print(age)
print(height)
print(is_student)
All Default Data Types used in Pythonโ
Numeric Types:
int: Integer type, e.g., 5, -10
float: Floating type, e.g., 3.14, -0.25
complex: Complex number type, e.g., 2 + 3j
Sequence Types:
str: String type, e.g., "Hello, World!"
list: List type, e.g., [1, 2, 3]
tuple: Tuple type, e.g., (1, 2, 3)
Mapping Type:
dict: Dictionary type, e.g., {'key': 'value'}
Set Types:
set: Unordered set type, e.g., {1, 2, 3}
frozenset: Immutable set type, e.g., frozenset([1, 2, 3])
Boolean Type:
bool: Boolean type, either True or False
NoneType:
None: Represents the absence of a value or a null value
Binary Types:
bytes: Immutable sequence of bytes, e.g., b'hello'
bytearray: Mutable sequence of bytes, e.g., bytearray([65, 66, 67])
memoryview: Provides a view on memory buffers
๐ด Conditional Statements (if, else, and elif)
Conditional statements allow you to control the flow of your program based on certain conditions. They help you make decisions and execute different blocks of code depending on whether conditions are met.
If Statement:
The if statement allows you to execute a block of code if a certain condition is true. Example:
The if-else statement lets you execute one block of code if a condition is true and another block if the condition is false.
The if-elif-else statement allows you to check multiple conditions in sequence.
๐ด Operators
Equal (==):
Checks if two values are equal.
Checks if two values are not equal.
Checks if the left value is greater than the right value.
Checks if the left value is less than the right value.
Checks if the left value is greater than or equal to the right value.
Checks if the left value is less than or equal to the right value.
These operators can be used in various combinations within conditional statements to create complex conditions:
Conditional statements allow you to control the flow of your program based on certain conditions. They help you make decisions and execute different blocks of code depending on whether conditions are met.
If Statement:
The if statement allows you to execute a block of code if a certain condition is true. Example:
age = 18If-else Statement:
if age >= 18:
print("You are an adult.")
The if-else statement lets you execute one block of code if a condition is true and another block if the condition is false.
age = 15
if age >= 18:
print("You are an adult.")
else:
print("You are a minor.")
If-elif-else Statement:The if-elif-else statement allows you to check multiple conditions in sequence.
score = 85
if score >= 90:
print("You got an A.")
elif score >= 80:
print("You got a B.")
elif score >= 70:
print("You got a C.")
else:
print("You need to improve.")
In this example, only one block of code will be executed. Once a condition is met, the rest of the elif and else blocks are skipped.๐ด Operators
Equal (==):
Checks if two values are equal.
x = 5Not Equal (!=):
y = 5
if x == y:
print("x and y are equal.")
Checks if two values are not equal.
x = 5Greater Than (>):
y = 10
if x != y:
print("x and y are not equal.")
Checks if the left value is greater than the right value.
x = 10Less Than (<):
y = 5
if x > y:
print("x is greater than y.")
Checks if the left value is less than the right value.
x = 5Greater Than or Equal To (>=):
y = 10
if x < y:
print("x is less than y.")
Checks if the left value is greater than or equal to the right value.
x = 10Less Than or Equal To (<=):
y = 10
if x >= y:
print("x is greater than or equal to y.")
Checks if the left value is less than or equal to the right value.
x = 5
y = 10
if x <= y:
print("x is less than or equal to y.")
๐ด Operators with combination Usage Examples:These operators can be used in various combinations within conditional statements to create complex conditions:
x = 7Additionally, these operators can also be used in conjunction with elif clauses within an if-elif-else statement:
y = 12
if x > 5 and y < 15:
print("Both conditions are satisfied.")
if x > 10 or y > 20:
print("At least one condition is satisfied.")
if not (x > 10):
print("The condition is not satisfied.")
age = 25
if age < 18:
print("You are a minor.")
elif age >= 18 and age < 60:
print("You are an adult.")
else:
print("You are a senior citizen.")๐ด Lists and Dictionaries
Lists and dictionaries are powerful data structures in Python. Example:
#Lists
In Python, indexing refers to the process of accessing individual elements within a data structure, such as a list, tuple, or string, using their position or index. The index is a numerical value that represents the position of the element within the data structure. Python uses zero-based indexing, which means that the index of the first element is 0, the index of the second element is 1, and so on.
Lists:
Lists are ordered collections of elements, and you can access elements using their index positions.
Tuples are similar to lists, but they are immutable (cannot be changed after creation).
Strings are sequences of characters, and you can access individual characters using their indices.
Negative indexing can also be used to count positions from the end of the sequence. For example, -1 refers to the last element, -2 refers to the second-to-last element, and so on.
Lists and dictionaries are powerful data structures in Python. Example:
#Lists
fruits = ["apple", "banana", "orange"]#Dictionaries
print(fruits[0]) # Accessing elements by index
fruits.append("grape") # Adding an element
print(len(fruits)) # Finding the length of the list
person = {"name": "Alice", "age": 30, "city": "New York"}
print(person["name"]) # Accessing values by key
person["job"] = "engineer" # Adding a key-value pair
๐ด Index In PythonIn Python, indexing refers to the process of accessing individual elements within a data structure, such as a list, tuple, or string, using their position or index. The index is a numerical value that represents the position of the element within the data structure. Python uses zero-based indexing, which means that the index of the first element is 0, the index of the second element is 1, and so on.
Lists:
Lists are ordered collections of elements, and you can access elements using their index positions.
my_list = [10, 20, 30, 40, 50]Tuples:
print(my_list[0]) # Output: 10
print(my_list[2]) # Output: 30
Tuples are similar to lists, but they are immutable (cannot be changed after creation).
my_tuple = (5, 15, 25, 35)Strings:
print(my_tuple[1]) # Output: 15
Strings are sequences of characters, and you can access individual characters using their indices.
my_string = "Hello, world!"Negative Index:
print(my_string[7]) # Output: "w"
Negative indexing can also be used to count positions from the end of the sequence. For example, -1 refers to the last element, -2 refers to the second-to-last element, and so on.
my_list = [10, 20, 30, 40, 50]
print(my_list[-1]) # Output: 50 (last element)
print(my_list[-2]) # Output: 40 (second-to-last element)๐ด Methods in Python
append() Method:
The append() method is used to add a single element to the end of a list.
The extend() method is used to append elements from another iterable (like a list or tuple) to the end of the list.
The insert() method is used to add an element at a specific index in the list. The syntax is list.insert(index, element).
The remove() method is used to remove the first occurrence of a specified element from the list.
The pop() method is used to remove and return an element from a specific index. If no index is provided, it removes and returns the last element.
The index() method is used to find the index of the first occurrence of a specified element.
append() Method:
The append() method is used to add a single element to the end of a list.
my_list = [1, 2, 3]extend() Method:
my_list.append(4)
print(my_list) # Output: [1, 2, 3, 4]
The extend() method is used to append elements from another iterable (like a list or tuple) to the end of the list.
my_list = [1, 2, 3]insert() Method:
my_list.extend([4, 5, 6])
print(my_list) # Output: [1, 2, 3, 4, 5, 6]
The insert() method is used to add an element at a specific index in the list. The syntax is list.insert(index, element).
my_list = [1, 2, 3]remove() Method:
my_list.insert(1, 5) # Insert 5 at index 1
print(my_list) # Output: [1, 5, 2, 3]
The remove() method is used to remove the first occurrence of a specified element from the list.
my_list = [1, 2, 3, 2]pop() Method:
my_list.remove(2) # Removes the first occurrence of 2
print(my_list) # Output: [1, 3, 2]
The pop() method is used to remove and return an element from a specific index. If no index is provided, it removes and returns the last element.
my_list = [10, 20, 30, 40]index() Method:
popped_element = my_list.pop(1) # Removes and returns element at index 1 (20)
print(my_list) # Output: [10, 30, 40]
print(popped_element) # Output: 20
The index() method is used to find the index of the first occurrence of a specified element.
my_list = [10, 20, 30, 20, 40]
index_of_20 = my_list.index(20) # Finds the index of the first occurrence of 20
print(index_of_20) # Output: 1๐ด Loops
Loops are a fundamental programming concept used to execute a block of code repeatedly. They allow you to automate repetitive tasks, iterate over collections of data, and perform various computations efficiently. Python provides two main types of loops: for loops and while loops.
For Loops:
A for loop is used to iterate over a sequence (such as a list, tuple, string, or range) and execute a block of code for each item in the sequence.
While Loops:
A while loop is used to repeatedly execute a block of code as long as a certain condition is true.
Loop Control Statements:
Python provides loop control statements to modify the behavior of loops:
break: Terminates the loop prematurely.
continue: Skips the rest of the current iteration and moves to the next one.
else clause: Used with for and while loops. The code in the else block executes when the loop completes normally (i.e., without encountering a break statement).
Here's an example of using the break statement to exit a loop:
You can also nest loops within each other to perform more complex tasks. Just be careful with the indentation to maintain clarity.
Loops are a fundamental programming concept used to execute a block of code repeatedly. They allow you to automate repetitive tasks, iterate over collections of data, and perform various computations efficiently. Python provides two main types of loops: for loops and while loops.
For Loops:
A for loop is used to iterate over a sequence (such as a list, tuple, string, or range) and execute a block of code for each item in the sequence.
for item in sequence:Here's an example using a for loop to print numbers from 1 to 5:
print("Hi")
for num in range(1, 6):In this example, the range(1, 6) generates a sequence of numbers from 1 to 5 (inclusive). The loop iterates over each number in the sequence and prints it.
print(num)
While Loops:
A while loop is used to repeatedly execute a block of code as long as a certain condition is true.
while condition:Here's an example using a while loop to print numbers from 1 to 5:
print("Hi")
num = 1In this example, the loop runs as long as the condition num <= 5 is true. The variable num starts at 1 and increments by 1 in each iteration until it reaches 6, at which point the loop terminates.
while num <= 5:
print(num)
num += 1
Loop Control Statements:
Python provides loop control statements to modify the behavior of loops:
break: Terminates the loop prematurely.
continue: Skips the rest of the current iteration and moves to the next one.
else clause: Used with for and while loops. The code in the else block executes when the loop completes normally (i.e., without encountering a break statement).
Here's an example of using the break statement to exit a loop:
for num in range(1, 11):Nested Loops:
if num == 5:
break # Exit the loop when num is 5
print(num)
You can also nest loops within each other to perform more complex tasks. Just be careful with the indentation to maintain clarity.
for i in range(3):This nested loop will print combinations of i and j for each value of i from 0 to 2 and each value of j from 0 to 1.
for j in range(2):
print(i, j)
โค1
๐ด All Types of Operators in Python
Python supports a variety of operators for performing different types of operations on values and variables. Here's an overview of the main types of operators in Python:
1. Arithmetic Operators:
These operators are used for mathematical calculations.
+: Addition
-: Subtraction
*: Multiplication
/: Division
//: Floor Division (division that rounds down to the nearest whole number)
%: Modulus (remainder after division)
**: Exponentiation (raising a number to a power)
2. Assignment Operators:
These operators are used to assign values to variables.
=: Assigns a value to a variable
+=: Adds the right operand to the left operand and assigns the result to the left operand
-=: Subtracts the right operand from the left operand and assigns the result to the left operand
*=: Multiplies the left operand by the right operand and assigns the result to the left operand
/=: Divides the left operand by the right operand and assigns the result to the left operand
//=: Performs floor division and assigns the result to the left operand
%=: Computes the modulus and assigns the result to the left operand
**=: Raises the left operand to the power of the right operand and assigns the result to the left operand
3. Comparison Operators:
These operators are used to compare values.
==: Equal to
!=: Not equal to
<: Less than
>: Greater than
<=: Less than or equal to
>=: Greater than or equal to
4. Logical Operators:
These operators are used to perform logical operations.
and: Logical AND (returns True if both operands are True)
or: Logical OR (returns True if at least one operand is True)
not: Logical NOT (returns the opposite of the operand's truth value)
5. Membership Operators:
These operators are used to test whether a value is a member of a sequence.
in: Returns True if a value is found in the sequence
not in: Returns True if a value is not found in the sequence
6. Identity Operators:
These operators are used to compare the memory locations of two objects.
is: Returns True if both operands refer to the same object
is not: Returns True if both operands do not refer to the same object
7. Bitwise Operators:
These operators are used to perform bitwise operations on integers.
&: Bitwise AND
|: Bitwise OR
^: Bitwise XOR (exclusive OR)
~: Bitwise NOT
<<: Left shift
>>: Right shift
Python supports a variety of operators for performing different types of operations on values and variables. Here's an overview of the main types of operators in Python:
1. Arithmetic Operators:
These operators are used for mathematical calculations.
+: Addition
-: Subtraction
*: Multiplication
/: Division
//: Floor Division (division that rounds down to the nearest whole number)
%: Modulus (remainder after division)
**: Exponentiation (raising a number to a power)
2. Assignment Operators:
These operators are used to assign values to variables.
=: Assigns a value to a variable
+=: Adds the right operand to the left operand and assigns the result to the left operand
-=: Subtracts the right operand from the left operand and assigns the result to the left operand
*=: Multiplies the left operand by the right operand and assigns the result to the left operand
/=: Divides the left operand by the right operand and assigns the result to the left operand
//=: Performs floor division and assigns the result to the left operand
%=: Computes the modulus and assigns the result to the left operand
**=: Raises the left operand to the power of the right operand and assigns the result to the left operand
3. Comparison Operators:
These operators are used to compare values.
==: Equal to
!=: Not equal to
<: Less than
>: Greater than
<=: Less than or equal to
>=: Greater than or equal to
4. Logical Operators:
These operators are used to perform logical operations.
and: Logical AND (returns True if both operands are True)
or: Logical OR (returns True if at least one operand is True)
not: Logical NOT (returns the opposite of the operand's truth value)
5. Membership Operators:
These operators are used to test whether a value is a member of a sequence.
in: Returns True if a value is found in the sequence
not in: Returns True if a value is not found in the sequence
6. Identity Operators:
These operators are used to compare the memory locations of two objects.
is: Returns True if both operands refer to the same object
is not: Returns True if both operands do not refer to the same object
7. Bitwise Operators:
These operators are used to perform bitwise operations on integers.
&: Bitwise AND
|: Bitwise OR
^: Bitwise XOR (exclusive OR)
~: Bitwise NOT
<<: Left shift
>>: Right shift
LXML INSTALLATION PROCESS IN TERMUX:
First clear data your termux.
Then open termux and command these sequently:
It will be installed ๐ฅฐ๐
First clear data your termux.
Then open termux and command these sequently:
apt update && apt upgradepkg install python libxml2 libxslt pkg-configpip install cython wheelCFLAGS="-Wno-error=incompatible-function-pointer-types -O0" pip install lxmlIt will be installed ๐ฅฐ๐