8000 Tweaks/lesson 5 by jacobwyke · Pull Request #2 · ihf-code/python · GitHub
[go: up one dir, main page]

Skip to content

Tweaks/lesson 5 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and priv 8000 acy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions session_03/answers/A7.py
Original file line number Diff line number Diff line change
@@ -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.")
print("Your current salary is" + str(salary)+ ", you get no bonus.")
18 changes: 9 additions & 9 deletions session_03/answers/B7.py
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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") 10000
else:
print("You are all the same age")
38 changes: 19 additions & 19 deletions session_03/exercises/multiple_choice_3.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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:
Expand All @@ -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
- You are not a teenager - A
20 changes: 10 additions & 10 deletions session_03/slides/session_3.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
```

---
Expand Down Expand Up @@ -318,7 +319,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")
Expand Down Expand Up @@ -365,4 +366,3 @@ if not (age > 12 and age < 20):

# [fit] Coding Time
## Section B

4 changes: 2 additions & 2 deletions session_04/slides/session_4.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -324,4 +324,4 @@ range(2000, 2020, 4)
---

# [fit] Coding Time
## Section B
## Section B
10 changes: 7 additions & 3 deletions session_05/slides/session_5.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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))
Expand Down Expand Up @@ -450,4 +449,9 @@ for x in range(times_to_loop):

---

# [fit] Coding Time
## Section A

---

### Questions?
0