All our Data Science projects include bite-sized activities to test your knowledge and practice in an environment with constant feedback.
All our activities include solutions with explanations on how they work and why we chose them.
Loop through the students
tuple and find the total number of students with grade A
.
Enter your answer in below as integer.
Construct a nested tuple named grade_count
that stores pairs of grades and their corresponding counts of students with that grade.
Your tuple should follow this structure(grade, count)(grades arranged in ascending order):
grade_count = (
('A', 23),
('B', 20),
('C', 17),
('D', 15),
('E', 25),
('F', 20)
)
Note that this is an illustrative example, and your actual solution will follow a similar pattern.
Create a new tuple named failed_students
sorted alphabetically that contains the names of students with grades F
.
Sort the students
tuple based on student names in ascending order and store the result in a new tuple named sorted_students
.
If the tuple is like below:
students = (
(1, 2),
('Joseph Mendoza', 'Carlos Green'),
('1818 Guzman Court Suite 712\nEast Carolyntown, IN 32206', '80276 Paul Trace\nSouth Chad, GA 46047'),
('A', 'B')
)
Then the sorted tuple should look like below:
sorted_students = (
(2, 1),
('Carlos Green', 'Joseph Mendoza'),
('80276 Paul Trace\nSouth Chad, GA 46047',
'1818 Guzman Court Suite 712\nEast Carolyntown, IN 32206'),
('B', 'A')
)
Split the students
tuple into two separate tuples containing the first and last 50 students, respectively. Store the first 50 students in a tuple named first_half
and the last 50 students in a tuple named second_half
.
Find the address of the student with the name 'Stephanie Harris' in the students
tuple.
Enter the address below input box as string.
If there are multiple students with same name input the address of the students who occur first.
Check if the grade E
exists in the students
tuple.
Find the index of the first occurrence of grade B
in the students
tuple.
Enter you answer as integer.
Find the index of the last occurrence of grade C
in the students
tuple.
Enter you answer as integer.
Create a new tuple named long_names
that contains the names of students with names longer than 15 characters.
Remove the student with the name 'Daniel Golden' from the students
tuple.
If there are multiple students with name
Daniel
then remove the first occurence.If you not able to pass the activity even after correct solution then try again reading
students
data.The tuples are
immutable
, meaning that even though we're updating them, we're creating new tuples to take the place of the old ones.
Name the first student who has grade D
.
Enter the name below input box as string.
Replace the grade of the student named 'Kevin Mccormick DVM' with 'B' in the students
tuple.
If there are multiple students with name
Kevin Mccormick DVM
then replace the grade of the first occurence.Note that, tuples are
immutable
, we need to create a new tuples to take the place of the old ones.
I think you noticed there are no students with grade E
, so let's add 6 students with grade E
in the students
tuple. Below are the details of six students:
student_ids = (100, 101, 102, 103, 104, 105)
student_names = ('John Doe', 'Twinkle Khanna', 'Jackson', 'Sunny Deol', 'Narendra Modi', 'Rahul Gandhi')
student_address = (
"123, Gali No. 4, Sarai Rohilla, New Delhi, Delhi, 110007",
"456, MG Road, Shivaji Nagar, Bangalore, Karnataka, 560001",
"789, Park Street, Park Circus, Kolkata, West Bengal, 700017",
"987, Jubilee Hills, Banjara Hills, Hyderabad, Telangana, 500033",
"654, Mount Road, Anna Salai, Chennai, Tamil Nadu, 600002",
"321, MG Road, Civil Lines, Jaipur, Rajasthan, 302001"
)
student_grades = ('E', 'E', 'E', 'E', 'E', 'E')
Add these students detail at the end of the tuple.
Store all the student ids in a variable named ids
, names in names
, address in address
, and grades in grades
. All these variables are of type tuple.
Make sure to not change the order of details of students.