Get the answers you need at Westonci.ca, where our expert community is always ready to help with accurate information. Connect with professionals ready to provide precise answers to your questions on our comprehensive Q&A platform. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.

List sales_data has multiple pairs of integers and strings. Each data pair represents the number of sales and the name of a sales person. The number of sales are at even indices and the names are at odd indices. Integer sales_person_num is read from input. Output:
the name at index sales_person_num
' made '
the number of sales at index sales_person_num - 1
' today.'sales_data = [10, 'Gil', 8, 'Aya', 17, 'Taj', 5, 'Dan', 18, 'Del', 7, 'Ava', 14, 'Ada']
sales_person_num = int(input())


Sagot :

Answer:

```python

sales_data = [10, 'Gil', 8, 'Aya', 17, 'Taj', 5, 'Dan', 18, 'Del', 7, 'Ava', 14, 'Ada']

sales_person_num = int(input())

# Ensure the input is within the range of indices

if sales_person_num >= 0 and sales_person_num * 2 + 1 < len(sales_data):

   # Index of the number of sales

   sales_index = sales_person_num * 2

   # Index of the sales person's name

   name_index = sales_index + 1

   

   # Retrieve the number of sales and name from the sales_data list

   num_sales = sales_data[sales_index]

   name = sales_data[name_index]

   

   # Print the result

   print(sales_data[name_index], 'made', sales_data[sales_index], 'today.')

else:

   print("Invalid input.")

```

This code snippet takes an integer input `sales_person_num` and retrieves the corresponding sales data from the `sales_data` list. It then prints the name of the salesperson and the number of sales made by that person. If the input is invalid (outside the range of indices), it prints "Invalid input."