G11_C6_TeacherCopy
Activity Flow | Slide No. | Topic | Time |
---|---|---|---|
TA | 4-7 | WarmUp Quiz | 3 min |
8-9 | Revision | 2 min | |
10-21 | Introduction to Lists | 10 min | |
22-30 | Creating and Iterating through Lists | 10 min | |
SA | 31-33 | Brick Creation | 5 min |
TA | 34 | Precap | 2 min |
Wrap - Up | 35-38 | Quiz | 3 min |
SA | 39-44 | Additional Activity | 10 min |
Slide No. | Topic |
---|---|
15 | TA1 Solution |
18 | TA2 Solution |
21 | TA3 Solution |
27 | TA4 Solution |
29 | TA5 Solution |
31 | TA6 Solution |
34 | SA1 solution |
41 | SAA1 solution |
43 | SAA2 Solution |
Computer with an Internet connection.
The latest browser installed.
Spyder IDE.
Projector to present the screen.
1. Computer with an Internet connection.
2. The latest browser installed.
3.Spyder IDE.
for loop
A "for" loop is a better choice when the task has to be performed a predefined number of times.
A "while" loop is more useful when the decision on whether to perform a task depends on some condition that needs to be dynamically changed.
print 0 infinitely
for i in range(10):
prod=10*i
while prod<=10:
print(prod)
check again
condition never becomes false!!
for i in range 10:
for loop starts: i=0
prod=10*0=0
prod<=10? : True
prod which is "0" is printed
carryOn = True
while carryOn:
for event in pygame.event.get():
if event.type == pygame.QUIT:
carryOn = False
pygame.quit()
B
Single value
Multiple values
List
B
roll_no=[12,56,90]
Box Brackets
Comma
roll_no=[12,56,90]
print(roll_no)
dot operator: helps the append function understand which list it has to work on.
List to which we want to append an item
Here: roll_no
item to be appended to list
append function:
appends one item to list
roll_no=[12,56,90]
print(roll_no)
roll_no.append(67)
print(roll_no)
roll_no.append(39)
print(roll_no)
dot operator: helps the remove function understand which list it has to work on.
List to which we want to remove an item
Here: roll_no
item to be removed
from list
remove
function:
removes one item to list
roll_no=[12,56,90]
print(roll_no)
roll_no.append(67)
print(roll_no)
roll_no.append(39)
print(roll_no)
roll_no.remove(90)
print(roll_no)
numbers=[1,2,3,4,5,6,...]
numbers=[]
for i in range(1,101):
numbers.append(i)
1. Create an "empty" list
2. Use a "for" loop to iterate through the desired range.
3. Append the desired element to the created list.
1. Create an "empty" list
2. Use a "for" loop to create a rectangle object
and add to the "empty" list.
X 6 times
bricksR=[]
for i in range(6):
brick=pygame.Rect(10 + i* 100,60,80,30)
red_bricks.append(brick)
Too many steps!!
What item to append?
How many times to append?
1. Create an "empty" list
2. Use a "for" loop to create
rectangle object and it add to the "empty" list.
X6 times
bricksR=[pygame.Rect(10 + i* 100,60,80,30) for i in range(6)]
for i in bricksR:
pygame.draw.rect(screen,RED,i)
Write to code to see the orange bricks on the screen.
Hints:
bricksO=[pygame.Rect(10 + i* 100,100,80,30) for i in range(6)]
for i in bricksO:
pygame.draw.rect(screen,ORANGE,i)
ORANGE = [255,100,0]
Remove brick
Since 10 is not present it will throw us a value error.
num=[2,3,4,6,7]
num.remove(10)
print(num)
The syntax is :
list.append(item)
num=[2,3,4,6,7]
append(num,10)
print(num)
Write a code to see the yellow bricks on the screen
Hints:
bricksY=[]
for i in range(7):
brick=pygame.Rect(10 + i* 100,140,80,30)
bricksY.append(brick)
for i in bricksY:
pygame.draw.rect(screen,YELLOW,i)
YELLOW = [255,255,0]
Code to be able to see the yellow bricks on the screen
Hints:
bricksY=[pygame.Rect(10 + i* 100,140,80,30) for i in range(7)]
for i in bricksY:
pygame.draw.rect(screen,YELLOW,i)
YELLOW = [255,255,0]
Activity | Activity Name | Link |
---|---|---|
TEACHER ACTIVITY 1,2,3 | List creation | |
TEACHER ACTIVITY 4 | Red brick creation | |
TEACHER ACTIVITY 5 | List comprehension | |
TEACHER ACTIVITY 6 | List iteration | |
TEACHER ACTIVITY 1 SOLUTION | Solution of TA1 | |
TEACHER ACTIVITY 2 SOLUTION | Solution of TA2 | |
TEACHER ACTIVITY 3 SOLUTION | Solution of TA3 | |
TEACHER ACTIVITY 4 SOLUTION | Solution of TA4 | |
TEACHER ACTIVITY 5 SOLUTION | Solution of TA5 | |
TEACHER ACTIVITY 6 SOLUTION | Solution of TA6 | |
STUDENT ACTIVITY 1 | Orange Brick Creation | |
TEACHER REFERENCE: STUDENT ACTIVITY 1 SOLUTION | Solution of SA1 | |
STUDENT ADDITIONAL ACTIVITY 1 | Yellow brick creation | |
STUDENT ADDITIONAL ACTIVITY 2 | Yellow brick creation (List Comprehension) |
|
TEACHER REFERENCE: STUDENT ADDITIONAL ACTIVITY 1 SOLUTION | Solution of SAA1 | |
TEACHER REFERENCE: STUDENT ADDITIONAL ACTIVITY 2 SOLUTION | Solution of SAA2 |