Question

Python 3 please and thank you

Task 3: Create a Function 7 Create the function TotalRewardPoints which accepts the dictionary that you created in Task 1 and

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Function to find total reward points that takes a dictionary (dic ) and ticket list (list)-

def TotalRewardPoints(dic, list): 
  i=0
  sumOfRewardPoints = 0  
  while i < (len(list) - 1): 
    numOfTickets = list[i] 
    typeOfTicket = list[i+1] 
    rewardPoint = dic[typeOfTicket] 
    reward_points = numOfTickets * rewardPoint 
    sumOfRewardPoints += reward_points 
    i += 2  
    print("The Total Reward Points is {}".format(sumOfRewardPoints)) 

dic = {"Member": 10, "Luxury":16} 
list = [4, "Member", 6, 'Luxury'] TotalRewardPoints(dic, list)

output:

The Total Reward Points is 136

(in this problem dictionary is not given so to show function at work i have guessed a dictionary. Please use the dictionary given in task 1 for real problem.

Add a comment
Know the answer?
Add Answer to:
Python 3 please and thank you Task 3: Create a Function 7 Create the function TotalRewardPoints...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In python 3 What you need to do? 1. 2. 3. Create a function implementing the...

    In python 3 What you need to do? 1. 2. 3. Create a function implementing the logic to a Pascal triangle. (You can use any logic of your choice to generate the triangle) Read an integer input from the user, to determine the number of rows to be generated in a Pascal triangle. Call the function by passing the input as an argument to the function. Hint: You can use a list of lists to store the values of a...

  • Expected submission: 1 Python file, Graph_Data.py Make a file called Graph_data Inside this file create 3...

    Expected submission: 1 Python file, Graph_Data.py Make a file called Graph_data Inside this file create 3 functions: 1.) BarGraph: This function should take 5 parameters, X-axis data, y-axis data, X-axis label, y-axis label, title. It will create a bar graph using the above data and display it. 2.) Line Graph: This function is the same as above, except with a line graph instead of a bar graph 3.) SaveGraph: This function is the same as BarGraph, except it saves the...

  • python 3 Define a function that uses two lists similar to the following to create a...

    python 3 Define a function that uses two lists similar to the following to create a dictionary: items = ['laptop', 'tablet', 'smartphone', 'reader', 'camera'] price = [749, 199, 399, 99, 1149] The dictionary should have the names of the items as keys and the prices as values. After creating the dictionary, ask the user to enter the name of an item, and display its price if the item is in the dictionary. If the item is not in the dictionary...

  • Please use Python 3, thank you~ Write a program that: Defines a function called find_item_in_grid, as...

    Please use Python 3, thank you~ Write a program that: Defines a function called find_item_in_grid, as described below. Calls the function find_item_in_grid and prints the result. The find_item_in_grid function should have one parameter, which it should assume is a list of lists (a 2D list). The function should ask the user for a row number and a column number. It should return (not print) the item in the 2D list at the row and column specified by the user. The...

  • write the following code in python 3.2+. Recursive function prefered. Thank you! Define a function named...

    write the following code in python 3.2+. Recursive function prefered. Thank you! Define a function named q3() that accepts a List of characters as a parameter and returns a Dictionary. The Dictionary values will be determined by counting the unique 3 letter combinations created by combining the values at index 0, 1, 2 in the List, then the values at index 1, 2, 3 and so on. The q3() function should continue analyzing each sequential 3 letter combination and using...

  • Python 3.x: Write a function typos(fname) that finds suspected typos in the file fname. To do...

    Python 3.x: Write a function typos(fname) that finds suspected typos in the file fname. To do that we need a dictionary, for which we use the file words.txt which is a reasonably complete list of English words (though you may disagree after running it on some sample texts). Any word in fname that is not in the dictionary should be printed, and we should be told how often it occurs in fname. Below I ran a Mark Train novel to...

  • In this project, you will use functions and dictionaries to track basketball players and their respective...

    In this project, you will use functions and dictionaries to track basketball players and their respective points, then display statistics of points made. You will need three functions as follows: def freeThrowMade(playerDictionary, playerName) - this function will add 1 point to the player's total score def twoPointMade(playerDictionary, playerName) - this function will add 2 points to the player's total score def threePointMade(playerDictionary, playerName) - this function will add 3 points to the player's total score Each of these functions has...

  • In this problem, you will create a selectable “To Do” List. To add a task to...

    In this problem, you will create a selectable “To Do” List. To add a task to this list, the user clicks the Add Task button and enters a description of the task. To delete a task from the list, the user selects the task and then clicks the Delete Task button. Open the HTML and JavaScript files provided as start-up files (index.html from within todo_list_Q.zip file). Then, review the HTML in this file. Note, within the div element, there is...

  • Please use python 3 programming language Write a function that gets a string representing a file...

    Please use python 3 programming language Write a function that gets a string representing a file name and a list. The function writes the content of the list to the file. Each item in the list is written on one line. Name the function WriteList. If all goes well the function returns true, otherwise it returns false. Write another function, RandomRange that takes an integer then it returns a list of length n, where n is an integer passed as...

  • Python: As you drive across one of the Washington DC monuments, there appeared to be a...

    Python: As you drive across one of the Washington DC monuments, there appeared to be a billboard with bold words informing the citizens of DC that the Powerball jackpot has risen to one of the all-time high. As you rest in your deep thoughts thinking that you have chance to win this jackpot. As an IT professional living and working in the District of Columbia area living with five other fellow roommates, who are in the same situation. As the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT