الاسبوع الثالث
الاسبوع الثالث
الاسبوع الثالث
بهذا الملف رح, احنا حكينا عنه قبل هيك ب االسابع الي فاتتstring موضوع ال
ناخذ اشياء جديدة
1-Multiline Strings:
You can assign a multiline string to a variable by using
three quotes (triple quotes)
Example:
2- Escape Character
: ً بنستخدمهم في البايثون المطلوب منا حالياEscape character في عنا اكثر من
2.1-new line = = \n
2.2-Tab = = \t
Example:
عن طريق الaccess element انه بقدر اعملlist نفس ما اخذنا ب موضوع ال
index
index 0 1 2 3 4 5 6 7 8 9 10 11
4-Extended Slicing.
The slice syntax is a handy way to refer to sub-parts of
sequences – typically strings and lists. The slice s[start: end] is
the elements beginning at start and extending up to but not
including end but s[start:end:step] will essentially work as a
step value
Example:
نشرح المثال وركزو معاي فيه
عندي جملة python is cool
-قبل ما افكر اعمل شي بشوف هو من وين بدو يبلش ووين بده ينتهي وبسجلهم على
جنب بالمثال هذا بده يبلش من االول لالخر و رح يشمل اخر index
ويمشي خطوتين
-رح يطبع ال p = p
ويتخطى عن ال yبيوصل لل tوبيطبعها = t
بيرجع مرة ثانية بيتخطى عن ال hوبيطبع ال o = o
بيرجع يتخطى ال nوبيطبع ال space = space
يتخطى ال iوبطبع s = s
بيرجع يتخطى spaceوبيطبع c = c
بيتخطى ال oوبيطبع oالثانية = o
واخر شي بتخطى عن اخر o & lوبوقف النه مافي اشي يطبعه
-Strings are immutable
strings are immutable, that is you cannot change one once
you make it:
Example:
"str="python
str [1] =1
print(str) = error
-String function:
-len () : The len function takes as an argument a string and
returns an integer, the length of a string.
Example:
my_str = 'Hello World'
len(my_str) ⇒ 11
length of a string محسوب في الspace ال-
-string methods:
-Python has a set of built-in methods that you can use on
strings.
-Note: All string methods returns new values. They do not
change the original string.
Methods:
Method Description
endswith() Returns true if the string ends with the specified value
index() Searches the string for a specified value and returns the position
of where it was found
isalpha() Returns True if all characters in the string are in the alphabet
islower() Returns True if all characters in the string are lower case
isupper() Returns True if all characters in the string are upper case
partition() Returns a tuple where the string is parted into three parts
rindex() Searches the string for a specified value and returns the last
position of where it was found
rpartition() Returns a tuple where the string is parted into three parts
rsplit() Splits the string at the specified separator, and returns a list
split() Splits the string at the specified separator, and returns a list
startswith() Returns true if the string starts with the specified value
swapcase() Swaps cases, lower case becomes upper case and vice versa
title() Converts the first character of each word to upper case
-String Format
int & string احنا بنعرف في البايثون انه ما بنقدر نجمع بين
Example:
-You can use index numbers {index} to be sure the arguments are
placed in the correct placeholders:
-Formatting Types
Inside the placeholders you can add a formatting type to format
the result:
:b Binary format
:d Decimal format
:g General format
:n Number format
:% Percentage format
.الحمد هلل الذي يقدرنا على فعل كل شيء ويوفقنا بفضله وكرمه إلى ما ينفع الناس