Python
Python
PROGRAMMING LANGUAGE
YAZAN
OBJECTIVES OF THIS
WEEK’S CLASS
Python Strings. *
Python Booleans.
Python Operators.
Python Lists. *
Python Tuple. *
Python Sets. *
Python Dictionaries. *
Python If … else . *
Python Loops. *
INSTALLING VIRTUAL STUDIO CODE
IDE
Open
Visual Studio Code
OR
programiz python compiler
WRITE YOUR FIRST CODE
print(“ICT Class”);
print(94);
WRITE YOUR FIRST CODE
• Note: print(“Ahmad”) is the same as print(‘Ahmad’)
print(“ICT Class”);
print(‘ICT Class’);
COMMENTS
COMMENTS
• Comments are made to explain the code.
• To write a comment in Python add # before the beginning of
the line.
Print(94);
Open
= Apple
= Ahmed
VARIABLES
• To create a variable in Python
X = “Hamad”
Z = 4
VARIABLES
• To create a variable in Python
X = “Hamad”
print(X);
Output?
VARIABLES
• To create a variable in Python
Z = 4
print(X);
Output?
VARIABLES
• Open Python Compiler:
Example:
X = “Adam”
print(X)
;
VARIABLES
• Make math calculations
print(1 + 1) print(1 * 1)
Output? 2 Output? 1
print(1 - 1) print(1 / 1)
Output? 0 Output? 1
VARIABLES
• Make math calculations
X = 1; X = 1; X = 1; X = 1;
Y = 1; Y = 1; Y = 1; Y = 1;
X =“Ahmad”; DO NOT
FORGET THE
Y = “Mohammad”; DOUBLE
QUOTATIONS
print(X) FOR AHMAD
AND
Output? Ahmad MOHAMMAD
print(Y)
Output? Mohammad
OBJECTIVES & OVERVIEW
Python Strings. *
Python Booleans.
Python Operators.
Python Lists. *
Python Tuple. *
Python Sets. *
Python Dictionaries. *
Python If … else . *
Python Loops. *
OBJECTIVES OF THIS
WEEK’S CLASS
X = “Ahmad”;
Y = 12;
X = 1;
Y = 12;
print( X + Y)
Output? 13
VARIABLES
• Combine two variables together
X = “Ahmad”;
Y = 12;
print( X + Y)
Output? ERROR
VARIABLES
X = “Ahmad”;
Y = 12;
print( X , Y)
Output? Ahmad 12
VARIABLES
cont.
OBJECTIVES & OVERVIEW
Python Strings. *
Python Booleans.
Python Operators.
Python Lists. *
Python Tuple. *
Python Sets. *
Python Dictionaries. *
Python If … else . *
Python Loops. *
OBJECTIVES OF THIS
WEEK’S CLASS
?
RI
?
!
AB
?
hmed” LE
= “A S
?
x
VARIABLES
y=5 ! X
!
Y
!
print(x+y)
Q&A
REMEMBER
X = 12;
Y = 4;
print( X + Y)
Answer
a) 12 4 b) 12 + 4 c) 16 d) error
REMEMBER
X = 12;
Y = 4;
print(“X + Y”)
Answer
a) 12 4 b) X + Y c) 16 d) error
REMEMBER
X = 12;
Y = 4;
print(X - Y)
Answer
a) 8 b) 12 - 4 c) 12 4 d) error
REMEMBER
REMEMBER:
X = 12; / is divsion.
Y = 4;
print(X / Y)
Answer
a) error b) 12 / 4 c) 12 4 d) 3
REMEMBER
REMEMBER:
X = 12; * is multiply.
Y = 4;
print(X * Y)
Answer
a) error b) 12 * 4 c) 12 4 d) 48
REMEMBER
REMEMBER:
X = 12; * is multiply.
Y = 4;
print(“X * Y”)
Answer
a) error b) 12 * 4 c) 12 4 d) 48
e) X * Y
REMEMBER
X = “Dani”;
Y = 4;
print(X + Y)
Answer
a) error b) Dani + 4 c) Dani 4 d) 5
REMEMBER
X = “Dani”;
Y = 4;
print(X - Y)
Answer
a) error b) Dani - 4 c) Dani 4 d) 9
REMEMBER
X = “Dani”;
Y = 4;
print(X / Y)
Answer
a) error b) Dani / 4 c) Dani 4 d) 1
REMEMBER
X = “Dani”;
Y = 4;
print(X * Y)
Answer
a) error b) Dani * 4 c) Dani 4 d) 3
HOW TO SOLVE!
5 mins search
X = “Dani”;
Y = 4;
print(X ? Y)
Output? Dani 4
HOW TO SOLVE!
X = “Dani”;
Y = 4;
print(X , Y)
Output? Dani 4
CHALLENGE
Print the following:
X = “My name is”;
Y = “Ahmad”;
print(X ? Y)
My name is Ahmad
CHALLENGE
Print the following:
My name is Ahmad
Y = “Ahmad”;
print( “My name is”, Y)
My name is Ahmad
VARIABLES
• How to print the following sentence:
Y = 7;
X = “Ahmad”;
print(“My name is: “ , X , “and I am : “ , Y , “years old”)
?
? RI
! ES ? AB
hmed”
= “A
?
x
L
VARIAB L
! X
!
ES
!
y=5 Y
Q&A
REMEMBER
X = 12;
Y = 4;
print( X + Y)
Answer
a) 12 4 b) 12 + 4 c) 16 d) error
REMEMBER
X = 12;
Y = 4;
print(“X + 2Y”)
Answer
a) 12 4 b) X + 2Y c) 16 d) error
REMEMBER
X = 12;
Y = 4;
print( X * Y)
Answer
a) 12 4 b) 48 c) 16 d) error
READ!
FAT
DA
4 IMA TA
11.4
Tr ue
TY
TYPE F PE
A T
D AH A A L SE
2.1
D 33
MA
IN G
STR
Q&A
THINK
What is this?
12
Answer
a) Name b) Integer c) Letter
THINK
What is this?
90.2
Answer
a) Name b) Letter c) Float
THINK
What is this?
Ahmad
Answer
a) String b) Integer c) Float
THINK
What is this?
True
Answer
a) Float b) Integer c) Boolean
DATA TYPES
5 minutes search
Open TalkAI Website
OBJECTIVES & OVERVIEW
Python Strings. *
Python Booleans.
Python Operators.
Python Lists. *
Python Tuple. *
Python Sets. *
Python Dictionaries. *
Python If … else . *
Python Loops. *
OBJECTIVES OF THIS
WEEK’S CLASS
Data Types:
Data types specify the value type of the variable.
Integer (Int):
It represents the whole numbers without decimal points.
Integers can be positive or negative.
Examples:
1 45 -3 100
DATA TYPE
Float:
It represents the real numbers with decimal points. Integers
can be positive or negative.
Examples:
String (str):
It represents sequence of characters like letters, numbers,
symbols with double quotations.
Examples:
“Ahmad” “?$#”
DATA TYPE
Boolean (bool):
It represents one of 2 values TRUE or FALSE.
Examples:
Tru
False
e
DATA TYPE 2 Mins 3 Marks
THIN
K!
What is the answer of the following question?
OPEN
Programiz Python
Compiler
EXERCISE
x = 50
print(type(x))
EXERCISE
x = 50.4325
print(type(x))
EXERCISE
x = “Sara”
print(type(x))
EXERCISE
x = True
print(type(x))