Objective:
Students will create and manipulate several 1D lists representing different aspects of new cars — such as brands, prices, colors, and features.
Create four 1D lists, each describing one aspect of new cars.
# List 1: Car brands
car_brands = ["Tesla", "Toyota", "BMW", "Ford", "Hyundai"]
# List 2: Car colors
car_colors = ["Red", "Black", "Blue", "White", "Silver"]
# List 3: Car prices (in USD)
car_prices = [55000, 32000, 67000, 40000, 30000]
# List 4: Car features
car_features = ["Electric", "Hybrid", "Luxury", "SUV", "Compact"]
Use basic list operations to explore and manipulate the data.
Print the number of brands available.
print("Number of car brands:", len(car_brands))
Display the first and last car in the list.
print("First car:", car_brands[0])
print("Last car:", car_brands[-1])
Find the most expensive and least expensive car.
print("Most expensive car:", max(car_prices))
print("Least expensive car:", min(car_prices))
Combine information using indexes.
for i in range(len(car_brands)):
print(f"{car_brands[i]} - {car_colors[i]} - ${car_prices[i]} - {car_features[i]}")
Add a new car brand, color, price, and feature to each list.
Sort the car_prices list in ascending order.
Find the average price of all cars.
Replace the color of the second car with “Green.”
Print only the cars that cost more than $40,000.
Create a new list called eco_friendly_cars that includes only cars with the feature "Electric" or "Hybrid".