From ace4407151b7988aba988793202f018263b0715c Mon Sep 17 00:00:00 2001 From: Jacob Wyke Date: Mon, 30 Jan 2023 15:18:35 +0000 Subject: [PATCH 1/2] Tweaking comment --- session_03/slides/session_3.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/session_03/slides/session_3.md b/session_03/slides/session_3.md index 7cd90d83..f72ee4e7 100644 --- a/session_03/slides/session_3.md +++ b/session_03/slides/session_3.md @@ -318,7 +318,7 @@ if age <= 13: elif age < 18: print("You are between 14 and 17") elif age == 0: - # This can never be run + # This will never get run print("You aren't born yet") else: print("You are 19 or over") @@ -365,4 +365,3 @@ if not (age > 12 and age < 20): # [fit] Coding Time ## Section B - From b8f44cfeb9a991082e6c11772010e6292cb96502 Mon Sep 17 00:00:00 2001 From: Jacob Wyke Date: Wed, 15 Feb 2023 20:46:11 +0000 Subject: [PATCH 2/2] More tweaks --- session_03/answers/A7.py | 8 ++--- session_03/answers/B7.py | 18 +++++------ session_03/exercises/multiple_choice_3.md | 38 +++++++++++------------ session_03/slides/session_3.md | 17 +++++----- session_04/slides/session_4.md | 4 +-- session_05/slides/session_5.md | 10 ++++-- 6 files changed, 50 insertions(+), 45 deletions(-) diff --git a/session_03/answers/A7.py b/session_03/answers/A7.py index 3117f403..faa89fd7 100644 --- a/session_03/answers/A7.py +++ b/session_03/answers/A7.py @@ -1,9 +1,9 @@ -# A7 - Your company has had a great year and are going to offer a bonus of 10% to any employee who has a service of over 3 years. +# A7 - Your company has had a great year and are going to offer a bonus of 10% to any employee who has a service of over 3 years. # Ask the user to input their current salary and years of service and print out their salary and their bonus or "No bonus" if they are not receiving one. -# salary = int(input("What is your current salary?\n")) -# years_of_service = int(input("How many years have you worked here?\n")) +salary = int(input("What is your current salary?\n")) +years_of_service = int(input("How many years have you worked here?\n")) if years_of_service > 3: print("Your current salary is" + str(salary)+ ", your bonus is" + str(salary*0.1)) else: - print("Your current salary is" + str(salary)+ ", you get no bonus.") \ No newline at end of file + print("Your current salary is" + str(salary)+ ", you get no bonus.") diff --git a/session_03/answers/B7.py b/session_03/answers/B7.py index 318b103b..65c232f9 100644 --- a/session_03/answers/B7.py +++ b/session_03/answers/B7.py @@ -1,5 +1,5 @@ -# B7 - Take the age and name of three people and determine who is the oldest and youngest -# and print out the name and age of the oldest and youngest. +# B7 - Take the age and name of three people and determine who is the oldest and youngest +# and print out the name and age of the oldest and youngest. # If all three ages are the same, print that. name1 = input("What is your name?\n") @@ -9,22 +9,22 @@ name3 = input("What is your name?\n") age3 = int(input("How old are you?\n")) -#Oldest +#Oldest if age1 > age2 and age1 > age3: print(name1 + "is the oldest and is " + str(age1) + "years old.") elif age2 > age1 and age2 > age3: print(name2 + "is the oldest and is " + str(age2) + "years old.") -elif age3 > age1 and age3> age2: +elif age3 > age1 and age3> age2: print(name3 + "is the oldest and is " + str(age3) + "years old.") -else: - ("You are all the same age") +else: + print("You are all the same age") #Youngest if age1 < age2 and age1 < age3: print(name1 + "is the youngest and is " + str(age1) + "years old.") elif age2 < age1 and age2 < age3: print(name2 + "is the youngest and is " + str(age2) + "years old.") -elif age3 < age1 and age3 < age2: +elif age3 < age1 and age3 < age2: print(name3 + "is the youngest and is " + str(age3) + "years old.") -else: - ("You are all the same age") \ No newline at end of file +else: + print("You are all the same age") diff --git a/session_03/exercises/multiple_choice_3.md b/session_03/exercises/multiple_choice_3.md index 00c06da6..64bc8846 100644 --- a/session_03/exercises/multiple_choice_3.md +++ b/session_03/exercises/multiple_choice_3.md @@ -2,20 +2,20 @@ 1. What is a conditional? - an expression that allows a user to enter an input -- an expression that allows a computer to make a decision - A +- an expression that allows a computer to make a decision - A - an expression that allows a computer to print an output - an expression that makes a string upper case 2. What will be the output of the below: -sum = 5 + 6 +sum = 5 + 6 if sum == 10: print("The value is 10") - 10 - The value is 10 -- There will be no output - A -- 11 +- There will be no output - A +- 11 3. What will be the output of the below: name = "Jackie" @@ -26,24 +26,24 @@ if name == "Anita": print("Thanks") -- Thanks - A +- Thanks - A - Hello Anita - How are you? - Hello Anita How are you? Thanks -4. What does the == comparator mean? +4. What does the == comparator mean? - equals - A -- does not equal +- does not equal - greater than -- less than or equal to +- less than or equal to -5. What does the != comparator mean? +5. What does the != comparator mean? - equals - does not equal - A - greater than -- less than or equal to +- less than or equal to 6. What is the output of below? age = 15 @@ -53,7 +53,7 @@ else: print("You cannot vote") - You can vote -- You cannot vote - A +- You cannot vote - A 7. What is the output of below? traffic_light = "red" @@ -69,7 +69,7 @@ else: - STOP! - You can go! - A -8. What will be the output of the below: +8. What will be the output of the below: age = 0 if age <= 13: @@ -81,23 +81,23 @@ elif age == 0: else: print("You are 19 or over") -- You are 13 or younger - A +- You are 13 or younger - A - You are between 14 and 17 -- You aren't born yet -- You are 19 or over +- You aren't born yet +- You are 19 or over -9. What will be the output of the below: +9. What will be the output of the below: age = 14 if age > 12 and age < 20: print("You are a teenager") -- You are a teenager +- You are a teenager - You are not a teenager -10. What will be the output of the below: +10. What will be the output of the below: age = 12 if age < 13 or age > 19: print("You are not a teenager") - You are a teenager -- You are not a teenager \ No newline at end of file +- You are not a teenager - A diff --git a/session_03/slides/session_3.md b/session_03/slides/session_3.md index f72ee4e7..9dce9e34 100644 --- a/session_03/slides/session_3.md +++ b/session_03/slides/session_3.md @@ -81,17 +81,18 @@ z = str(10.0) # z will be '10.0' # Index -| C | H | A | R | L | I | E | -| --- | --- | --- | --- | --- | --- | --- | -| 0 | 1 | 2 | 3 | 4 | 5 | 6 | -| -7 | -6 | -5 | -4 | -3 | -2 | -1 | + +| A | L | A | N | T | U | R | I | N | G | +| --- | --- | --- | --- | --- | --- | --- | -- | -- | -- | +| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | + ```python -name = "CHARLIE" -print(name[0]) # Prints 'C' - first index item -print(name[1]) # Prints 'H' -print(name[-1]) # Prints 'E' - last index item +fullname = "Alan" + "Turing" +length = len(fullname) # 10 +# int(length / 2) = 5 +middle_letter = fullname[5].lower() ``` --- diff --git a/session_04/slides/session_4.md b/session_04/slides/session_4.md index 3fb70f08..e3104570 100644 --- a/session_04/slides/session_4.md +++ b/session_04/slides/session_4.md @@ -116,7 +116,7 @@ if age <= 13: elif age < 18: print("You are between 14 and 17") elif age == 0: - # This can never be run + # This will never get run print("You aren't born yet") else: print("You are 19 or over") @@ -324,4 +324,4 @@ range(2000, 2020, 4) --- # [fit] Coding Time -## Section B \ No newline at end of file +## Section B diff --git a/session_05/slides/session_5.md b/session_05/slides/session_5.md index 7d2e4d1e..7569778b 100644 --- a/session_05/slides/session_5.md +++ b/session_05/slides/session_5.md @@ -75,7 +75,7 @@ for person in names: ```python # Create variables to store our numbers and counts -numbers = [1, 10, 13 , 15, 765, 32, 65, 23, 56, 101] +numbers = [1, 10, 13, 15, 765, 32, 65, 23, 56, 101] even_count = 0 odd_count = 0 @@ -85,8 +85,7 @@ for i in numbers: if i % 2 == 0: even_count = even_count + 1 else: - # This is short hand for the line above - odd_count += 1 + odd_count = odd_count + 1 print("Even: " + str(even_count)) print("Odd: " + str(odd_count)) @@ -450,4 +449,9 @@ for x in range(times_to_loop): --- +# [fit] Coding Time +## Section A + +--- + ### Questions?