Python

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 75

PYTHON

PROGRAMMING LANGUAGE

YAZAN
OBJECTIVES OF THIS
WEEK’S CLASS

1. Write Your First Python Code.


2. Apply The Concept Of Comment.
OBJECTIVES & OVERVIEW

Introduction into python.


Python History.
Installing Visual Studio code and Python.
Python Syntax.
Write Your First Code.
Python Comments.
Python Variables. *
Python data types.
Python Number.
Python Castings.
OBJECTIVES & OVERVIEW

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);

This is a Picture of #This Python code prints a


Green Snake number equal to 94
COMMENTS
• Open Python Compiler:

Print your name:


Print(“YOUR
NAME”);
Write a comment:
#I am printing my name
VARIABLES
OBJECTIVES OF THIS
WEEK’S CLASS

1. Apply Python Code.


2. Understand Variables and Apply them.
INSTALLING VIRTUAL STUDIO CODE
IDE

Open

programiz python compiler


VARIABLES
• Variables are containers for storing data values.

= 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:

Crate a variable called X and give it a value of your name

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;

print(X + Y) print(X - Y) print(X * Y) print(X / Y)

Output? 2 Output? 0 Output? 1 Output? 1


VARIABLES
• Variables with names

X =“Ahmad”; DO NOT
FORGET THE
Y = “Mohammad”; DOUBLE
QUOTATIONS
print(X) FOR AHMAD
AND
Output? Ahmad MOHAMMAD

print(Y)
Output? Mohammad
OBJECTIVES & OVERVIEW

Introduction into python.


Python History.
Installing Visual Studio code and Python.
Python Syntax.
Write Your First Code.
Python Comments.
Python Variables. *
Python data types.
Python Number.
Python Castings.
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

1. Apply Python Code.


2. Create Variables and Apply them together.
VARIABLES
cont.
VARIABLES
• Combine two variables together

X = “Ahmad”;

Y = 12;

We learnt before how to add two variables as numbers, BUT


HOW TO ADD A NUMBER AND A TEXT.
VARIABLES
• Combine two variables together

X = 1;
Y = 12;
print( X + Y)
Output? 13
VARIABLES
• Combine two variables together

X = “Ahmad”;
Y = 12;
print( X + Y)

Output? ERROR
VARIABLES

Open Google and search this question:

How to print variables in Python?


VARIABLES
• Combine two variables together
• First way:

X = “Ahmad”;
Y = 12;

print( X , Y)
Output? Ahmad 12
VARIABLES
cont.
OBJECTIVES & OVERVIEW

Introduction into python.


Python History.
Installing Visual Studio code and Python.
Python Syntax.
Write Your First Code.
Python Comments.
Python Variables. *
Python data types.
Python Number.
Python Castings.
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

1. Students Should Be Able Remember The Use Of


Variables.
2. Some Students Must Apply Python Code.
3. Students Should Create Variables With Different
Types And Apply Them Together.
REMEMBER
Z ! VA

?
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:

My name is Ahmad and I am 7 years old

HINT: store Ahmad in a variable and 7 in a variable.


VARIABLES
• How to add a text inside the print command?

Y = 7;
X = “Ahmad”;
print(“My name is: “ , X , “and I am : “ , Y , “years old”)

Output? My name is Ahmad I am 12 years old


REMEMBER
Z ! VA

?
? 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

Introduction into python.


Python History.
Installing Visual Studio code and Python.
Python Syntax.
Write Your First Code.
Python Comments.
Python Variables. *
Python data types. *
Python Number.
Python Castings.
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

1. Students should be able remember the use of


variables.
2. Some students must apply python code.
3. Students should create variables with different types
and apply them together.
DATA TYPE

Data Types:
Data types specify the value type of the variable.

Int Float String Boolean


DATA TYPE

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:

1.23 45.4 -3.42 100.0


DATA TYPE

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?

What is the data type of “5” and “5.3” ?

a) Float b) String c) Boolean d) Integer


DATA TYPE

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))

You might also like