Reference no: EM132586574
Question 1 - Required
Code this question in a separate file. When your solution works, paste it into the "starter file" in the location for question 1.
The code provided assigns data to the following dictionary:
1. Create a DataFrame using ['name', 'sales', 'region'] as column headings:
2. Display the records in the DataFrame which have a value of sales that is more than 40000. Print the resulting DataFrame.
3. Display the records in the DataFrame arranged in alphabetical order by region, with sales in each region from highest to lowest. Print the resulting DataFrame.
Question 2 -Required.
You may wish to develop your solution in a separate file. When your solution works, paste it into the "starter file" in the location for Question 2.
This question uses the data file courses.csv which contains information about fall and spring enrollments for several courses.
1. Create a stacked bar chart showing the number of students enrolled in each course during both fall and spring semesters.
2. Include a legend, title, cyan and green colors, axis labels, and ticks as shown. The width of each bar is 0.3.
3. The largest y-tick value is based on calculating the maximum values for fall and spring enrollments, and spacing them in intervals of 100.
(Please do not use a Pandas DataFrame for this question, but rather, implement your solution using techniques for reading and interacting with CSV files.)
Question 3 -Optional. Answer any four of the six optional questions.
You may wish to develop your solution in a separate file. When your solution works, paste it into the "starter file" in the location for Question 3.
This question uses the data file courses.csv which contains information about fall and spring enrollments for several courses. The first line of the file is a header row. the file is here: courses.csv
Write code to open the file and calculate the total number of students enrolled in any course containing the word "Java" in its name during the Fall Semester. Use whatever file reading techniques you wish to solve the problem.
Question 4-Optional. Answer any four of the six optional questions.
You may wish to develop your solution in a separate file. When your solution works, paste it into the "starter file" in the location for Question 4.
Write a function compare_letters(word1, word2) that returns a string describing whether two words share the same letters in corresponding positions.
The function returns a new string where each character is a + if the corresponding characters in word1 and word2 are the same, and - if they are different. If the strings are of different lengths, the resulting string should contain a ? for each position of the longer string.
Examples:
Your code should work for the three different cases shown in the code in the starter file for question 4. Hint: Get the function to work for two words which have the same length first. Calculate the difference in lengths from both words and append that many "'?"'s to the result.
Question 5-Optional. Answer any four of the six optional questions.
You may wish to develop your solution in a separate file. When your solution works, paste it into the "starter file" in the location for Question 5.
1. Rewrite this code to use a list comprehension.
2. Write a loop to print the index of each item in the list, followed by the original price and price with sales tax.
Question 6-Optional. Answer any four of the six optional questions.
You may wish to develop your solution in a separate file. When your solution works, paste it into the "starter file" in the location for Question 6.
Consider the list of gadgets:
1. Write Python code to display each item followed by its price.
2. Calculate and print the average cost of all items. Hint: You may use the statistics module to compute the average or write code to do it yourself, but that's longer!
Question 7-Optional. Answer any four of the six optional questions.
You may wish to develop your solution in a separate file. When your solution works, paste it into the "starter file" in the location for Question 7.
Consider the dictionary containing hotel prices in various cities:
1. Write code to print the name of each city followed its most expensive hotel price.
2. Write code to compute and print the city and most expensive hotel price from those included in the dictionary.
Question 8-Optional. Answer any four of the six optional questions.
You may wish to develop your solution in a separate file. When your solution works, paste it into the "starter file" in the location for question 8.
A short name is defined as the first letter of a person's first name followed by the first five letters of their last name, converted to upper case. If the last name has five or fewer letters, use the entire last name.)
1. Write a function shortname(name) to return a short name given a tuple containing a first name and last name.
2. Write a function print_short( name, short) to display the full name (first and last, separated by a space) formatted in a field of 20 spaces, followed by the word Shortname:and the corresponding short name.
Your code should work with the sample code provided in the starter file.
Attachment:- Assignment Question.rar