[go: up one dir, main page]

0% found this document useful (0 votes)
6 views15 pages

Lecture 1 (1)

The document is an introductory lecture on Python programming for first-year Civil Engineering students at Al-Azhar University. It covers the basics of programming, the functionality of Python, its common data types, syntax rules, and the differences between compilers and interpreters. Additionally, it provides guidance on Python installation and Integrated Development Environments (IDEs) suitable for programming in Python.

Uploaded by

abdoelraheman28
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)
6 views15 pages

Lecture 1 (1)

The document is an introductory lecture on Python programming for first-year Civil Engineering students at Al-Azhar University. It covers the basics of programming, the functionality of Python, its common data types, syntax rules, and the differences between compilers and interpreters. Additionally, it provides guidance on Python installation and Integrated Development Environments (IDEs) suitable for programming in Python.

Uploaded by

abdoelraheman28
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/ 15

Lecture:1

Introduction to Python programming language

Lectures Notes
For 1St year, Civil Engineering, Faculty of Engineering, Al-Azhar University
By, Dr. Eid F. Latif, PhD, Public Work Departement
 What is programming?
 Programming refers to a technological process for telling a computer which
tasks to perform in order to solve problems. You can think of programming as a
collaboration between humans and computers, in which humans create
instructions for a computer to follow (code) in a language computers can
understand.
 How does computer programming work?
 At its most basic, programming tells a computer what to do. First, a
programmer writes code—a set of letters, numbers, and other characters. Next,
a compiler converts each line of code into a language a computer can
understand. Then, the computer scans the code and executes it, thereby
performing a task or series of tasks. Tasks might include displaying an image
on a webpage or changing the font of a section of text.
 Machine language is the language understood by a computer. It is very difficult
to understand, but it is the only thing that the computer can work with. All
programs and programming languages eventually generate or run programs in
machine language.
, Python
 Most used programming's languages among developers
worldwide as of 2023
 What you can do with these programming languages?
 JavaScript
This language is used on every major web browser. JavaScript allows you
to add complex features to a web page, such as content updates, interactive
maps, and animated graphics, develop games, and more.
 HTML/CSS
These languages are used to create web pages and web applications. You
would use HTML (HyperText Markup Language) to build web page
structure, while CSS (Cascading Style Sheets) would enable you to
determine the page’s styling.
 Python
Python programming is most used in machine learning, web development,
and desktop applications. Python is a popular language among beginners,
as the syntax is relatively easy to learn. It is known as an object-oriented
programming language.
What is Python?
● Python is a popular high-level programming
language used in various applications
○ Python is an easy language to learn because of its
simple syntax
○ Python can be used for simple tasks such as plotting or
for more complex tasks like machine learning
Common Data Types and Operators
● A data type is a means of classifying a value and determining what
operations can be performed on it. All objects have a data type.
● Operators are symbols used carry out specific functions/computations.

1 < 2 is True, 0==1 is false


e.g. 732 or -5
e.g. 3.14 or 2.0
[5, “ahmed”, 5.0]
(5, “ahmed”, 5.0)
‘hello’ or ‘C’ ‘’ “”
Generated from list

{“1”:”ahmed”, “country”:”Egypt” }
Basic Syntax Rules
● The name of your variable (myInt etc.) is placed on the left of the “=“ operator.

○ Most variable names are in camel case where the first word begins with a lowercase
letter and any subsequent words are capitalized
○ Variable names may also appear in snake case where all words are lowercase, with
underscores between words
● The assignment operator (“=“) sets the variable name equal to the memory location where
your value is found.
● The value of your variable (“Hello, World”) is placed on the right of the “=“ operator.
○ The type of this value does NOT need to be stated but its format must abide by a given
object type (as shown).

myString = “Hello, World”


myInt = 7
myFloat = 7.0
myList = [7, 8, 9]
myBoolean = true
Binary Operations
Op Meaning Example Remarks

+ Addition 9+2 is 11
9.1+2.0 is 11.1
- Subtraction 9-2 is 7
9.1-2.0 is 7.1
* Multiplication 9*2 is 18
9.1*2.0 is 18.2
/ Division 9/2 is 4.25 In Python3
9.1/2.0 is 4.55 Real div.
// Integer Division 9//2 is 4
% Remainder 9%2 is 1
The Programming Cycle for Python

Run
with some input

Write/Edit
OK?
NO
YES

YES
NO More
Inputs?
 Which Python Version/IDE ( Integrated Development Environment) to use?

 (IDE) is a software application that provides comprehensive facilities for


software development. An IDE normally consists of at least a source-code
editor, build automation tools, and a debugger. Some IDEs, contain the
necessary compiler, interpreter or both
 You can use pycharm
(https://www.jetbrains.com/pycharm/download/?section=windows) or
visual studio code (https://code.visualstudio.com/)
 You can use the latest pycharm only if you have a 64 bit windows or mac
system. For 32 bit systems download an older version
 You can use any other text editor you are comfortable with, you do not
have to use pycharm or visual studio code
 You can use python version 3.X
 Check this link https://www.python.org/downloads/windows/ for
downloading specific python version for windows, as the latest version
doesn’t work for windows 7
 For windows 7 you can download version 3.8.6, for 32bit and for 64bit
 If you are having a problem installing a text editor or python itself, you can
use an online interpreter such as repl.it (https://repl.it/languages/python3)
What is the difference between text editor compiler and interpreter?

The compiler derives its name from the way it works, as looking at the entire piece of
source code and collecting and reorganizing the instructions. It translates high-level
instructions directly into machine language. Compiled programs generally run faster.
The machine code which typically stored in a file is also referred as binary code and
can be directly executed by the machine after linking. Examples of compiled
programming languages are C, C++, C#, Objective-C, SWIFT, and Fortran.

In contrast, an interpreter directly executes instructions written in a programming or


scripting language without previously converting them to an object code or machine
code. That means you write the program using a text editor, and then instruct the
interpreter to run the program. It takes the program one line at a time and translates
each line before executing it. It translates the first line and runs it and then the second
line so on. Examples of interpreted languages are Python, Ruby, PHP, JAVA, R,
Powershell and Matlab.
Both compilers and interpreters covert source code which refers text files into machine
language. Both may generate immediate instructions. But between these translators,
there has some technical and processing difference.
Python installation
PyCharm installation
visual studio code installation

https://www.youtube.com/watch?v=SMyzYOP
GeD8&list=PLuXY3ddo_8nzrO74UeZQVZOb5
-wIS6krJ&index=4
https://www.youtube.com/watch?v=WTRKeSo
ynKI&list=PLuXY3ddo_8nzrO74UeZQVZOb5-
wIS6krJ&index=3
Editor area

Console area (in visual studio code is called Terminal)

You might also like