myDictionary= {1:"Apple", 2:"Mango", 3:"Banana"} 2POINTS
write a PYTHON code that removes Apple from the myDictionary, is this possible? explain
write a PYTHON code that inserts Grape into the myDictionary, is this possible? explain
write a PYTHON code that removes 3 from myDictionary, is this possible? Explain
# part a
![1 myDictionary= {1:Apple, 2: Mango, 3: Banana} 2 3 4- 5 6 7 8 for one in myDictionary: if myDictionary[one] Apple: my](http://img.homeworklib.com/questions/83d117f0-8292-11eb-8999-75bad5c61874.png?x-oss-process=image/resize,w_560)
myDictionary= {1:"Apple", 2:"Mango", 3:"Banana"}
for one in myDictionary:
if myDictionary[one] == 'Apple':
myDictionary.pop(one)
break
print(myDictionary)
# part b
myDictionary[4] = "Grape"
# By this {1: 'Apple', 2: 'Mango', 3: 'Banana', 4: 'Grape'}
# part c
myDictionary.pop(3)
# By this {1: 'Apple', 2: 'Mango'}
# Please up vote
myDictionary= {1:"Apple", 2:"Mango", 3:"Banana"} 2POINTS write a PYTHON code that removes Apple from the myDictionary, is...
In Python
1 2 Write a function that removes all occurrences of a given letter from a string: test (remove_letter ("a", "apple") "pple") test (remove_letter ("a", "banana") "bnn") test (remove_letter (2", "banana") "banana") test (remove_letter ("i", "Mississippi") "Msssspp") test (remove letter (",) "") test (remove_letter("b","0"> MO) 4 5 ### Run the following lines. # If you get "Correct" you # did it right. if remove_letter("a", "banana") == "nn": print("Correct!") else: print("Incorrect :(")
In python and without using Libraries (comment the code and please don't use lambda code): Write a function called mostfrequent that takes one string argument containing a list of words separated by commas (e.g., “apple,banana,apple,pear”, note there are no spaces). The function must return the word that occurs most frequently in the input string. You can assume there will be no ties in frequency. Examples: mostfrequent(“apple,apple,banana,apple,peach,banana”) “apple” mostfrequent(“apple,banana,banana,apple,peach,banana”) “banana” mostfrequent(“apple”) “apple”
Question about spark with python.
I have a dataset named example.csv, here is data in CSV file
below: [0] name [1] name of fruits [2] number of fruits
1. use Pyspark code to plot the number of each fruit. sort the
result based on the number of fruits
the x-axis is the name of fruits, the y-axis is num of total
fruits
the output should be apple 10 banana 5 orange 3 mango 2
2. use Pyspark code to plot...
Write a Python program (remove_first_char.py) that removes the first character from each item in a list of words. Sometimes, we come across an issue in which we require to delete the first character from each string, that we might have added by mistake and we need to extend this to the whole list. Having shorthands (like this program) to perform this particular job is always a plus. Your program should contain two functions: (1) remove_first(list): This function takes in a...
Provide Python code that does the following: Create the following list in your program: lst1 = ["apple", "banana", "pear", "grapefruit", "pineapple", "grape", "guava", "plum", "peach"] Write code that then does the following: Print the last item in the list. Print the first item in the list. Print all but the last three items in the list. Print the first, third, fifth etc. items of the list. Print the second, fourth, sixth etc. items of the list. Parts A- E should...
please explain why
Suppose the Xavier values each apple at $1 and each banana at $2; Yolanda values each apple at $2 and each banana at $4; and Zoe value each apple at $2 and each banana at $1. Consider the following three allocations: Allocation 1: Xavier has 4 apples and 3 bananas, Yolanda has 2 apples and 2 bananas, and Zoe has 3 bananas and 4 apples. Allocation 2: Xavier has 3 apples and 4 bananas, Yolanda has 2...
please explain why
Suppose the Xavier values each apple at $1 and each banana at $2; Yolanda values each apple at $2 and each banana at $4; and Zoe value each apple at $2 and each banana at $1. Consider the following three allocations Allocation 1: Xavier has 4 apples and 3 bananas, Yolanda has 2 apples and 2 bananas, and Zoe has 3 bananas and 4 apples. Allocation 2: Xavier has 3 apples and 4 bananas, Yolanda has 2...
The following table shows the Total utility or Marginal utility for three goods apple and mango and orange the price of apple=10 Ryals the price of mango=2 Ryals and price of orange-8 Ryals Complete the following table by calculating the missing data (1 Find the optimum quantity that must be consumed from each goods in (2 order to achieve the maximum utility. Calculate the maximum total utility that you can achieve by consuming (3 . optimum of the three goods...
python
Write a program that reads the name of fruits and the colors from an input file fruit. txt. Each fruit name and the color is given on a line as shown below separated by space Apple Red Orange Orange Grape Green Now write output to an output file (fruit2.txt) as shown below Color of Apple is Red Color of Orange is Orange Color of Grape is Green The program has to be general to read in as many lines...
please explain why
Suppose the Xavier values each apple at $1 and each banana at $2; Yolanda values each apple at $2 and each banana at $4; and Zoe value each apple at $2 and each banana at $1. Consider the following three allocations: Allocation 1: Xavier has 4 apples and 3 bananas, Yolanda has 2 apples and 2 bananas, and Zoe has 3 bananas and 4 apples. Allocation 2: Xavier has 3 apples and 4 bananas, Yolanda has 2...