ADEL AHMED ALHAJJ
Reference
ADEL AHMED ALHAJJ
Introduction to Python
Python is a simple, high-level, object-oriented, general-purpose programming
language.
Python is a versatile language used for many purposes. This means that you can
use Python in various fields, including:
- Web applications
- Big data applications
- Automation
- Data science, machine learning, and artificial intelligence
- Desktop software
- Mobile applications
3
Introduction to Python
Advantages of Python for Developers
It has enormous popularity and there are plenty of references and resources
available.
It is simple and very easy to learn compared to other programming languages.
If you create a program using Python, it runs on any operating system (cross-
platform).
Nowadays, it is considered one of the most in-demand languages in the job
market. In other words, if you want to enter the workforce, Python offers you
many opportunities.
It is one of the most important languages used by professionals in the fields of
information security and ethical hacking.
4
Introduction to Python
Back End
Flask
Django
GUI
QT
Tkinter
Kivy
Networking
Socket
Data Analysis
Pandas
Numpy
5
How to Install Python ( Environment Set-up )
Installation on Windows
Visit the link [Link] to download the latest release of
Python.
In this process, we will install Python 3.11.1 on our Windows operating system. When
we click on the above link, it will bring us the following page.
6
How to Install Python ( Environment Set-up )
7
How to Install Python ( Environment Set-up )
How to verify that Python has been installed successfully
To check whether the Python interpreter has been installed and to see its version
number, open the Command Prompt (CMD) and type the following command inside it:
8
How to Install Python ( Environment Set-up )
Get Started with PyCharm
PyCharm is an integrated development environment (IDE) used for computer
programming, especially for programming in Python, as it was designed specifically for
the Python language and all its frameworks, such as Django and others.
It differs greatly from other programming environments because it was developed
specifically for Python programmers. It was produced and developed by the Czech
company JetBrains, which is a well-known company in developing many IDEs, which
demonstrates the strength of this environment for its users.
9
How to Install Python ( Environment Set-up )
Get Started with PyCharm
Downloading PyCharm is very important for any
programmer working with Python, because it
provides an ideal working environment that enables
the programmer to accomplish their tasks in this
easy and wonderful programming language.
The software comes with excellent, high-quality
specifications that cover the programmer's needs,
and it also comes with all the necessary tools. It
automatically calls all the files and libraries related
to the language and makes it easier for the
programmer to search for them.
10
How to Install Python ( Environment Set-up )
Get Started with PyCharm
11
First Programming
12
First Programming >> print ( )
13
Comments
Comments
Comments are hints that we add to our code to make it easier to understand.
Python comments start with #. For example,
ADEL AHMED ALHAJJ
# print a number
# print a number
print(25)
print(25)
# print adel
print(“adel”)
14
Comments
Multiline Comments
However, we can achieve the same effect by using the hash (#)
symbol at the beginning of each line.
ADEL AHMED ALHAJJ
# This is an example of a multiline comment
# created using multiple single-line commenced
# The code prints the text Hello World
print("Hello, World!")
15
Comments
Multiline Comments
We can also use multiline strings as comments like:
ADEL AHMED ALHAJJ
16
Python Variables
A variable is a name of memory location. It is used to store data. Its value
can be changed and it can be reused many times.
ADEL AHMED ALHAJJ
Name Variable = Value
variables allow you to store and work with data in the computer’s memory.
Part of the job of programming is to determine how many variables a program
will need and what types of information they will hold.
This is called a variable definition It tells the compiler the variable’s name
and the type of data it will hold
17
Python Variables
Rules for Naming Variables
To use variables effectively, we must follow Python’s naming rules:
ADEL AHMED ALHAJJ
If you want to create a variable name having two words, use
underscore to separate them. For example: my_name
variable name cannot start with a digit.
Variable names are case-sensitive (myVar and myvar are different).
Avoid using Python keywords (e.g., if, else, for) as variable names.
18
Python Variables
Rules for Defining Variables
Variable names must consist of a single word with no spaces.
Variable names must consist only of letters, numbers, and underscores (_).
Variable names should not start with a number.
19
Python Variables
Some Notes and Naming Conventions
It is common practice when naming variables to start the variable name with a
lowercase letter, and to use underscores to separate words. Starting with a
capital letter is also acceptable.
20
Python Data Type
ADEL AHMED ALHAJJ
21
Python Data Type
Data Types in Python
In Python, data types are divided into 7 fundamental types:
Numbers: Numeric values (integers, floats, complex numbers).
Strings: Text data.
Booleans: Logical values (True or False).
Lists: Arrays with no fixed size (mutable and ordered).
Tuples: Arrays with fixed size and values that are immutable (unchangeable).
Sets: Arrays with no fixed size, where values cannot be deleted, but new
values can be added (unordered and unique).
Dictionaries: Tables that store data in the form of keys and values (key-value
pairs).
22
Python Data Type
Data Types in Python
Numbers: Numeric values (integers, floats, complex numbers).
مثال إستخدامها النوع
x = 3 يستخدم لتخزين أعداد صحيحة. int
x = 1.5 يستخدم لتخزين أعداد تحتوي على فاصلة عشرية. float
يستخدم لتخزين أعداد مركبة Complex Numberو التي غالباً ما يحتاجها
المهندسون عند إجراء عمليات حاسبيه معقدة.
x = 4J complex
ّ
مفسر مالحظة :هنا يجب وضع الحرف Jأو jمباشر ًة بعد العدد حتى يعرف
بايثون أنك تقصد عدد مركب و ليس عدد عادي.
23
Python Variables
In Python, we don't need to specify the type of variable because Python is a infer
language and smart enough to get variable type.
Variable names can be a group of both the letters and digits, but they have to
begin with a letter or an underscore ( _ ) .
It is recommended to use lowercase letters for the variable name. R and r both are
two different variables.
d = 10
q = “ ali ”
24
Python Variables
ADEL AHMED ALHAJJ
25
Python Variables
ADEL AHMED ALHAJJ
26
Python Variables
27
Python Variables
Changing Variable Values
In Python, you can change the value of a variable at any time by simply assigning a
new value to it using the assignment operator (=). Variables in Python are
dynamically typed, meaning you can even change the data type of a variable by
assigning a value of a different type.
x = 76
x = 76 print(x)
x = “adel"
print(x) x = “adel"
print(x)
28
Python Variables
Assigning the Same Value
Python allows assigning the same value to multiple variables in a
single line, which can be useful for initializing variables with the
same value.
x = y = z = 10
print(x)
print(y)
print(z)
29
Python Variables
Assigning Different Values
We can assign different values to multiple variables simultaneously,
making the code concise and easier to read
j, k, l = “ali", 2.05, 15
print(j)
print(k)
print(l)
30
Python Variables
we have created a string object. Let's check the type of it using the Python built-in
type() function.
31
Python Variables
32
Python Data Type
Data Types in Python – Strings
To define a string in Python, we use the single quote ('), double quotes ("),
or triple quotes (''' or “ “ ").
Is there a difference between these symbols?
For the single quote (') and double quotes ("):
There is no difference between them. You can use either one to define a
string that consists of a single line.
For triple single quotes (''') and triple double quotes (“ “ "):
There is no difference between them either. You can use either one to
define a large string that consists of multiple lines.
33
Python Data Type
34