Others Class PDF
Others Class PDF
LIST
21
Meeting 3 - Lists
INTRO TO LISTS
Lists
Imagine you are making a game and want to save the name of the player in
each team. If you code a variable for each player name, it will look as in the
image below. It uses a lot of space, right?
22
Meeting 3 - Lists
LIST IN PYTHON
?
? ? QUIZ TIME
Type the answer to the question below in chat!
FALSE TRUE
FALSE TRUE
23
Meeting 3 - Lists
LIST IN PYTHON
4. Type the following code in the text editor, then press the Run button
5. Type the following code in the text editor, then press the Run button
24
Meeting 3 - Lists
LIST IN PYTHON
W hat is the first data? _______________
What is the second data? __________________
What is the last data? ________________
6. Type the following code in the text editor, then press the Run button
CHALLENGE
Try to display the data in the 2nd, 5th, and last order in the
Pokemon list below by coding Python in Replit!
pokemon = [Pikachu, Bulbasaur, Charmeleon, Squirtle,
Wartortle, Kakuna, Kadabra]
Coding
To store data in the list we use the following code:
list_name = [Data, Data, Data]
To display the number of data in the list we use the code:
print(len(list_name))
To display the data type we use the code:
print(t ype(list _name))
To display the order of data in the list we use the code:
print(list _name[index])
25
Meeting 3 - Lists
CHALLENGE
Try to create a square shape with 100px long straight lines
and green lines using Python’s coding in Replit!
27
HOWHO WA WSA TSO TDOADYA’YS’
QUIZ TIME ?
? ?
Let’s check your understanding by answering the
question in the link below
Open Link :h ttps://forms.gle/hto79xqeY5VFpPok8
WHAT’S NEXT?
LOOPING
28
Meeting 4
LOOPS
29
Meeting 4 - Loops
INTRO TO INDENTATION
After successfully learning variables and data
types, it’s time for you to learn about Indentation
and Loops
Have you ever seen messy and
disorganized coding?
Of course, it will be difficult to
understand and difficult to fix the error,
right?
Python has a rule for typing code to make the code look
neat which is called Indentation
Do you know what Indentation is?
Indentat ion
30
Meeting 4 - Loops
INTRO TO LOOPS
When is indentation used?
Indentation is very important used in several coding concepts such as
Loops (for & while), conditional (if, else, elif), and function.
Indentation is used to make it easier for humans to read program code and
is tasked with defining the structure of program code blocks
Using repeat
can shorten the
coding that is
compiled
Loops
31
Meeting 4 - Loops
LOOPS
There are 2 types of loops in python, they are:
For Loops
For loops are used when you know how many times you
want to run the code loop.
While Loops
While loops are used when you don’t know how many
times you want to run the coding loop and the coding will
loop over and over as long as the condition is met.
?
? ? QUIZ TIME
Type the answer to the question below in chat!
FALSE TRUE
While Do while
For Loop
Loop
32
Meeting 4 - Loops
FOR LOOPS
We will learn to display data using For Loops.
1. Open the link : https://replit.com
2. Log in with your Google account
3. Click +Create
4. Choose the Python template, add title for_loops,
5. then +Create repl
Type the following code in the text editor to display the text
5 times, then press the Run button
Repeated
coding
33
Meeting 4 - Loops
FOR LOOPS
Start End
9. Type the following code in the text editor to calculate multiples
numbers with the concept of increment, then press the Run button
11. Type the following code in the text editor to display the number
of data loops entered, then press the Run button
Coding
To create a coding loop in python we use the code:
for Counter_Variable in range (Number) :
or
for Counter_Variable in range (Start, End, Increment/decrement) :
or
for Counter_Variable in Variable :
34
Meeting 4 - Loops
WHILE LOOPS
We will learn to display data using While Loops.
1. Click +Create
2. Choose the Python template, add title while_loops, then +Create
3.
repl
Type the following code in the text editor to display the
numbers 0-9, then press the Run button
Star t
Coding
To create a coding loop in python we use the code:
while Condition end :
or
35
Meeting 4 - Loops
36
Meeting 4 - Loops
TURTLE
We will learn how to draw a square using a turtle.
CHALLENGE
Try to display a triangle image using the concept of a for loop
with a green line!
37
HOWHO WA WSA TSO TDOADYA’YS’
QUIZ TIME ?
? ?
Let’s check your understanding by answering the
question in the link below
Open Link : https://forms.gle/ANyTt9maCkfAZAMq5
WHAT’S NEXT?
CONDITIONAL
38