0% found this document useful (0 votes)
20 views7 pages

Summary Python M. Ciise

The document discusses Python programming concepts including data types, variables, functions, classes, inheritance, modules and code examples. It covers key Python topics like strings, lists, tuples, dictionaries, loops, functions, OOP concepts of classes, objects, methods, attributes, inheritance, encapsulation and polymorphism.

Uploaded by

zuhaybmaxamed9
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)
20 views7 pages

Summary Python M. Ciise

The document discusses Python programming concepts including data types, variables, functions, classes, inheritance, modules and code examples. It covers key Python topics like strings, lists, tuples, dictionaries, loops, functions, OOP concepts of classes, objects, methods, attributes, inheritance, encapsulation and polymorphism.

Uploaded by

zuhaybmaxamed9
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
You are on page 1/ 7

python

What is Python? Python is a popular programming language. It was created by Guido


van Rossum, and released in 1991

2. What can Python do


1.Python can be used on a server to create web applications.
2.Python can be used alongside software to create workflows.
3.Python can connect to database systems. It can also read and modify files.
4.Python can be used to handle big data and perform complex mathematics.

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.

4:How to write comments?


1.Comments are lines that exist in computer programs that are ignored by
compilers and interpreters. Including comments in programs makes code
more readable for humans as it provides some information.
Comment Syntax #
# This is a comment

5.Understanding Data Types?


1. data types are used to classify one particular type of data

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.

11:How To Convert Data Types


When programming, there are times we need to convert values between types in order
to manipulate values in a different way.

12: Update List


The list is mutable. You can add new items in the list using the append() or insert()
methods, and update items using indexes.
13.Python Variables
In Python, a variable is a container that stores a value. In other words, variable is the
name given to a value, so that it becomes easy to refer a value later on.

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

17:Python For Loops


for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a
set, or a string).

18:python while 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.

22:Passing a List as an Argument


You can send any data types of argument to a function (string, number, list, dictionary
etc.), and it will be treated as the same data type inside the function.

23:Python Lambda
lambda function is a small anonymous function.

24: Why Use Lambda Functions


1.The power of lambda is better shown when you use them as an anonymous function
inside another function.
2.Say you have a function definition that takes one argument, and that argument
will be multiplied with an unknown number.

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

2:Objects:instances: of classes that encapsulate data and behavior. They are


created using the class as a template and can have unique values for their attributes.

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.

7:Polymorphism: Refers to the ability of different classes to be treated as objects of a


common superclass. It allows for flexibility in using different classes through a unified
interference

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

11:modules: In Python, a module is a file containing Python definitions, statements,


functions, and classes. It serves as a way to organize Python code, making it reusable
and maintainable. Modules help to structure programs into logical components.

Codes
#List
courses= ['python','java' , 'css','Oracle']

print(courses) print(courses[3])

#we will print Oracle using index or i

#Dictionary
Student=

{'Name':'Hodo','Age':'20','department':'HRM'}

print(Student) print(Student.keys()) #print all the keys

print(Student.values()) #print all the values

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

while num < 5:

num = num + 1

print('num = ', num)

BY MOHAMED CIIZE

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy