Summary Python M. Ciise
Summary Python M. Ciise
3.Why Python
1.Python works on different platforms (Windows, Mac, Linux,
Raspberry Pi, etc).
2.Python has a simple syntax similar to the English language. 3.Python has syntax that
allows developers to write programs with fewer lines than some other programming
languages.
4.Python runs on an interpreter system, meaning that code can be executed as soon as
it is written. This means that prototyping can be very quick.
5.Python can be treated in a procedural way, an object-oriented way or a functional
way.
2. This is important because the specific data type you use will determine what values
you can assign to it and what you can do to it (including what operations you can
perform.
6. BOOLEANS
1.The Boolean data type can be one of two values, either True or
False.
2.Booleans are used to represent the truth values that are associated with the logic
branch of mathematics, which informs algorithms in computer science.
3.The values True and False will also always be with a capital T and F respectively, as
they are special values in Python.
7:STRINGS?
A string is a sequence of one or more characters (letters, numbers, symbols) that can
be either a constant or a variable.
8:LISTS?
A list is a mutable, or changeable, ordered sequence of elements
9:TUPLES?
A tuple is used for grouping data. It is an immutable, or unchangeable, ordered
sequence
10: Dictionaries?
dictionaries is Python’s built-in mapping type. This means that dictionaries map keys
to values and these key-value pairs are a useful way to store data in Python.
14:Local Scope
A variable created inside a function belongs to the local scope of that function, and
can only be used inside that function.
15:Global Scope
A variable created in the main body of the Python code is a global variable and
belongs to the global scope
16:Python Loops
Python has two primitive loop commands:
1.while loops
2.for loops
With the while loop we can execute a set of statements as long as a condition is true.
19:Nested Loops
nested loop is a loop inside a loop
20:Python Functions
A function is a block of code which only runs when it is called.
21: Arguments
1.Information can be passed into functions as arguments.
2.Arguments are specified after the function name, inside the parentheses. You can add
as many arguments as you want, just separate them with a comma.
23:Python Lambda
lambda function is a small anonymous function.
25:Python Inheritance
1.Parent class is the class being inherited from, also called base class.
2.Child class is the class that inherits from another class, also called derived.
26:Python Iterators
iterator is an object that contains a countable number of values.
OOP IN PYTHON (SUMMARY)
1:Classes: These are blueprints or templates for creating objects. They define properties
(attributes) and behaviors (methods) that the objects will
3.Attributes: These are variables within a class that hold data. Attributes represent the
state of an object and can be accessed and modified using dot notation.
4:Methods: Functions defined within a class that perform actions or operations on the
object's data. They encapsulate behavior and can modify object attributes
5.Inheritance : The ability of a class to inherit properties and behaviors from another
class. It allows for code reusability and the creation of more specialized classes (child
classes) based on existing ones (parent classes).
6:Encapsulation: The principle of bundling the data (attributes) and the methods that
operate on the data within a single unit (class). It restricts access to certain components,
promoting data integrity and security.
8:The init: method: in Python is a special method, also known as the constructor. It is
automatically called when a new instance of a class is created. Its purpose is to initialize
the object's attributes or perform any setup required before the object is used.
9:The self parameter: refers to the instance of the class itself and is used to access and
assign instance variables within the class. It's a convention in Python to use self as the
first parameter in instance methods to refer to the object itself.
10:Super function: In Python, the super() function is used to access and call methods
from a parent class in inheritance hierarchies. It's commonly used in object-oriented
programming to invoke methods from the superclass (or parent class) within the
subclass
Codes
#List
courses= ['python','java' , 'css','Oracle']
print(courses) print(courses[3])
#Dictionary
Student=
{'Name':'Hodo','Age':'20','department':'HRM'}
functions
def mycountry(country="somaliland"):
print("i am from" + country )
Oops
class ICT:
name=”muuse”
age=30
student=ICT( )
print(student.name, student.age)
#Loops
while loop:
i=1
while i < 6:
print(i)
i += 1
for loop:
num =0
num = num + 1
BY MOHAMED CIIZE