programming languages
The programming languages supported by Raspberry Pi are all the languages supported by Linux, such as Python, Pascal, Java, and many other languages. We will use the python language in this course to program the GPIO control ports for the features that are available in this language over other languages which we will list when introducing Python language.
2. PROGRAMMING LANGUAGES
• The programming languages supported by Raspberry Pi are all
the languages supported by Linux, such as Python, Pascal, Java,
and many other languages. We will use the python language in
this course to program the GPIO control ports for the features
that are available in this language over other languages which we
will list when introducing Python language.
5. PYTHON
• Python is one of the languages High-level and advanced programming.
This language is characterized by its simplicity in writing and
reading, easy to learn and open source which made it scalable.
• Python can be used for various stages of programming from Through
programming simple programs for beginners and reaching the
completion of huge projects like any other programming language.
6. PYTHON
• Why did we choose Python to program Control ports?
Because of the advantages that this language has over other
languages. Perhaps the most important characteristic of it is
the ease of learning this language and it is a free and open
source language.
7. PYTHON
• Python Characteristics
o Open source: You can freely read and edit the source code In which.
o Easy to learn: due to the simplicity of writing and reading this language.
o Practical: Works on all operating systems and their different versions
o Code Libraries: There are a large number of software libraries available Supported by this
language.
o Support: Supported by the programming community in the World Wide Web Significantly.
o GPIO: Supports programming of control ports on the Raspberry Pi
14. BASIC PYTHON OPERATIONS
• Comments
• And to make a specific comment in your program what
you need Except tick the box (#) followed by the
comment you want.
• Example:
# Show the following text on screen
print "Hello Raspberry Pi
15. BASIC PYTHON OPERATIONS
• Comments
• It is possible to benefit from the process of ignoring the translator
For comments invalidate a specific line of code.
• Example
# Show the following text
# on screen
print "Hello"
# print "HelloWorld"
print "Raspberry Pi"
16. BASIC PYTHON OPERATIONS
• Calculations
• Python has the advantage of its ability to do operations
Arithmetic such as: addition, subtraction, multiplication, and
division Without prior definition of variables. Can do So with
the following command.
Number*Number
• Example: 5*5
17. BASIC PYTHON OPERATIONS
• Calculations
• It is also possible to link between the printing process and the
calculations, for example
Number*Number
• Example: print "The result of addition 5+5 is ", 10
18. BASIC PYTHON OPERATIONS
• Variables
• The variables are defined by typing the variable name Followed
by its value between the sign equals and this is done through
the following command:
Var=Value
• Example 1:x=5
19. BASIC PYTHON OPERATIONS
• Variables
• Example 2:
Raspberry = 50
pi = 50
print " Raspberry + Pi =" , Raspberry + pi
print "Raspberry - Pi =", Raspberry - pi
20. BASIC PYTHON OPERATIONS
• Variable type
• To find out the type of the variable we write the word type followed
byWith the variable in parentheses
Type(Var_Name)
• Example:
type(x)
21. BASIC PYTHON OPERATIONS
• if statement
if expression :
Statement(s)
Example:
pi=50
raspberry =50
if pi == raspberry:
print "Hello Raspberry
25. BASIC PYTHON OPERATIONS
• while loop
Example:
count=1
while (count<10) :
print "The number of letters of raspberry" , count
count= count + 1
26. BASIC PYTHON OPERATIONS
• List
• It is a list that contains a number of values, The value is
specified with a quotation mark and between Each value is
a comma and all values are in between Square brackets
28. BASIC PYTHON OPERATIONS
• List
• Example:
list_Num=[ 1 , 2 , 3 , 4 , 5 ]
list_Lett=[ "R", "a", "s", "p","b", "e","r","r","y"]
list_Mix=[1,2 , "a", "b"]
print " List_Num in position 2 is ", list_Num[2]
print " list_Lett in position 0 is ", list_Lett [0]
print " list_Mix in position 3 is ", list_Mix [3]
29. BASIC PYTHON OPERATIONS
• for loop
for iterating_var in sequence:
Statement(s)
• Example:
list_Num=[ 1 , 2 , 3 , 4 , 5 ]
list_Lett=[ "R", "a", "s", "p", "b", "e","r","r","y"]
list_Mix=[1,2 , "a", "b"]
print " List_Num in position 2 is ", list_Num[2]
print " list_Lett in position 0 is ", list_Lett [0]
print " list_Mix in position 3 is ", list_Mix [3]
30. BASIC PYTHON OPERATIONS
• for loop
• Example:
List_Lett=[ "R", "a", "s", "p", "b", "e","r","r","y"]
for letter in list_ Lett:
print "letters of raspberry pi", letter