8000 Updated session 4 and multiple choice questions · ihf-code/python@53c0e1b · GitHub
[go: up one dir, main page]

Skip to content

Commit 53c0e1b

Browse files
committed
Updated session 4 and multiple choice questions
1 parent b38536c commit 53c0e1b

File tree

6 files changed

+105
-28
lines changed

6 files changed

+105
-28
lines changed

session_04/answers/B4.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
# B4 - The modern olympics started in 1896, print the years they have been held
22

3-
for olympic_year in range(1896, 2019, 4):
3+
for olympic_year in range(1896, 2022, 4):
44
print(olympic_year)
5+
6+
# Bonus: skip the years it has not been 1916, 1940, 1944, 2020
7+
8+
not_held = [1916, 1940, 1944, 2020]
9+
10+
for olympic_year in range(1896, 2022, 4):
11+
if olympic_year not in not_held:
12+
print(olympic_year)

session_04/exercises/exercises_4.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1. Loop through the list you created in section A and print each item out
1313
2. Print the numbers 1 to 100 (including the number 100)
1414
3. Print all odd numbers from 1 to 100
15-
4. The modern olympics started in 1896, print the years they have been held (bonus points to skip 1916, 1940, 1944)
15+
4. The modern olympics started in 1896, print the years they have been held (bonus points to skip the years it has not been held 1916, 1940, 1944, 2020)
1616
5. Create a list of ten random numbers. Loop through your list and count the number of even numbers and the number of odd numbers.
1717
6. Create a list of five names. Write a loop that will print "Hello" plus each name in the list.
1818
7. Create a loop to go through each letter of the word "supercalifragilisticexpialidocious".
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# KPMG:Code - Session 4 - Multiple Choice Questions
2+
3+
1. What is a list?
4+
- a way to allow user input
5+
- a statement that allows a computer to make a decision
6+
- a way to print an output
7+
- a collection of data - A
8+
9+
2. What brackets does a list use?
10+
- {}
11+
- ()
12+
- [] - A
13+
- <>
14+
15+
3. What will be the output of the below:
16+
flowers = ["tulip", "rose", "snowdrop", "lily"]
17+
print(flowers[-1])
18+
19+
- tulip
20+
- rose
21+
- snowdrop
22+
- lily - A
23+
24+
4. What will be the output of the below:
25+
flowers = ["tulip", "rose", "snowdrop", "lily"]
26+
flowers[2] = "sunflower"
27+
28+
print(flowers)
29+
30+
- ["sunflower", "rose", "snowdrop", "lily"]
31+
- ["tulip", "sunflower", "snowdrop", "lily"]
32+
- ["tulip", "rose", "sunflower", "lily"] - A
33+
- ["tulip", "rose", "snowdrop", "sunflower"]
34+
35+
5. What will be the output of the below:
36+
birds = ["albatross", "buzzard", "chicken"]
37+
38+
if "chicken" in birds:
39+
print("A chicken is here")
40+
else:
41+
print("A chicken isn't here")
42+
43+
- A chicken is here - A
44+
- A chicken isn't here
45+
46+
6. To print out the numbers 0-100, fill in the blank:
47+
for num in range(?):
48+
print(num)
49+
50+
- 99
51+
- 100
52+
- 101 - A
53+
- 0
54+
55+
7. A for loop is used for iterating over a sequence.
56+
57+
- True - A
58+
- False
59+
60+
8. What will be the output of the below:
61+
total = 0
62+
63+
for num in range(1,4):
64+
total += num
65+
66+
print(total)
67+
68+
- 0
69+
- 2
70+
- 4
71+
- 6 - A
72+
73+
9. What will be the output of the below:
74+
names = ["Saf", "Anita", "Jake", "Jackie"]
75+
captains = []
76+
for name in names:
77+
captains.append("Captain. " + name)
78+
print(captains)
79+
80+
- ["Dr. Saf", "Dr. Anita", "Dr. Jake", "Dr. Jackie"]
81+
- ["Captain. Saf", "Captain. Anita", "Captain. Jake", "Captain. Jackie"]
82+
- ["Capn. Saf", "Capn. Anita", "Capn. Jake", "Capn. Jackie"]
83+
- ["Saf", "Anita", "Jake", "Jackie"]
84+
85+
10. What will be the output of the below:
86+
for x in range(1,10,2):
87+
print(x)
88+
89+
- The even numbers from 1 to 10
90+
- The odd numbers from 1 to 10 - A

session_04/slides/answers_4.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
# [fit] IHF: Code
1+
# [fit] KPMG: Code
22
## [fit] Python — Session 4 — Answers
3-
### Live at 10am
43

54
---
65

76
## Any Questions
8-
### go to sli.do #python2020
9-
10-
---
11-
12-
# [fit] Next Session
13-
### Tuesday 9th June 10am
14-
### Lesson 5

session_04/slides/session_4.md

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# [fit] IHF: Code
1+
# [fit] KPMG: Code
22
## [fit] Python — Session 4 — Lesson
3-
### Live at 10am
43

54
---
65

@@ -158,7 +157,6 @@ if not (age > 12 and age < 20):
158157
---
159158

160159
## Any Questions?
161-
### sli.do #python2020
162160

163161
---
164162

@@ -326,15 +324,4 @@ range(2000, 2020, 4)
326324
---
327325

328326
# [fit] Coding Time
329-
## Section B
330-
331-
---
332-
333-
### Questions?
334-
### go to sli.do #python2020
335-
336-
---
337-
338-
# [fit] Next Session
339-
### Thursday 4th June 10am
340-
### Answers
327+
## Section B

session_04/slides/thumbnails_4.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# [fit] IHF: Code
1+
# [fit] KPMG: Code
22
## [fit] Python — Session 4 — Lesson
33

44
---
55

6-
# [fit] IHF: Code
6+
# [fit] KPMG: Code
77
## [fit] Python — Session 4 — Answers

0 commit comments

Comments
 (0)
0