- Easy to Learn
- Less coding
- Easy to read
- Libraries
- Listen and Watch
- Take notes
- practice
- Share
Integers (int) => 1,2,3 Floating Point (Float) => 2.3 , 2.8 .100.1 Strings (str) => 'Hello' , "Hello"
Lists (list) ordered => [1 , 'Hi' , 4.2] Dictionaries (dict) unordered => {'key' : 'value'} => {'Name' : 'Mohamed'} Sets (set) unordered { 'A' , 'B' , 'C' } Tuples (Tuple) immutable(غير قابل للتغيير ) => (1 , 'Hi' , 4.2) Booleans (bool) => True , False
+=> Addition -=> Subtraction / => Division % => Moduls ** => Exponent // => Floor Division [[Python/Number Calculations/Data_types numbers.py at main · mohamedmahmoud26/Python]]
It tells Python "the next character is not regular text" — it has a special meaning.
%% ''Hallo, Mohamed Elseragy %%
No special characters here, so you can just print it normally:
print("%% ''Hallo, Mohamed Elseragy %%")
%% ''Hallo, Mohamed Elseragy %%
==%% " " " %%==
Since you're using double quotes " " inside the string, you must escape them using \":
print("==%% \" \" \" %%==")
Output:
==%% " " " %%==
Or use single quotes ' ' around the whole string and keep double quotes inside:
print('==%% " " " %%==')
print(\"\"\")
This will cause a SyntaxError — because Python thinks you're starting a triple-quoted string, but you never closed i
- Single quotes (' ')= Double quotes(" ")
- ( \n ) => New Line
- ( \t ) => Such as(Enter Tab)
- len => Count This variable.
-
Indexing means accessing a specific character in a string using its position (index).
-
Indexing starts from 0 on the left (forward indexing),
and from -1 on the right (backward indexing).
-
Slicing means cutting a string into parts by selecting a range of characters using their indexes.
-
Syntax:
string[start:end:step]
- The
.upper()method is used to convert all characters in a string to uppercase (capital letters).
- The
.lower()method is used to convert all characters in a string to lowercase (small letters).
- The
.split()method is used to break a string into a list of words, based on a separator (default is space). Python/String at main · mohamedmahmoud26/Python
String formatting is the process of inserting variables or values into a string in a structured and readable way.
-
To create readable and dynamic messages
-
To control the format of numbers (like decimals or comma separators)
-
To keep code clean and professional
-
%s→ string -
%d→ integer -
%f→ float (e.g.%.2f= 2 decimal places)
print("My name is {} and I am {} years old.".format("Sergio", 22))
Advanced formatting:
print("Pi is approximately {:.2f}".format(3.14159))
You can:
-
Rearrange:
"Name: {1} {0}".format("Last", "First") -
Use named placeholders:
"{name}".format(name="Sergio")
name = "Mohamed Mahmoud" age = 22 print(f"My name is {name} and I am {age} years old.")`
You can format directly:
pi = 3.14159 print(f"Pi to 2 decimals: {pi:.2f}")
Python/Formating at main · mohamedmahmoud26/Python