QUESTION IMAGE
Question
challenge activity 3.3.1: tuple basics. jump to level 1 school is a named tuple with fields: name, city, state, and enrollment. read three strings and one integer from input. create school_data as a school tuple, and initialize school_data with schoolname, citylocated, statelocated, and enrollment count as the fields. click here for example 1 from collections import namedtuple 3 school = namedtuple(\school\,
ame\, \city\, \state\, \enrollment\) 4 5 \\\ your code goes here \\\ 6 7 print(f\school name: {school_data.name}\, f\city: {school_data.city}\, f\state: {school_data.state}\, f\enrollment: {s how was this section? provide section feedback feedback? check next level 1 2 3 4
Step1: Read input values
school_name = input().strip()
city_located = input().strip()
state_located = input().strip()
enrollment_count = int(input().strip())
Step2: Initialize the named tuple
school_data = School(name=school_name, city=city_located, state=state_located, enrollment=enrollment_count)
Step3: Fix print statement variable
print(f"School name: {school_data.name}, City: {school_data.city}, State: {school_data.state}, Enrollment: {school_data.enrollment}")Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
from collections import namedtuple
School = namedtuple("School", ["name", "city", "state", "enrollment"])
# Read input values
school_name = input().strip()
city_located = input().strip()
state_located = input().strip()
enrollment_count = int(input().strip())
# Initialize the named tuple
school_data = School(name=school_name, city=city_located, state=state_located, enrollment=enrollment_count)
# Print the formatted output
print(f"School name: {school_data.name}, City: {school_data.city}, State: {school_data.state}, Enrollment: {school_data.enrollment}")