From fd239e60491a6fbcb01cac93915bc70792fe9f3d Mon Sep 17 00:00:00 2001 From: Citrus716 <60357364+Citrus716@users.noreply.github.com> Date: Thu, 30 Jul 2020 11:27:55 -0400 Subject: [PATCH 01/10] Added Participation grade --- .../chapter9/practice/participation_grade.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 2_intermediate/chapter9/practice/participation_grade.py diff --git a/2_intermediate/chapter9/practice/participation_grade.py b/2_intermediate/chapter9/practice/participation_grade.py new file mode 100644 index 00000000..60874c06 --- /dev/null +++ b/2_intermediate/chapter9/practice/participation_grade.py @@ -0,0 +1,21 @@ +# Warning: can be challenging +# +# A teacher is given a list of students. The number of occurences of a student's +# name in the list is the number of times the student participated in this week. +# If a student has more the 7 participation, then got an A. If a student has +# more than 3 but less than 8, the student got a B. If a student has more than +# 0 but less than 4, the student got a C. +# +# Make a dictionary with the keys as the students' name and the values as the +# corresponding student's letter grade. Print the dictionary +# +# Write your code below + + +participation_occurences = ["Sam", "Dan", "Bob", "Dan", "Sam", "Sam", + "Bob", "Dan", "Dan", "Ivan", "Ivan", + "Ray", "Sam", "Sam", "Dan", "Ivan", "Ivan", + "Ray", "Dan", "Ivan", "Ivan", "Sam", "Dan", + "Ray", "Sam", "Dan", "Bob", "Dan", "Sam", + "Sam", "Dan", "Bob", "Dan", "Sam", "Sam"] + From cafb98c7aff40a8c322798e8b274d4db709bb08e Mon Sep 17 00:00:00 2001 From: Citrus716 <60357364+Citrus716@users.noreply.github.com> Date: Thu, 30 Jul 2020 11:28:35 -0400 Subject: [PATCH 02/10] Added participation grade solution --- .../chapter9/solutions/participation_grade.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 2_intermediate/chapter9/solutions/participation_grade.py diff --git a/2_intermediate/chapter9/solutions/participation_grade.py b/2_intermediate/chapter9/solutions/participation_grade.py new file mode 100644 index 00000000..d539d1aa --- /dev/null +++ b/2_intermediate/chapter9/solutions/participation_grade.py @@ -0,0 +1,37 @@ +# Warning: can be challenging +# +# A teacher is given a list of students. The number of occurences of a student's +# name in the list is the number of times the student participated in this week. +# If a student has more the 7 participation, then got an A. If a student has +# more than 3 but less than 8, the student got a B. If a student has more than +# 0 but less than 4, the student got a C. +# +# Make a dictionary with the keys as the students' name and the values as the +# corresponding student's letter grade. Print the dictionary +# +# Write your code below + + +participation_occurences = ["Sam", "Dan", "Bob", "Dan", "Sam", "Sam", + "Bob", "Dan", "Dan", "Ivan", "Ivan", + "Ray", "Sam", "Sam", "Dan", "Ivan", "Ivan", + "Ray", "Dan", "Ivan", "Ivan", "Sam", "Dan", + "Ray", "Sam", "Dan", "Bob", "Dan", "Sam", + "Sam", "Dan", "Bob", "Dan", "Sam", "Sam"] + +grade_dict = {} +for student in participation_occurences: + if student not in grade_dict: + grade_dict[student] = 1 + else: + grade_dict[student] += 1 + +for student in grade_dict: + if grade_dict[student] > 7: + grade_dict[student] = "A" + elif grade_dict[student] >3: + grade_dict[student] = "B" + else: + grade_dict[student] = "C" + +print(grade_dict) From 19759bfe23aaf9a2ab7c96bb2a25177d4010b552 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Thu, 30 Jul 2020 15:29:49 +0000 Subject: [PATCH 03/10] Fix code style issues with Black --- .../chapter9/practice/participation_grade.py | 46 ++++++++++++++---- .../chapter9/solutions/participation_grade.py | 47 +++++++++++++++---- 2 files changed, 77 insertions(+), 16 deletions(-) diff --git a/2_intermediate/chapter9/practice/participation_grade.py b/2_intermediate/chapter9/practice/participation_grade.py index 60874c06..b7168caa 100644 --- a/2_intermediate/chapter9/practice/participation_grade.py +++ b/2_intermediate/chapter9/practice/participation_grade.py @@ -4,7 +4,7 @@ # name in the list is the number of times the student participated in this week. # If a student has more the 7 participation, then got an A. If a student has # more than 3 but less than 8, the student got a B. If a student has more than -# 0 but less than 4, the student got a C. +# 0 but less than 4, the student got a C. # # Make a dictionary with the keys as the students' name and the values as the # corresponding student's letter grade. Print the dictionary @@ -12,10 +12,40 @@ # Write your code below -participation_occurences = ["Sam", "Dan", "Bob", "Dan", "Sam", "Sam", - "Bob", "Dan", "Dan", "Ivan", "Ivan", - "Ray", "Sam", "Sam", "Dan", "Ivan", "Ivan", - "Ray", "Dan", "Ivan", "Ivan", "Sam", "Dan", - "Ray", "Sam", "Dan", "Bob", "Dan", "Sam", - "Sam", "Dan", "Bob", "Dan", "Sam", "Sam"] - +participation_occurences = [ + "Sam", + "Dan", + "Bob", + "Dan", + "Sam", + "Sam", + "Bob", + "Dan", + "Dan", + "Ivan", + "Ivan", + "Ray", + "Sam", + "Sam", + "Dan", + "Ivan", + "Ivan", + "Ray", + "Dan", + "Ivan", + "Ivan", + "Sam", + "Dan", + "Ray", + "Sam", + "Dan", + "Bob", + "Dan", + "Sam", + "Sam", + "Dan", + "Bob", + "Dan", + "Sam", + "Sam", +] diff --git a/2_intermediate/chapter9/solutions/participation_grade.py b/2_intermediate/chapter9/solutions/participation_grade.py index d539d1aa..526aebde 100644 --- a/2_intermediate/chapter9/solutions/participation_grade.py +++ b/2_intermediate/chapter9/solutions/participation_grade.py @@ -4,7 +4,7 @@ # name in the list is the number of times the student participated in this week. # If a student has more the 7 participation, then got an A. If a student has # more than 3 but less than 8, the student got a B. If a student has more than -# 0 but less than 4, the student got a C. +# 0 but less than 4, the student got a C. # # Make a dictionary with the keys as the students' name and the values as the # corresponding student's letter grade. Print the dictionary @@ -12,12 +12,43 @@ # Write your code below -participation_occurences = ["Sam", "Dan", "Bob", "Dan", "Sam", "Sam", - "Bob", "Dan", "Dan", "Ivan", "Ivan", - "Ray", "Sam", "Sam", "Dan", "Ivan", "Ivan", - "Ray", "Dan", "Ivan", "Ivan", "Sam", "Dan", - "Ray", "Sam", "Dan", "Bob", "Dan", "Sam", - "Sam", "Dan", "Bob", "Dan", "Sam", "Sam"] +participation_occurences = [ + "Sam", + "Dan", + "Bob", + "Dan", + "Sam", + "Sam", + "Bob", + "Dan", + "Dan", + "Ivan", + "Ivan", + "Ray", + "Sam", + "Sam", + "Dan", + "Ivan", + "Ivan", + "Ray", + "Dan", + "Ivan", + "Ivan", + "Sam", + "Dan", + "Ray", + "Sam", + "Dan", + "Bob", + "Dan", + "Sam", + "Sam", + "Dan", + "Bob", + "Dan", + "Sam", + "Sam", +] grade_dict = {} for student in participation_occurences: @@ -29,7 +60,7 @@ for student in grade_dict: if grade_dict[student] > 7: grade_dict[student] = "A" - elif grade_dict[student] >3: + elif grade_dict[student] > 3: grade_dict[student] = "B" else: grade_dict[student] = "C" From f01bd29c0ee6483aae646e221df9f6845da8df6e Mon Sep 17 00:00:00 2001 From: Citrus716 <60357364+Citrus716@users.noreply.github.com> Date: Sat, 1 Aug 2020 11:10:43 -0400 Subject: [PATCH 04/10] Github lint fix --- 2_intermediate/chapter9/practice/participation_grade.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2_intermediate/chapter9/practice/participation_grade.py b/2_intermediate/chapter9/practice/participation_grade.py index b7168caa..1d75be24 100644 --- a/2_intermediate/chapter9/practice/participation_grade.py +++ b/2_intermediate/chapter9/practice/participation_grade.py @@ -1,7 +1,7 @@ # Warning: can be challenging # # A teacher is given a list of students. The number of occurences of a student's -# name in the list is the number of times the student participated in this week. +# name in the list is the number of times the student participated this week. # If a student has more the 7 participation, then got an A. If a student has # more than 3 but less than 8, the student got a B. If a student has more than # 0 but less than 4, the student got a C. From 754a7dc41a763c705e565fba17618a6a954a9862 Mon Sep 17 00:00:00 2001 From: Citrus716 <60357364+Citrus716@users.noreply.github.com> Date: Sat, 1 Aug 2020 11:11:51 -0400 Subject: [PATCH 05/10] Update participation_grade.py --- 2_intermediate/chapter9/practice/participation_grade.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2_intermediate/chapter9/practice/participation_grade.py b/2_intermediate/chapter9/practice/participation_grade.py index 1d75be24..acaed7d7 100644 --- a/2_intermediate/chapter9/practice/participation_grade.py +++ b/2_intermediate/chapter9/practice/participation_grade.py @@ -1,6 +1,6 @@ # Warning: can be challenging # -# A teacher is given a list of students. The number of occurences of a student's +# A teacher is given a list of students.The number of occurences of a student's # name in the list is the number of times the student participated this week. # If a student has more the 7 participation, then got an A. If a student has # more than 3 but less than 8, the student got a B. If a student has more than From e99b7abf12cc13a8e0c6646547a56ad711f58e85 Mon Sep 17 00:00:00 2001 From: Citrus716 <60357364+Citrus716@users.noreply.github.com> Date: Sat, 1 Aug 2020 11:12:40 -0400 Subject: [PATCH 06/10] Update participation_grade.py --- 2_intermediate/chapter9/solutions/participation_grade.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2_intermediate/chapter9/solutions/participation_grade.py b/2_intermediate/chapter9/solutions/participation_grade.py index 526aebde..c444670e 100644 --- a/2_intermediate/chapter9/solutions/participation_grade.py +++ b/2_intermediate/chapter9/solutions/participation_grade.py @@ -1,6 +1,6 @@ # Warning: can be challenging # -# A teacher is given a list of students. The number of occurences of a student's +# A teacher is given a list of students.The number of occurences of a student's # name in the list is the number of times the student participated in this week. # If a student has more the 7 participation, then got an A. If a student has # more than 3 but less than 8, the student got a B. If a student has more than From c26256e7647af52c0f9ddae0cac5bbd5dd9e6ca2 Mon Sep 17 00:00:00 2001 From: Citrus716 <60357364+Citrus716@users.noreply.github.com> Date: Sat, 1 Aug 2020 18:04:35 -0400 Subject: [PATCH 07/10] Fixed some lint problem ? --- 2_intermediate/chapter9/solutions/participation_grade.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2_intermediate/chapter9/solutions/participation_grade.py b/2_intermediate/chapter9/solutions/participation_grade.py index c444670e..1044cfe4 100644 --- a/2_intermediate/chapter9/solutions/participation_grade.py +++ b/2_intermediate/chapter9/solutions/participation_grade.py @@ -1,7 +1,7 @@ # Warning: can be challenging # # A teacher is given a list of students.The number of occurences of a student's -# name in the list is the number of times the student participated in this week. +# name in the list is the number of times the student participated this week. # If a student has more the 7 participation, then got an A. If a student has # more than 3 but less than 8, the student got a B. If a student has more than # 0 but less than 4, the student got a C. From f3420f1f67188a9f819a5b7a7339b926da38c184 Mon Sep 17 00:00:00 2001 From: abhatia1205 <32373316+abhatia1205@users.noreply.github.com> Date: Sat, 1 Aug 2020 16:40:47 -0700 Subject: [PATCH 08/10] Update participation_grade.py --- 2_intermediate/chapter9/practice/participation_grade.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/2_intermediate/chapter9/practice/participation_grade.py b/2_intermediate/chapter9/practice/participation_grade.py index acaed7d7..8ecad6af 100644 --- a/2_intermediate/chapter9/practice/participation_grade.py +++ b/2_intermediate/chapter9/practice/participation_grade.py @@ -2,9 +2,9 @@ # # A teacher is given a list of students.The number of occurences of a student's # name in the list is the number of times the student participated this week. -# If a student has more the 7 participation, then got an A. If a student has -# more than 3 but less than 8, the student got a B. If a student has more than -# 0 but less than 4, the student got a C. +# If a student has 8 or more participations, they get an A. If a student has +# between 4 and 7 participations, they get a B. If a student has more than +# 0 but less than 4, the student gets a C. # # Make a dictionary with the keys as the students' name and the values as the # corresponding student's letter grade. Print the dictionary From 6b359090e83adc47fe388ee19a51d0c000ee4a06 Mon Sep 17 00:00:00 2001 From: abhatia1205 <32373316+abhatia1205@users.noreply.github.com> Date: Sat, 1 Aug 2020 16:52:26 -0700 Subject: [PATCH 09/10] Update participation_grade.py --- .../chapter9/solutions/participation_grade.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/2_intermediate/chapter9/solutions/participation_grade.py b/2_intermediate/chapter9/solutions/participation_grade.py index 1044cfe4..82353b0c 100644 --- a/2_intermediate/chapter9/solutions/participation_grade.py +++ b/2_intermediate/chapter9/solutions/participation_grade.py @@ -2,9 +2,9 @@ # # A teacher is given a list of students.The number of occurences of a student's # name in the list is the number of times the student participated this week. -# If a student has more the 7 participation, then got an A. If a student has -# more than 3 but less than 8, the student got a B. If a student has more than -# 0 but less than 4, the student got a C. +# If a student has 8 or more participations, they get an A. If a student has +# between 4 and 7 participations, they get a B. If a student has more than +# 0 but less than 4, the student gets a C. # # Make a dictionary with the keys as the students' name and the values as the # corresponding student's letter grade. Print the dictionary @@ -57,7 +57,7 @@ else: grade_dict[student] += 1 -for student in grade_dict: +for student in grade_dict.keys(): if grade_dict[student] > 7: grade_dict[student] = "A" elif grade_dict[student] > 3: @@ -66,3 +66,5 @@ grade_dict[student] = "C" print(grade_dict) + + From 72abd30ac278ea421d12966ded77c718dc788d7d Mon Sep 17 00:00:00 2001 From: Lint Action Date: Sat, 1 Aug 2020 23:52:45 +0000 Subject: [PATCH 10/10] Fix code style issues with Black --- 2_intermediate/chapter9/solutions/participation_grade.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/2_intermediate/chapter9/solutions/participation_grade.py b/2_intermediate/chapter9/solutions/participation_grade.py index 82353b0c..dd4dde72 100644 --- a/2_intermediate/chapter9/solutions/participation_grade.py +++ b/2_intermediate/chapter9/solutions/participation_grade.py @@ -66,5 +66,3 @@ grade_dict[student] = "C" print(grade_dict) - -