0% found this document useful (0 votes)
8 views3 pages

Python

The document outlines variable types in programming, including String, Integer, Float, and Boolean, along with type casting methods. It describes data structures like Lists, Sets, Tuples, and Dictionaries, as well as logical operations and control flow statements. Additionally, it covers object-oriented programming concepts such as classes, objects, methods, attributes, and special methods for various functionalities.

Uploaded by

riadhussein980
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Python

The document outlines variable types in programming, including String, Integer, Float, and Boolean, along with type casting methods. It describes data structures like Lists, Sets, Tuples, and Dictionaries, as well as logical operations and control flow statements. Additionally, it covers object-oriented programming concepts such as classes, objects, methods, attributes, and special methods for various functionalities.

Uploaded by

riadhussein980
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Variable = (1) Value (String, Integer, Float, Boolean)

✓ “Str” = Text (always with “comma”)


✓ Int = Whole Number (always without “comma” & parts 0)
✓ Float = Number with parts (0.0)
✓ Boolean = True or False

Type casting
• Int [Text > Number]
• Float [Text > Number 0.0]
• Str [Number > Text]
• Classes & Objects

If you want add multi value in single variable:


o List = […] ordered & changeable. Duplicates Ok
o Set = {…} unordered & immutable, but Add - Remove Ok. No duplicates
o Tuple = (…) ordered & un changeable. Duplicates Ok. Faster
Dict. = {‘a’:1, ‘b’:2, ‘c’:3}

Logical operations
• or = at last one condition must be True
• and = both conditions must be true
• not = inverts the condition (not False, not True)

If statement
Variable = value
for value in variable

• Class ‫الصنف‬
• Objects (instant):
o A1 = A (“x”, “y”, “z”)
o A2 = A (“x”, “y”, “z”)
• Methods: def method name (self)
o Instance methods
▪ Accessor (Getters) ‫الوصول الى سمات الكائن بدون تعديلها‬
▪ Mutator (Setters) ‫تعديل سمات الكائن‬
▪ Utility ‫اجراء عمليات منطقية او وظيفية على السمات‬
o Class methods (Decorator) only one type (@classmethod)
o Special methods
o Static methods (Decorator) only one type (@staticmethod)
• Attributes: ‫السمات – ممكن تعطى للكائن او للفئة او لكليهما‬
o Self. X = X
o Self. Y = Y
• Constructor: is a special type of method use to initialize an object.
o Default: def __init__ (self):
▪ Object = details
o Parameter: def __init__ (self, Parameter, Parameter)
▪ Object = details (Parameter, Parameter)
Special methods
1. Initializing & deletion
• __init__ ( self )
• __del__ ( self )
2. Representation
• __str__ ( self )
• __repr__ ( self )
3. Comparison
• __eq, ne, it, le, gt, ge __ ( self, other )
4. Arithmetic operations
• __ add, sub, mul, truediv, floordiv, mod, pow __ ( self, other )
5. Type conversion
• __ int, float, bool __ ( self )
6. Container & sequence behavior
• __ len__ ( self )
• __ getitem __ (self, key )
• __ setitem __ (self, key, value )
• __ delitem __ (self, key)
• __ iter __ (self )
• __ next __ (self )
7. Callable objects
• __ call __ ( self, … )
8. Attribute Access
• __ getattr __ (self, name )
• __ setattr __ ( self, name, value )
• __ delatter __ ( self, name )
• __ dir __ ( self )
9. Context management
• __enter __ ( self )
• __ exit __ ( self, exc_type, exc_value, traceback)
10. Miscellaneous ‫أُخرى‬
• __hash __ (self )
• __ contains __ ( self, item )

You might also like