Write Python code to input student data, each line per student, where student name is the first item in each line, and the student test scores follow.  Store all data in variables to be used in the same IDE session.

 

 

>>> data = """
... Bill 93 83 89
... Steve 88 85 90
... Karen 99 79 82
... Jane 65 98 98
... """
>>> lines = data.strip().split('\n')
>>> student_data = []
>>>
>>> for line in lines:
...     name, *scores = line.split()
...     scores = [int(score) for score in scores]
...     student_data.append((name, scores))
...
>>> for name,scores in student_data:
...     print(f"Student: {name}, Scores: {scores}")
...
Student: Bill, Scores: [93, 83, 89]
Student: Steve, Scores: [88, 85, 90]
Student: Karen, Scores: [99, 79, 82]
Student: Jane, Scores: [65, 98, 98]
>>> 

 

 

Now continue with the previous exercise, write Python code to display student name only on a single line.

 

>>> student_names_input = input("Enter student names separated by spaces: ")
Enter student names separated by spaces: Bill Steve Karen Jane
>>> student_names_input.split()
['Bill', 'Steve', 'Karen', 'Jane']

 

 

Go Back