Computer Programming
PYTHON
Done By: Thana Abdulhalim
01
Python Syntax
Spaces Variables Comments
Python
Indentation
● Indentation refers to the spaces at the
beginning of a code line.
● Where in other programming
languages the indentation in code is
for readability only, the indentation in
Python is very important.
● Python uses indentation to indicate a
block of code.
Error Example
Python Variables
● In Python, variables are
created when you assign a
value to it
● Python has no command
for declaring a variable.
Example
Comments
● Python has commenting
capability for the purpose
of in-code
documentation.
● Comments start with a #,
and Python will render
the rest of the line as a
comment
Example
01
Practice Time !
Spaces Variables Comments
8 Minutes
● Create a name variable
01 ● Create an age variable
● Print name variable
● Check age variable , if
02 it’s less than 18 print “
you are under age “, else
print the age .
● Create a comment to
03 explain the code
02
Python Variables
Names Multiple output global
Variables
How to use variables in python
Example
Variable Names
A variable can have a short name (like x and y) or a
more descriptive name (age, carname, total_volume).
Rules for Python variables:
● A variable name must start with a letter or the
underscore character
● A variable name cannot start with a number
● A variable name can only contain alpha-numeric
characters and underscores (A-z, 0-9, and _ )
● Variable names are case-sensitive (age, Age and
AGE are three different variables)
● A variable name cannot be any of the Python
keywords.
Example
Multi Words
Variable Names
● Variable names with more than one
word can be difficult to read.
● There are several techniques you can
use to make them more readable.
Example
Many Values to
Multiple Variables
● Python allows you to
assign values to multiple
variables in one line
● Make sure the number of
variables matches the
number of values, or else
you will get an error.
● And you can assign
the same value to multiple
variables in one line
Example
Output Variables
● The print() function is often
used to output variables.
● The best way to output
multiple variables in the
print() function is to separate
them with commas, which
even support different data
types.
Example
Example
02
Practice Time !
variables
10 Minutes
● Create 3 int variables x, y,
01 z, assign 6, 7, 8, to them
● Print the power of each
number inside print() .
● Create variables name ,
02 id , major then assign
any values to them
● Get the type of them.
● Print the variables in the
03 same line .
● Make sure to define the
names in python standard
03
Python Data Types
Numbers Strings Booleans
Built-in Data Types
● In programming, data type is
an important concept.
● Variables can store data of
different types, and different
types can do different things.
● Python has the following data
types built-in by default, in
these categories
Example
03
Practice Time !
Data Types
6 Minutes
01 ● Create one variable for
each type
02 ● Print the variables
● Get the variables type
Weekly Problem
Given two integer number ,
return their multiple only if the
multiple is equal to or lower
than 500 . Otherwise, return
their sum.
Quiz Time
01 02
03 04
Q.01
Explain the Indentation
system
Q.02
How to print 2 different typed
variables in the same line
Q.03
Name 3 of python unique
data types
Q.04
What are python variables
rules
Thanks!
Do you have any questions?
CREDITS: This presentation
template was created by Slidesgo,
including icons by Flaticon, and
infographics & images by Freepik